1 /* $XConsortium: parser.c /main/8 1996/03/25 09:14:08 rswiston $ */
2 /***************************************************************************/
6 /***************************************************************************/
19 /***************************************************************************
21 * Local procedure declarations
23 ***************************************************************************/
26 char ** GetKeywordValuePairs(char *, int *, int);
27 FiletypeData ** GetFiletypeData(FILE *, char *, short *);
28 char ** ProcessExecString(char *);
29 int ProcessContents(FiletypeData *);
30 Boolean IsLastSingle(char *);
33 /***************************************************************************
35 * Extern variable declarations
37 ***************************************************************************/
40 /***************************************************************************
42 * Global variable declarations
44 ***************************************************************************/
46 /* Action Keyword Table */
47 char keywordDB[][30] = { "ACTION" ,
58 /* Max Number of fields in Action Keyword Table */
59 #define MAX_NUM_ACTION_FIELDS 8
61 /* Filetype Keyword Table */
62 char FiletypekeywordDB[][30] = { "DATA_ATTRIBUTES" ,
71 "DATA_ATTRIBUTES_NAME" ,
82 /* Max Number of fields in Filetype Keyword Table */
83 #define MAX_NUM_FILETYPE_FIELDS 17
91 /*****************************************************************
93 ** GetActionData(FILE *fp, ActionData *) **
95 ** Description: Parses the action file and fills the data in the**
96 ** pointer pointing to the ActionData structure **
97 ** passed as input. **
99 ** Input : Filepointer that points to the ActionFile and, **
100 ** a pointer to the ActionData structure. **
102 ** Output : 0 (No error). **
105 ** references : dtcreate.h, parser.h, and dtcreate spec. **
107 ******************************************************************/
111 GetActionData(FILE *fp, ActionData *ActionDataptr)
113 int rc,manflds=0,len,first=TRUE,lastfld=0,fldid=-1;
114 char linebuf[1024],**wordPairs,**execstr;
117 /* reset the read pointer to zero byte for fp */
119 /* Initialize the ActionData structure passed */
121 memset((ActionData *)ActionDataptr,
122 NULL,sizeof(ActionData));
125 printf("ActionDataptr is NULL\n");
130 /* initialize the linebuf with NULL's */
131 bzero(linebuf,sizeof(linebuf));
132 while (fgets (linebuf, sizeof (linebuf)-1, fp))
134 /* skip the complete line if it starts with a '{' or a comment ('#') */
135 if(linebuf[0] == '{' || linebuf[0] == '#') continue;
136 /* If the first character is '}' reached the end of Action Stanza so quit */
137 if(linebuf[0] == '}')
139 len = strlen (linebuf);
140 if (linebuf[len-1] == '\n')
141 linebuf[len-1] = '\0';
142 /* Get the keyword and value pair from the string linebuf */
143 /* On return, wordPairs[0] = keyword like ICON
144 and wordPairs[1] = value for the keyword
146 if( (wordPairs = GetKeywordValuePairs(linebuf,&fldid,ACTION_TABLE)) != NULL)
148 if( first && strcmp(wordPairs[0],"ACTION") )
151 printf("first && strcmp(wordPairs[0],ACTION)\n");
157 /* Update the mandatory fields counter */
158 if( !strcmp(wordPairs[0],"TYPE") ||
159 !strcmp(wordPairs[0],"EXEC_STRING") ||
160 !strcmp(wordPairs[0],"WINDOW_TYPE") )
162 if( !strcmp(wordPairs[0],"WINDOW_TYPE") )
164 if( !strcmp(wordPairs[1],"PERM_TERMINAL") )
165 ActionDataptr->fsFlags |= CA_WT_PERMTERM;
166 if( !strcmp(wordPairs[1],"TERMINAL") )
167 ActionDataptr->fsFlags |= CA_WT_TERM;
168 if( !strcmp(wordPairs[1],"NO_STDIO") )
169 ActionDataptr->fsFlags |= CA_WT_XWINDOWS;
171 if( !strcmp(wordPairs[0],"ARG_TYPE") )
172 ActionDataptr->fsFlags |= CA_DF_ONLYFTFILES;
174 /* if linebuf does not contain the keyword then everything
175 in wordPairs[0],else, wordPairs[0] contains the keyword
176 and wordpairs[1] contains the value.
178 if( wordPairs && wordPairs[0] && !wordPairs[1])
180 /* fldid is returned by the GetKeywordValuePairs function.
181 This id determines which field of the ActionDataptr will
182 have the value. Please see KeywordDB array in parser.h
187 case 7: /* next line for action_name */
188 ActionDataptr->pszName=wordPairs[0];
191 case 1: /* next line for action_icon_name */
192 ActionDataptr->pszIcon=wordPairs[0];
195 case 2 : /* next line for exec_string */
196 ActionDataptr->pszCmd=wordPairs[0];
199 case 3: /* next line for action_help_text */
200 ActionDataptr->pszHelp=wordPairs[0];
206 else if(wordPairs && wordPairs[1])
208 if(fldid >= 0 && fldid <=2)
210 /* for fldid see the comments above */
213 case 7: /* first line for action_name */
214 ActionDataptr->pszName=wordPairs[1];
217 case 1: /* first line for action_icon_name */
218 ActionDataptr->pszIcon=wordPairs[1];
221 case 2 : /* first line for exec_string */
222 ActionDataptr->pszCmd=wordPairs[1];
225 case 3: /* first line for action_help_text */
227 ActionDataptr->pszHelp=wordPairs[1];
230 default: state=0;break;
234 /* reset the linebuf to NULL's */
235 bzero(linebuf,sizeof(linebuf));
240 /* Done with retrieving Action Data */
241 /* Check if we got all the mandatory fields data */
244 printf("if(manflds != 3)\n");
249 /* Everything looks right so process the exec_string */
250 if( !(execstr = ProcessExecString(ActionDataptr->pszCmd)) )
252 ActionDataptr->pszCmd = NULL;
253 ActionDataptr->pszPrompt = 0;
257 ActionDataptr->pszCmd = execstr[0];
258 ActionDataptr->pszPrompt = execstr[1];
260 /* Got the ActionData,so, go get the FiletypeData */
261 ActionDataptr->papFiletypes =
262 (FiletypeData **) GetFiletypeData(fp,(char *)(ActionDataptr->pszCmd),
263 (short *)&(ActionDataptr->cFiletypes) );
264 if( !ActionDataptr->papFiletypes && ActionDataptr->cFiletypes > 0) {
266 printf("!ActionDataptr->papFiletypes && ActionDataptr->cFiletypes > 0)\n");
268 return(1); /* return 1 if error */
270 return(0); /* return 0 if no error */
276 /*****************************************************************
278 ** GetFiletypeData(FILE *fp, char *pszOpenCmd) **
280 ** Description: Parses the action file and returns a pointer **
281 ** that points to the data in the form of **
282 ** FiletypeData structure (defined in dtcreate.h). **
284 ** Input : Filepointer that points to the ActionFile, and, **
285 ** a char pointer to the exec_string of the **
286 ** ActionData structure as obtained in the GetAc- **
287 ** -tionData function call. **
289 ** Output : Pointer to an array of FiletypeData structures **
290 ** containing data for all the Filetypes,and,no of **
293 ** references : dtcreate.h, parser.h, and dtcreate spec. **
295 ******************************************************************/
298 GetFiletypeData(FILE *fp, char *pszOpenCmd, short *nftypes)
300 int manflds=0,len,nfiletypes,previous=0,lastfld=0,fldid;
301 char linebuf[1024],**wordPairs,**execstr;
302 FiletypeData **ppFiletypeData,**ppnewFiletypeData;
308 /* Initialize the linebuf */
309 bzero(linebuf,sizeof(linebuf));
310 while (fgets (linebuf, sizeof (linebuf)-1, fp))
312 /* If begin of a stanza skip and continue */
313 if(linebuf[0] == '{')
318 /* skip the rest of the line if a comment found */
319 if(linebuf[0] == '#') continue;
321 /* If end of a stanza check if all the mandatory fields are there */
322 if( linebuf[0] == '}' )
324 /* Check for atleast one field in DATA_ATTRIBUTES stanza */
325 if( previous == DATA_ATTRIBUTES && manflds != 1 )
327 printf("Error in DATA_ATTR stanza of the FiletypeData\n");
330 /* Check for atleast one field in DATA_CRITERIA stanza */
331 else if( previous == DATA_CRITERIA && manflds != 1 )
333 printf("Error in DATA_CRITERIA stanza of the FiletypeData\n");
336 /* Check for atleast two fields in ACTION_OPEN or ACTION_PRINT stanza */
337 else if( (previous == ACTION_OPEN || previous == ACTION_PRINT) )
341 printf("Error in ACTION_OPEN/PRINT stanza of the FiletypeData\n");
345 /* Check for atleast three fields in ACTION_PRINT_FTYPE stanza */
346 else if( previous == ACTION_PRINT_FTYPE && manflds != 3 )
348 printf("Error in ACTION_PRINT_FTYPE stanza of the FiletypeData\n");
353 len = strlen (linebuf);
354 if (linebuf[len-1] == '\n')
355 linebuf[len-1] = '\0';
357 if( (wordPairs = GetKeywordValuePairs(linebuf,&fldid,FILETYPE_TABLE)) != NULL)
359 if( !strcmp(wordPairs[0],"DATA_ATTRIBUTES") )
364 /* Allocate a filetypedata pointer to an array of filetypedata records */
367 if( (ppFiletypeData = (FiletypeData **)calloc(1,sizeof(FiletypeData *)))
370 printf("\n Cannot allocate memory\n");
373 /* Allocate a filetypedata record */
376 if( (ppFiletypeData[nfiletypes] =
377 (FiletypeData *)calloc(1,sizeof(FiletypeData)) )
380 printf("\n Cannot allocate memory\n");
386 ppFiletypeData[nfiletypes]->pszOpenCmd = pszOpenCmd;
387 previous = DATA_ATTRIBUTES;
390 else if(previous == ACTION_OPEN || previous == ACTION_PRINT)
392 /* New filetypedata started so allocate a new filetypedata ptr */
393 if( (ppnewFiletypeData =
394 (FiletypeData **)realloc((FiletypeData *)ppFiletypeData,
395 nfiletypes+2 * sizeof(FiletypeData *)))
398 printf("\n Cannot allocate memory\n");
401 else if(ppFiletypeData)
403 ppFiletypeData=ppnewFiletypeData;
404 /* Process the contents field if any */
405 if(ProcessContents((FiletypeData *)ppFiletypeData[nfiletypes]) < 0 )
407 printf("\n Error in Contents Data\n");
410 /* Everything looks right so process the exec_string */
411 if( !(execstr = ProcessExecString((char *)ppFiletypeData[nfiletypes]->pszPrintCmd)) )
412 ppFiletypeData[nfiletypes]->pszPrintCmd=NULL;
414 ppFiletypeData[nfiletypes]->pszPrintCmd=execstr[0];
416 /* Allocate a new filetypedata record */
417 if( (ppFiletypeData[nfiletypes] =
418 (FiletypeData *)calloc(1,sizeof(FiletypeData)) )
421 printf("\n Cannot allocate memory\n");
424 ppFiletypeData[nfiletypes]->pszOpenCmd = pszOpenCmd;
425 previous = DATA_ATTRIBUTES;
432 printf("Error in filetypedata \n");
436 else if( !strcmp(wordPairs[0],"DATA_CRITERIA") )
438 if( previous == DATA_ATTRIBUTES )
440 previous = DATA_CRITERIA;
445 printf("Error in filetypedata \n");
449 else if( !strcmp(wordPairs[0],"ACTION") && !strcmp(wordPairs[1],"Open") )
451 if( previous == DATA_CRITERIA )
453 previous = ACTION_OPEN;
458 printf("Error in filetypedata \n");
462 else if( !strcmp(wordPairs[0],"ACTION") && strcmp(wordPairs[1],"Open") &&
463 strcmp(wordPairs[1], "Print") )
465 if( previous == ACTION_OPEN )
467 previous = ACTION_PRINT_FTYPE;
472 printf("Error in filetypedata \n");
476 else if( !strcmp(wordPairs[0],"ACTION") && !strcmp(wordPairs[1],"Print") )
478 if( previous == ACTION_PRINT_FTYPE )
480 previous = ACTION_PRINT;
485 printf("Error in filetypedata \n");
491 /* update mandatory fields counter */
492 if( previous == DATA_ATTRIBUTES && strcmp(wordPairs[0],"DATA_ATTRIBUTES") )
494 if( !strcmp(wordPairs[0],"ACTIONS") )
497 else if( previous == DATA_CRITERIA )
499 if( !strcmp(wordPairs[0],"DATA_ATTRIBUTES_NAME") )
502 else if( previous == ACTION_OPEN || previous == ACTION_PRINT )
504 if( !strcmp(wordPairs[0],"ARG_TYPE") ||
505 !strcmp(wordPairs[0],"TYPE") ||
506 !strcmp(wordPairs[0],"MAP_ACTION") ||
507 !strcmp(wordPairs[0],"LABEL") )
510 else if( previous == ACTION_PRINT_FTYPE )
512 if( !strcmp(wordPairs[0],"TYPE") ||
513 !strcmp(wordPairs[0],"WINDOW_TYPE") )
521 if( wordPairs && !wordPairs[1] && wordPairs[0])
525 case 0: /* next line for filetype_name */
526 ppFiletypeData[nfiletypes]->pszName=wordPairs[0];
529 case 1: /* next line for icon_name */
530 ppFiletypeData[nfiletypes]->pszIcon=wordPairs[0];
533 case 2 : /* next line for help_text */
534 ppFiletypeData[nfiletypes]->pszHelp=wordPairs[0];
537 case 3: /* next line for print_cmd */
538 ppFiletypeData[nfiletypes]->pszPrintCmd=wordPairs[0];
541 case 4: /* next line for name_pattern or path_pattern */
542 ppFiletypeData[nfiletypes]->pszPattern=wordPairs[0];
544 case 5: /* next line for name_pattern or path_pattern */
545 ppFiletypeData[nfiletypes]->pszPattern=wordPairs[0];
547 case 6: /* next line for mode */
548 ppFiletypeData[nfiletypes]->pszPermissions=wordPairs[0];
550 case 7: /* next line for contents */
551 ppFiletypeData[nfiletypes]->pszContents=wordPairs[0];
557 else if(wordPairs && wordPairs[1])
561 case 0: /* first line for filetype_name */
562 ppFiletypeData[nfiletypes]->pszName = wordPairs[1];
565 case 1: /* first line for icon_name */
566 ppFiletypeData[nfiletypes]->pszIcon=wordPairs[1];
569 case 2 : /* first line for help_text */
570 ppFiletypeData[nfiletypes]->pszHelp=wordPairs[1];
573 case 3: /* first line for print_cmd */
574 ppFiletypeData[nfiletypes]->pszPrintCmd=wordPairs[1];
578 case 4: /* first line for name_pattern or path_pattern */
579 ppFiletypeData[nfiletypes]->pszPattern=wordPairs[1];
582 case 5: /* first line for name_pattern or path_pattern */
583 ppFiletypeData[nfiletypes]->pszPattern=wordPairs[1];
586 case 6: /* first line for mode */
587 ppFiletypeData[nfiletypes]->pszPermissions=wordPairs[1];
590 case 7: /* first line for contents */
591 ppFiletypeData[nfiletypes]->pszContents=wordPairs[1];
599 bzero(linebuf,sizeof(linebuf));
600 } /* end of while fgets */
602 /* Done with retrieving FiletypeData */
603 /* Check if we got all the mandatory fields data */
604 if( (previous == ACTION_OPEN && manflds != 4) ||
605 (previous == ACTION_PRINT && manflds != 4) )
607 else if(ppFiletypeData)
609 /* Process Contents for the last file filetype if any */
610 if(ProcessContents((FiletypeData *)ppFiletypeData[nfiletypes]) < 0)
612 printf("\n Error in Contents Data\n");
615 /* Everything looks right so process the exec_string */
617 ProcessExecString((char *)ppFiletypeData[nfiletypes]->pszPrintCmd)) )
618 ppFiletypeData[nfiletypes]->pszPrintCmd=NULL;
620 ppFiletypeData[nfiletypes]->pszPrintCmd=execstr[0];
621 if( !ppFiletypeData[nfiletypes])
622 ppFiletypeData[nfiletypes] = 0;
623 /* return number of filetypes */
624 *nftypes = nfiletypes+1;
625 return ppFiletypeData;
633 /*****************************************************************
635 ** GetKeywordValuePairs(char *s, int *id, int table) **
637 ** Description: Parses the text string in *s and returns a **
638 ** pointer to two strings that are Keyword and **
639 ** values.However, it returns the complete string **
640 ** in the first pointer if keyword not found. **
642 ** Input : A character pointer pointing to text string. **
643 ** An integer pointer to return the field id. **
644 ** An integer value that determines which table to **
645 ** use (either ACTION_TABLE of FILETYPE_TABLE). **
646 ** see definitions in parser.h **
648 ** Output : pointer to two pointers pointing to text strings**
649 ** fieldid in the id parameter. **
651 ** references : dtcreate.h, parser.h, and dtcreate spec. **
653 ******************************************************************/
656 GetKeywordValuePairs(char *s, int *id, int table)
662 args[0] = args[1] = args[2] = NULL;
663 /* Skip all leading spaces */
664 while (*s && isspace (*s))
666 /* Skip the complete line if a '#' character is found (comments) */
667 if (!*s || *s == '#')
670 while (*s && *s != '#' && !isspace (*s))
674 args[0] = (char *)malloc (s - wordStart + 1);
677 memset(args[0],0,sizeof(args[0]));
679 strncpy (args[0], wordStart, s - wordStart);
680 args[0][s-wordStart] = '\0';
684 args[1] = (char *)malloc (strlen(s)+1);
691 memset(args[1],0,sizeof(args[1]));
693 /* Skip all leading spaces */
694 while (*s && isspace (*s))
698 /* Check for whether args[0] is a keyword or not */
700 if( table == ACTION_TABLE )
702 /* Check for keyword in keywordDB defined in parser.h */
703 while((strcmp(keywordDB[idx],"")) && (strcmp(args[0],keywordDB[idx])) ) idx++;
704 if(idx >= 0 && idx < MAX_NUM_ACTION_FIELDS)
707 else if( table == FILETYPE_TABLE )
709 /* Check for keyword in FiletypekeywordDB defined in parser.h */
710 while((strcmp(FiletypekeywordDB[idx],"")) && (strcmp(args[0],FiletypekeywordDB[idx])) ) idx++;
711 if(idx >= 0 && idx < MAX_NUM_FILETYPE_FIELDS)
714 /* If no keyword found then keep the complete string
717 if( (idx == MAX_NUM_ACTION_FIELDS && table == ACTION_TABLE) ||
718 (idx == MAX_NUM_FILETYPE_FIELDS && table == FILETYPE_TABLE) )
722 if( (temp4 = (char *)realloc(args[0],strlen(args[0])+strlen(args[1])+2) ) == NULL )
724 printf("Cannot Allocate memory\n");
729 strcat(args[0],args[1]);
736 if( IsLastSingle(args[0]) && args[0][strlen(args[0])-1] == '\\' )
737 args[0][strlen(args[0])-1] = '\0';
738 if( (temp4 = (char *)realloc(fline,flinesize+strlen(args[0])+1)) == NULL)
740 printf("Cannot Allocate memory\n");
743 strcat(temp4,args[0]);
748 *id = fldid; /* return field id */
749 if(args[1] && IsLastSingle(args[1]) && args[1][strlen(args[1])-1] == '\\')
750 args[1][strlen(args[1])-1] = '\0';
752 args[0][strlen(args[0])] = '\0';
754 args[1][strlen(args[1])] = '\0';
755 if(args[0] && args[1])
758 flinesize=strlen(fline);
760 if(!args[1] && args[0])
763 flinesize=strlen(fline);
769 /*****************************************************************
771 ** ProcessExecString(char *) **
773 ** Description: Parses the text string and returns two pointers,**
774 ** the first pointing to cmd part (if any) **
775 ** the second pointing to prompt part (if any) **
776 ** of either the ActionData structure type or **
777 ** FiletypeData structure type. Please see **
778 ** dtcreate.h for the above mentioned datastructure**
779 ** definitions and for the cmd and prompt fields **
781 ** Input : A character pointer that points to the complete **
782 ** text string comprising the command and arguments**
783 ** and prompt (if any). **
785 ** Limitation : Supports only ONE prompt. **
787 ** Output : returns 0 (No error). **
788 ** returns >0 (Error). **
790 ** Assumptions: a) Arg fields start with a '%' character. **
791 ** b) Prompt string start and end with '"' chara- **
792 ** cter. Also, the prompt string comes after **
793 ** the Arg strings if any. **
795 ** references : dtcreate.h, parser.h, and dtcreate spec. **
797 ******************************************************************/
800 ProcessExecString(char *cmd)
803 char *s1, *s2,*s3,*s4,*argbuf,*exec_args[3];
804 int done=FALSE, argfound=FALSE,promptfound=FALSE;
807 return((char **)NULL);
809 s1=s2=s3=s4=argbuf=NULL;
810 /* Allocate buffer for the cmd string */
811 exec_args[0] = (char *)calloc(1,strlen(cmd)+1);
812 exec_args[1] = exec_args[2] = NULL;
813 /* check if any Args present */
819 s4 = strstr(s1,"%Arg");
824 strncat(exec_args[0],s1,(s4-s1));
825 exec_args[0][strlen(exec_args[0])] = '\0';
828 s2 = strchr(s1+1,'%'); /* at this point we got s1 to s2
829 covers the complete string
832 if(argbuf) free(argbuf);
835 argbuf = (char *)calloc(1,(s2-s1)+2);
836 strncpy(argbuf,s1,(s2-s1)+1);
840 strcat(exec_args[0],s1);
844 argbuf[strlen(argbuf)]='\0';
845 if( strncmp(argbuf,"%Arg_",5) &&
846 strncmp(argbuf,"%Args%",6) &&
847 strncmp(argbuf,"%Args\"",6) )
849 strncat(exec_args[0],argbuf,strlen(argbuf)-1);
850 exec_args[0][strlen(exec_args[0])] = '\0';
857 strcat(exec_args[0],s1);
858 if(argbuf) free(argbuf);
868 /* move s1 until a '_' or 's' */
869 tmp = strchr(argbuf,'_');
871 tmp= strchr(argbuf,'s');
872 strcat(exec_args[0],"$");
874 /* start of Arg processing */
875 while (*tmp != '%' && *tmp != '"' )
879 strcat(exec_args[0],"*");
882 if( *tmp > '0' && *tmp <= '9')
884 strncat(exec_args[0],tmp,1);
885 exec_args[0][strlen(exec_args[0])] = '\0';
889 /* end of Arg processing */
891 /* Get Prompt string if any */
892 s3 = strchr(argbuf,'"');
893 if(s3 && *(s3+1) != '"')
898 if( (tmp = strchr(s3,'"')) )
901 exec_args[1] = (char *)calloc(1,(tmp-s3)+1);
902 strncpy(exec_args[1],s3,(tmp-s3));
903 exec_args[1][strlen(exec_args[1])] = '\0';
908 /* see if there is some stuff between the last '%'
909 and the next first '%' of another Arg
915 if(argbuf) free(argbuf);
919 /*****************************************************************
921 ** ProcessContents(FiletypeData *) **
923 ** Description: Parses the text string in pszContents field and **
924 ** fills the sStart,fsFlags and pszContents fields **
925 ** of the filetypeData datastructure that is passed**
928 ** Input : A pointer of type FiletypeData defined in **
931 ** Output : Fills the sStart, fsFlags and pszContents fields**
932 ** of the FiletypeData pointer and returns 0 (No **
933 ** error or >0 (error) values. **
935 ** Assumptions: Fields are separated by atleast one blank **
938 ** references : dtcreate.h, parser.h, and dtcreate spec. **
940 ******************************************************************/
943 ProcessContents(FiletypeData *pFtD)
946 char *s1,*tmp,*s2,buf[10],*cts;
949 bzero(buf,sizeof(buf));
950 /* simply return if there is no data in contents field */
951 if(!pFtD->pszContents)
953 cts = (char *)calloc(1,strlen(pFtD->pszContents)+1);
954 strcpy(cts,pFtD->pszContents);
956 free(pFtD->pszContents);
957 pFtD->pszContents=NULL;
958 /* Skip all leading spaces */
959 while( *s1 && isspace(*s1) ) s1++;
960 /* Get the sStart value if any */
962 if( (s1 = strchr(cts,' ')) )
964 while( *s1 && !isspace(*s1) && *s1 != '\n') s1++;
967 strncpy(buf,cts,(s1-cts));
969 pFtD->sStart=atoi(buf);
971 while( *s1 && isspace(*s1) ) s1++;
973 /* Get the fsFlags value if any */
975 bzero(buf,sizeof(buf));
977 if ( (tmp = strchr(s1,' ')) )
979 while( *tmp && !isspace(*tmp) && *tmp != '\n') tmp++;
982 strncpy(buf,s1,(tmp-s1));
984 if ( !strcmp(buf,"byte") )
985 pFtD->fsFlags|=CA_FT_CNTBYTE;
986 else if ( !strcmp(buf,"string") )
987 pFtD->fsFlags|=CA_FT_CNTSTRING;
988 else if ( !strcmp(buf,"long") )
989 pFtD->fsFlags|=CA_FT_CNTLONG;
990 else if ( !strcmp(buf,"short") )
991 pFtD->fsFlags|=CA_FT_CNTSHORT;
995 while( *tmp && isspace(*tmp) ) tmp++;
997 /* Get the contents if any */
1000 pFtD->pszContents = (char *)calloc(1,strlen(s2)+1);
1001 strcpy(pFtD->pszContents,s2);
1010 /*****************************************************************
1012 ** IsLastSingle(char *str) **
1014 ** Description: returns TRUE if the last character of the **
1015 ** string str is a single-byte character, returns **
1016 ** FALSE if it is a multi-byte character. **
1018 ******************************************************************/
1021 IsLastSingle(char *str)
1029 n = mblen(str, MB_CUR_MAX);