home *** CD-ROM | disk | FTP | other *** search
-
- #include <stdio.h>
- #include <stdarg.h>
- #include <string.h>
- #include "defines.h"
- #include "cus.h"
-
- int isanyof(char c, char *cp)
- {
- while (*cp != NUL) {
- if (c == *cp)
- return TRUE;
- ++cp;
- }
- return FALSE;
- }
-
- /* Unqoute a string buffer if quoted by skipping the first char
- and replacing the last char by the null terminater. */
-
- char *strcvt(char *str)
- {
- char *ptr = str;
- int found = NO;
-
- if (*ptr == QUOTE) {
- while (*ptr != NUL) {
- if (*ptr != QUOTE)
- found = YES;
- ptr++;
- }
- if (found) {
- *(--ptr) = NUL;
- return (++str);
- }
- else return str;
- }
- else
- return str;
- }
-
-
- /* Truncate a domain extension if exists in a given ARPA address, so
- that the name of the host will be remain only. */
-
- void truncdomain(char *str)
- {
- while( (*str != '.') && (*str != NUL))
- str++;
- if (*str == '.')
- *str = NUL;
- return;
- }
-
-
- /* Split an argument string into an argument array with pointers to
- null-terminated argument strings like argv[]. */
-
- void splitarg(char **cppArgv, char *cpCmnd)
- {
- char *cp;
-
- cp = cpCmnd;
-
- for ( ; ; ) {
- *cppArgv++ = cp;
- while ( (*cp != SP) && (*cp != HT) && (*cp != NL) && (*cp != NUL) )
- cp++;
- if (*cp == NUL)
- break;
- *cp++ = NUL;
- while ( (*cp == SP) || (*cp == HT) )
- cp++;
- }
- *cppArgv = NULL;
-
- return;
- }
-
-
- int cnvbuf(char *cpBufFirst, char *cpBufLast)
- {
- char *cpRead;
- char *cpWrite;
- int rc;
-
- cpRead = cpWrite = cpBufFirst;
-
- for ( ; ; ) {
- if (cpRead > cpBufLast)
- CU(cpWrite - cpBufFirst);
- if (cpRead < cpBufLast) {
- if (*cpRead == '\\' && *(cpRead+1) == LF) {
- cpRead += 2;
- continue;
- }
- }
- *cpWrite++ = *cpRead++;
- }
-
- CUS:
- return rc;
- }
-
- #define STRBPLRC_ERR -1
-
- int strbplst(char *cpaPointers[], int pnPointersMax, char *cpStrings)
- {
- char *cpStringsCur;
- int iPointers;
- int rc;
-
- cpStringsCur = cpStrings;
- iPointers = 0;
-
- for (;;) {
- if (*cpStringsCur == NUL) {
- cpaPointers[iPointers] = NULL;
- break;
- }
- if (iPointers >= pnPointersMax)
- CU(STRBPLRC_ERR);
- cpaPointers[iPointers++] = cpStringsCur;
- while (*cpStringsCur++ != NUL);
- ;
- }
- rc = iPointers;
-
- CUS:
- return rc;
- }
-
-