#include "creatdct.h" /* included in this file are: (char *) s = skipblnk(char *t) (void) stccpy(char *to, char *from, int length) (void) lowercase(char *s) (void) cpytok(char *t, char *s) (void) righttrim(char *s) (void) righttrimchar(char *s, char c) (int) haschar(char *s, char *c) (int) indexc(char *s, char *t) */ /* ------------------------------------------------------------------------*/ /* _ (char *) s = skipblnk(char *t) - skips over blank characters, returns pointer to first nonblank character in t. Copyright (c) 1991 by C.R.C. */ char *skipblnk(s) register char *s ; { while(*s==' ') s++ ; return(s) ; } /* ------------------------------------------------------------------------*/ /* (void) stccpy(to, from, length) char *to destination string pointer char *from source string pointer int length maximum length of copy Copies "from" to "to" for a maximum length of "length". "to" is ALWAYS null-termianted. Note that length includes the terminating null byte. Thus, stccpy(to,from,1) always produces 0-length string. Copyright (c) 1988 by CRC */ void stccpy(to,from,length) register char *to, *from ; int length ; { int i ; for (i=1;*from!='\0' && i='A' && *s<='Z') (*s) += 32 ; } } /* ------------------------------------------------------------------------*/ /* (void) cpytok(char *t, char *s) Copies next token from s into t. Assumes leading white space already stripped from s. Tokens are parsed on blanks and bound using single or double quotes. */ void cpytok(t,s) char *t ; char *s ; { char q ; if (*s=='\"' || *s=='\'') { q = *t = * s ; for(t++,s++;*s!=q;s++,t++) { if (*s=='\0') { fprintf(stderr, "%s: missing close quote character\n", progname) ; exit(BADINPUT_ERROR) ; /*NOTREACHED*/ } *t = *s ; } *t++ = '\"' ; *t = '\0' ; s++ ; if (*s!=' ' && *s!='\0') { fprintf(stderr, "%s: no blank after close quote\n",progname) ; exit(BADINPUT_ERROR) ; /*NOTREACHED*/ } return ; } for (;*s!=' ' && *s!='\0';s++,t++) *t = *s ; *t = '\0' ; } /* ------------------------------------------------------------------------*/ /* (void) righttrim(char *s) removes trailing blanks from s (void) righttrimchar(char *s, char c) removes trailing char c from s */ void righttrim(s) char *s ; { righttrimchar(s,' ') ; } void righttrimchar(s,c) char *s ; char c ; { register int l ; for (l=strlen(s)-1;l>=0;l--) { if (s[l]!=c) return ; s[l] = '\0' ; } } /* ------------------------------------------------------------------------*/ /* (int) haschar(char *s, char c) returns 1 if s contains c, 0 otherwise. */ int haschar(s, c) char *s ; char c ; { for (;*s;s++) { if (*s==c) return(1) ; } return(0) ; } /* ------------------------------------------------------------------------*/ /* (int) indexc(char *s, char *t) returns position in s in which character in t is found */ int indexc(s,t) char s[] ; register char *t ; { register int i ; for (;*t!='\0';t++) { for (i=0;s[i]!='\0';i++) { if (s[i]== *t) return(i) ; } } return(-1) ; }