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: }

Defined functions

getintrc defined in line 51; never used
getrcfile defined in line 5; used 2 times
getstringrc defined in line 71; used 3 times
rckeymatch defined in line 23; used 2 times
rcval defined in line 41; used 2 times

Defined macros

LEN defined in line 3; used 5 times
Last modified: 1983-07-21
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 662
Valid CSS Valid XHTML 1.0 Strict