|
|
1.1 ! root 1: #include <stdio.h> ! 2: ! 3: #define LEN 100 ! 4: ! 5: FILE * ! 6: getrcfile (file) ! 7: char *file; ! 8: { ! 9: char path[LEN]; ! 10: FILE *fp; ! 11: ! 12: if (*file != '/') { ! 13: strcpy (path, getenv ("HOME")); ! 14: strcat (path, "/"); ! 15: strcat (path, file); ! 16: fp = fopen (path, "r"); ! 17: } else { ! 18: fp = fopen (file, "r"); ! 19: } ! 20: return (fp); ! 21: } ! 22: ! 23: rckeymatch (line, rc) ! 24: char *line; ! 25: char *rc; ! 26: { ! 27: while (*line == ' ' || *line == '\t') ! 28: line++; ! 29: while (*rc != 0) { ! 30: if (*rc++ != *line++) ! 31: return (0); ! 32: } ! 33: while (*line == ' ' || *line == '\t') ! 34: line++; ! 35: if (*line == '=') ! 36: return (1); ! 37: else ! 38: return (0); ! 39: } ! 40: ! 41: char * ! 42: rcval (line) ! 43: char *line; ! 44: { ! 45: while (*line++ != '='); ! 46: while (*line == ' ' || *line == '\t') ! 47: line++; ! 48: return (line); ! 49: } ! 50: ! 51: getintrc(file, rc, rvptr) ! 52: char *file; ! 53: char *rc; ! 54: char *rvptr; ! 55: { ! 56: char line[LEN]; ! 57: FILE *fp; ! 58: ! 59: fp = getrcfile (file); ! 60: if (fp != NULL) { ! 61: while (fgets(line, LEN, fp) != NULL) { ! 62: if (rckeymatch (line, rc)) { ! 63: *rvptr = atoi (rcval(line)); ! 64: return (0); ! 65: } ! 66: } ! 67: } ! 68: return (-1); ! 69: } ! 70: ! 71: getstringrc(file, rc, rvptr) ! 72: char *file; ! 73: char *rc; ! 74: char *rvptr; ! 75: { ! 76: char line[LEN]; ! 77: char *p1; ! 78: FILE *fp; ! 79: ! 80: fp = getrcfile (file); ! 81: if (fp != NULL) { ! 82: while (fgets(line, LEN, fp) != NULL) { ! 83: if (rckeymatch (line, rc)) { ! 84: p1 = rcval(line); ! 85: while (*p1 != '\n' && *p1 != 0) ! 86: *rvptr++ = *p1++; ! 87: *rvptr = 0; ! 88: return (0); ! 89: } ! 90: } ! 91: } ! 92: return (-1); ! 93: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.