/* utils.c * $Id: utils.c,v 1.2.4.4 2005/08/01 12:12:02 becker Exp $ * Ralf Becker */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include "utils.h" static char cvsid[] = "$Id: utils.c,v 1.2.4.4 2005/08/01 12:12:02 becker Exp $"; /* advance to next whitespace */ char *skip(const char *p) { while(isspace(*p)) { p++; } while((*p != '\0') && !isspace(*p)) { p++; } return (char *)p; } /* advance to begining of next line */ char *skip_line(const char *p) { while((*p != '\0') && (*p != '\n')) { p++; } if (*p != '\0') { p++; } return (char *)p; } /* skip token indicated by t */ char *skip_token(const char *p, const char *t) { while ((*p == *t) && (*t != '\0') && (*p != '\0')) { p++; t++; } return (char *)p; } void (*my_signal(int sig, void (*func)(int)))(int) { struct sigaction act,oact; act.sa_handler = func; sigemptyset(&act.sa_mask); act.sa_flags = 0; if (sigaction(sig, &act, &oact) == -1) { return SIG_ERR; } return oact.sa_handler; } /* check if c is in [a-zA-Z0-9] */ int isletdig(char c) { if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || ((c >= '0') && (c <= '9'))) { return 1; } return 0; } /* check if s is a valid domainname * valid names are * ::=