summaryrefslogtreecommitdiff
path: root/src/FreeType/xttcap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/FreeType/xttcap.c')
-rw-r--r--src/FreeType/xttcap.c361
1 files changed, 158 insertions, 203 deletions
diff --git a/src/FreeType/xttcap.c b/src/FreeType/xttcap.c
index 963d1ff..507da80 100644
--- a/src/FreeType/xttcap.c
+++ b/src/FreeType/xttcap.c
@@ -151,6 +151,164 @@ numOfCorrespondRelations
Functions
*/
+/* get property record type by record name */
+static Bool /* True == Found, False == Not Found */
+get_record_type_by_name(SPropertyRecord const ** const refRefRecord, /*result*/
+ char const *strName)
+{
+ Bool result = False;
+ int i;
+
+ *refRefRecord = NULL;
+ for (i=0; i<numOfValidRecords; i++) {
+ if (!strcasecmp(validRecords[i].strRecordName, strName)) {
+ result = True;
+ *refRefRecord = &validRecords[i];
+ break;
+ }
+ }
+
+ return result;
+}
+
+/* Add Property Record Value */
+static Bool /* True == Error, False == Success */
+SPropRecValList_add_record(SDynPropRecValList *pThisList,
+ char const * const recordName,
+ char const * const strValue)
+{
+ Bool result = False;
+ SPropRecValContainerEntityP tmpContainerE;
+
+ if (get_record_type_by_name(&tmpContainerE.refRecordType, recordName)) {
+ switch (tmpContainerE.refRecordType->recordType) {
+ case eRecTypeInteger:
+ {
+ int val;
+ char *endPtr;
+
+ val = strtol(strValue, &endPtr, 0);
+ if ('\0' != *endPtr) {
+ fprintf(stderr,
+ "truetype font property : "
+ "%s record needs integer value.\n",
+ recordName);
+ result = True;
+ goto quit;
+ }
+ SPropContainer_value_int(&tmpContainerE) = val;
+ }
+ break;
+ case eRecTypeDouble:
+ {
+ double val;
+ char *endPtr;
+
+ val = strtod(strValue, &endPtr);
+ if ('\0' != *endPtr) {
+ fprintf(stderr,
+ "truetype font property : "
+ "%s record needs floating point value.\n",
+ recordName);
+ result = True;
+ goto quit;
+ }
+ SPropContainer_value_dbl(&tmpContainerE) = val;
+ }
+ break;
+ case eRecTypeBool:
+ {
+ Bool val;
+
+ if (!strcasecmp(strValue, "yes"))
+ val = True;
+ else if (!strcasecmp(strValue, "y"))
+ val = True;
+ else if (!strcasecmp(strValue, "on"))
+ val = True;
+ else if (!strcasecmp(strValue, "true"))
+ val = True;
+ else if (!strcasecmp(strValue, "t"))
+ val = True;
+ else if (!strcasecmp(strValue, "ok"))
+ val = True;
+ else if (!strcasecmp(strValue, "no"))
+ val = False;
+ else if (!strcasecmp(strValue, "n"))
+ val = False;
+ else if (!strcasecmp(strValue, "off"))
+ val = False;
+ else if (!strcasecmp(strValue, "false"))
+ val = False;
+ else if (!strcasecmp(strValue, "f"))
+ val = False;
+ else if (!strcasecmp(strValue, "bad"))
+ val = False;
+ else {
+ fprintf(stderr,
+ "truetype font property : "
+ "%s record needs boolean value.\n",
+ recordName);
+ result = True;
+ goto quit;
+ }
+ SPropContainer_value_bool(&tmpContainerE) = val;
+ }
+ break;
+ case eRecTypeString:
+ {
+ char *p;
+
+ if (NULL == (p = (char *)xalloc(strlen(strValue)+1))) {
+ fprintf(stderr,
+ "truetype font property : "
+ "cannot allocate memory.\n");
+ result = True;
+ goto quit;
+ }
+ strcpy(p, strValue);
+ SPropContainer_value_str(&tmpContainerE) = p;
+ }
+ break;
+ case eRecTypeVoid:
+ if ('\0' != *strValue) {
+ fprintf(stderr,
+ "truetype font property : "
+ "%s record needs void.\n", recordName);
+ result = True;
+ }
+ break;
+ }
+ {
+ /* add to list */
+ SPropRecValListNodeP *newNode;
+
+ if (NULL == (newNode =
+ (SPropRecValListNodeP *)xalloc(sizeof(*newNode)))) {
+ fprintf(stderr,
+ "truetype font property : "
+ "cannot allocate memory.\n");
+ result = True;
+ goto quit;
+ }
+ newNode->nextNode = pThisList->headNode;
+ newNode->containerE = tmpContainerE;
+ tmpContainerE.refRecordType = NULL; /* invalidate --
+ disown value handle. */
+ pThisList->headNode = newNode;
+ }
+ } else {
+ /* invalid record name */
+ fprintf(stderr,
+ "truetype font : "
+ "invalid record name \"%s.\"\n", recordName);
+ result = True;
+ }
+
+ quit:
+ return result;
+}
+
#ifdef USE_TTP_FILE
#ifndef LEN_LINEBUF
@@ -393,26 +551,6 @@ SPropRecValList_read_prop_file(SDynPropRecValList *pThisList,
}
#endif /* USE_TTP_FILE */
-/* get property record type by record name */
-static Bool /* True == Found, False == Not Found */
-get_record_type_by_name(SPropertyRecord const ** const refRefRecord, /*result*/
- char const *strName)
-{
- Bool result = False;
- int i;
-
- *refRefRecord = NULL;
- for (i=0; i<numOfValidRecords; i++) {
- if (!strcasecmp(validRecords[i].strRecordName, strName)) {
- result = True;
- *refRefRecord = &validRecords[i];
- break;
- }
- }
-
- return result;
-}
-
/* Constructor for Container Node */
Bool /* True == Error, False == Success */
SPropRecValList_new(SDynPropRecValList *pThisList)
@@ -424,37 +562,6 @@ SPropRecValList_new(SDynPropRecValList *pThisList)
return result;
}
-/* Destructor for Container List */
-Bool /* True == Error, False == Success */
-SPropRecValList_delete(SDynPropRecValList *pThisList)
-{
- Bool result = False;
- SPropRecValListNodeP *p, *np;
-
- for (p=pThisList->headNode; NULL!=p; p=np) {
- np = p->nextNode;
- switch (p->containerE.refRecordType->recordType) {
- case eRecTypeInteger:
- break;
- case eRecTypeDouble:
- break;
- case eRecTypeBool:
- break;
- case eRecTypeString:
- if (SPropContainer_value_str(&p->containerE))
- xfree((void*)SPropContainer_value_str(&p->containerE));
- break;
- case eRecTypeVoid:
- break;
- }
- xfree(p);
- }
-
- pThisList->headNode = NULL;
-
- return result;
-}
-
#ifdef DUMP
void
SPropRecValList_dump(SRefPropRecValList *pThisList)
@@ -492,144 +599,6 @@ SPropRecValList_dump(SRefPropRecValList *pThisList)
}
#endif
-/* Add Property Record Value */
-extern Bool /* True == Error, False == Success */
-SPropRecValList_add_record(SDynPropRecValList *pThisList,
- char const * const recordName,
- char const * const strValue)
-{
- Bool result = False;
- SPropRecValContainerEntityP tmpContainerE;
-
- if (get_record_type_by_name(&tmpContainerE.refRecordType, recordName)) {
- switch (tmpContainerE.refRecordType->recordType) {
- case eRecTypeInteger:
- {
- int val;
- char *endPtr;
-
- val = strtol(strValue, &endPtr, 0);
- if ('\0' != *endPtr) {
- fprintf(stderr,
- "truetype font property : "
- "%s record needs integer value.\n",
- recordName);
- result = True;
- goto quit;
- }
- SPropContainer_value_int(&tmpContainerE) = val;
- }
- break;
- case eRecTypeDouble:
- {
- double val;
- char *endPtr;
-
- val = strtod(strValue, &endPtr);
- if ('\0' != *endPtr) {
- fprintf(stderr,
- "truetype font property : "
- "%s record needs floating point value.\n",
- recordName);
- result = True;
- goto quit;
- }
- SPropContainer_value_dbl(&tmpContainerE) = val;
- }
- break;
- case eRecTypeBool:
- {
- Bool val;
-
- if (!strcasecmp(strValue, "yes"))
- val = True;
- else if (!strcasecmp(strValue, "y"))
- val = True;
- else if (!strcasecmp(strValue, "on"))
- val = True;
- else if (!strcasecmp(strValue, "true"))
- val = True;
- else if (!strcasecmp(strValue, "t"))
- val = True;
- else if (!strcasecmp(strValue, "ok"))
- val = True;
- else if (!strcasecmp(strValue, "no"))
- val = False;
- else if (!strcasecmp(strValue, "n"))
- val = False;
- else if (!strcasecmp(strValue, "off"))
- val = False;
- else if (!strcasecmp(strValue, "false"))
- val = False;
- else if (!strcasecmp(strValue, "f"))
- val = False;
- else if (!strcasecmp(strValue, "bad"))
- val = False;
- else {
- fprintf(stderr,
- "truetype font property : "
- "%s record needs boolean value.\n",
- recordName);
- result = True;
- goto quit;
- }
- SPropContainer_value_bool(&tmpContainerE) = val;
- }
- break;
- case eRecTypeString:
- {
- char *p;
-
- if (NULL == (p = (char *)xalloc(strlen(strValue)+1))) {
- fprintf(stderr,
- "truetype font property : "
- "cannot allocate memory.\n");
- result = True;
- goto quit;
- }
- strcpy(p, strValue);
- SPropContainer_value_str(&tmpContainerE) = p;
- }
- break;
- case eRecTypeVoid:
- if ('\0' != *strValue) {
- fprintf(stderr,
- "truetype font property : "
- "%s record needs void.\n", recordName);
- result = True;
- }
- break;
- }
- {
- /* add to list */
- SPropRecValListNodeP *newNode;
-
- if (NULL == (newNode =
- (SPropRecValListNodeP *)xalloc(sizeof(*newNode)))) {
- fprintf(stderr,
- "truetype font property : "
- "cannot allocate memory.\n");
- result = True;
- goto quit;
- }
- newNode->nextNode = pThisList->headNode;
- newNode->containerE = tmpContainerE;
- tmpContainerE.refRecordType = NULL; /* invalidate --
- disown value handle. */
- pThisList->headNode = newNode;
- }
- } else {
- /* invalid record name */
- fprintf(stderr,
- "truetype font : "
- "invalid record name \"%s.\"\n", recordName);
- result = True;
- }
-
- quit:
- return result;
-}
-
/* Search Property Record */
Bool /* True == Hit, False == Miss */
@@ -759,18 +728,4 @@ XttXstrdup(char const *str)
}
-#if 0
-int main()
-{
- SDynPropRecValList list;
-
- SPropRecValList_new(&list);
- SPropRecValList_read_prop_file(&list, "-");
- SPropRecValList_dump(&list);
- SPropRecValList_delete(&list);
-
- return 0;
-}
-#endif
-
/* end of file */