|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T g
Length: 1712 (0x6b0) Types: TextFile Names: »gen.c«
└─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit └─⟦653021b30⟧ »EurOpenD3/utils/downtime.tar.Z« └─⟦946c717da⟧ └─⟦this⟧ »libgen/gen.c«
#ifndef lint static char *RCSid = "$Header: gen.c,v 1.1 88/04/12 10:34:22 mcooper Exp $"; #endif /* * $Log: gen.c,v $ * Revision 1.1 88/04/12 10:34:22 mcooper * Initial revision * */ #include <stdio.h> #include <ctype.h> char *xmalloc(), *newstr(), *argv_zero(); /* * newstr - Return new copy of "str". */ char * newstr(p) char *p; { char *s; s = (char *) xmalloc(strlen(p)+1); strcpy(s, p); return(s); } /* * upstr - Make "str" all upper case. */ upstr(str) char *str; { for (; *str; str++) if (islower(*str)) *str = toupper(*str); } /* * lowerstr - Make "str" all lower case. */ lowerstr(str) char *str; { for (; *str; str++) if (isupper(*str)) *str = tolower(*str); } /* * xmalloc - Do a malloc with error checking. */ char * xmalloc(size) int size; { char *p; if ((p = (char *) malloc(size)) == NULL) { perror("malloc"); exit(1); } return(p); } /* * istrncmp - Do a strncmp ignoring case */ istrncmp(s1, s2, len) char *s1, *s2; int len; { char p1[BUFSIZ], p2[BUFSIZ]; int s; strcpy(p1, s1); strcpy(p2, s2); lowerstr(p1); lowerstr(p2); s = strncmp(p1, p2, len); return(s); } /* * istrncmp - Do a strncmp ignoring case */ istrcmp(s1, s2) char *s1, *s2; { char p1[BUFSIZ], p2[BUFSIZ]; int s, len1, len2; strcpy(p1, s1); strcpy(p2, s2); lowerstr(p1); lowerstr(p2); len1 = strlen(p1); len2 = strlen(p2); s = strncmp(p1, p2, (len1 > len2) ? len1 : len2); return(s); } /* * argv_zero - Return the an appropriate argv[0] from "str". */ char * argv_zero(str) char *str; { char *p; p = (char *)rindex(str, '/'); if (p == NULL) { p = str; } else { *p++; } return(newstr(p)); }