Subversion Repositories SvarDOS

Rev

Rev 1931 | Rev 1965 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1931 Rev 1963
Line 29... Line 29...
29
  struct customdirs *curpos;
29
  struct customdirs *curpos;
30
  for (; dirlist != NULL; dirlist = dirlist->next) {
30
  for (; dirlist != NULL; dirlist = dirlist->next) {
31
    for (curpos = dirlist->next; curpos != NULL; curpos = curpos->next) {
31
    for (curpos = dirlist->next; curpos != NULL; curpos = curpos->next) {
32
      if (strcasecmp(curpos->name, dirlist->name) == 0) {
32
      if (strcasecmp(curpos->name, dirlist->name) == 0) {
33
        kitten_printf(7, 0, curpos->name); /* "ERROR: custom dir '%s' is listed twice!" */
33
        kitten_printf(7, 0, curpos->name); /* "ERROR: custom dir '%s' is listed twice!" */
34
        puts("");
34
        outputnl("");
35
        return(-1);
35
        return(-1);
36
      }
36
      }
37
    }
37
    }
38
  }
38
  }
39
  return(0);
39
  return(0);
Line 44... Line 44...
44
static int validatedirlist(const struct customdirs *dirlist) {
44
static int validatedirlist(const struct customdirs *dirlist) {
45
  for (; dirlist != NULL; dirlist = dirlist->next) {
45
  for (; dirlist != NULL; dirlist = dirlist->next) {
46
    /* the location must be at least 3 characters long to be a valid absolute path (like 'c:\')*/
46
    /* the location must be at least 3 characters long to be a valid absolute path (like 'c:\')*/
47
    if (strlen(dirlist->location) < 3) {
47
    if (strlen(dirlist->location) < 3) {
48
      kitten_printf(7, 15, dirlist->name); /* "ERROR: custom dir '%s' is not a valid absolute path!" */
48
      kitten_printf(7, 15, dirlist->name); /* "ERROR: custom dir '%s' is not a valid absolute path!" */
49
      puts("");
49
      outputnl("");
50
      return(-1);
50
      return(-1);
51
    }
51
    }
52
    /* is it a valid absolute path? should start with [a..Z]:\ */
52
    /* is it a valid absolute path? should start with [a..Z]:\ */
53
    if ((dirlist->location[1] != ':') ||
53
    if ((dirlist->location[1] != ':') ||
54
       ((dirlist->location[2] != '/') && (dirlist->location[2] != '\\')) ||
54
       ((dirlist->location[2] != '/') && (dirlist->location[2] != '\\')) ||
55
       (((dirlist->location[0] < 'a') || (dirlist->location[0] > 'z')) && ((dirlist->location[0] < 'A') || (dirlist->location[0] > 'Z')))) {
55
       (((dirlist->location[0] < 'a') || (dirlist->location[0] > 'z')) && ((dirlist->location[0] < 'A') || (dirlist->location[0] > 'Z')))) {
56
      kitten_printf(7, 15, dirlist->name); /* "ERROR: custom dir '%s' is not a valid absolute path!" */
56
      kitten_printf(7, 15, dirlist->name); /* "ERROR: custom dir '%s' is not a valid absolute path!" */
57
      puts("");
57
      outputnl("");
58
      return(-1);
58
      return(-1);
59
    }
59
    }
60
    /* check for forbidden names */
60
    /* check for forbidden names */
61
    if ((strcasecmp(dirlist->name, "appinfo") == 0) ||
61
    if ((strcasecmp(dirlist->name, "appinfo") == 0) ||
62
        (strcasecmp(dirlist->name, "doc") == 0) ||
62
        (strcasecmp(dirlist->name, "doc") == 0) ||
63
        (strcasecmp(dirlist->name, "help") == 0) ||
63
        (strcasecmp(dirlist->name, "help") == 0) ||
64
        (strcasecmp(dirlist->name, "nls") == 0) ||
64
        (strcasecmp(dirlist->name, "nls") == 0) ||
65
        (strcasecmp(dirlist->name, "packages") == 0)) {
65
        (strcasecmp(dirlist->name, "packages") == 0)) {
66
      kitten_printf(7, 16, dirlist->name); /* "ERROR: custom dir '%s' is a reserved name!" */
66
      kitten_printf(7, 16, dirlist->name); /* "ERROR: custom dir '%s' is a reserved name!" */
67
      puts("");
67
      outputnl("");
68
      return(-1);
68
      return(-1);
69
    }
69
    }
70
  }
70
  }
71
  return(0);
71
  return(0);
72
}
72
}
Line 103... Line 103...
103
    fd = fopen(token, "r");
103
    fd = fopen(token, "r");
104
    if (fd == NULL) {
104
    if (fd == NULL) {
105
      kitten_printf(7, 1, "%DOSDIR%\\PKG.CFG"); /* "ERROR: Could not open config file (%s)!" */
105
      kitten_printf(7, 1, "%DOSDIR%\\PKG.CFG"); /* "ERROR: Could not open config file (%s)!" */
106
    } else {
106
    } else {
107
      kitten_printf(7, 17, token);  /* "ERROR: PKG.CFG found at %s */
107
      kitten_printf(7, 17, token);  /* "ERROR: PKG.CFG found at %s */
108
      puts("");
108
      outputnl("");
109
      puts(svarlang_str(7, 18));    /* Please move it to %DOSDIR%\PKG.CFG */
109
      outputnl(svarlang_str(7, 18));    /* Please move it to %DOSDIR%\PKG.CFG */
110
    }
110
    }
111
    puts("");
111
    outputnl("");
112
    return(-1);
112
    return(-1);
113
  }
113
  }
114
 
114
 
115
  *dirlist = NULL;
115
  *dirlist = NULL;
116
  *bootdrive = 'C'; /* default */
116
  *bootdrive = 'C'; /* default */
Line 122... Line 122...
122
    /* skip comments and empty lines */
122
    /* skip comments and empty lines */
123
    if ((token[0] == '#') || (token[0] == 0)) continue;
123
    if ((token[0] == '#') || (token[0] == 0)) continue;
124
 
124
 
125
    if ((value == NULL) || (value[0] == 0)) {
125
    if ((value == NULL) || (value[0] == 0)) {
126
      kitten_printf(7, 4, nline); /* "Warning: token with empty value on line #%d" */
126
      kitten_printf(7, 4, nline); /* "Warning: token with empty value on line #%d" */
127
      puts(PKG_CFG);
127
      outputnl(PKG_CFG);
128
      continue;
128
      continue;
129
    }
129
    }
130
 
130
 
131
    /* printf("token='%s' ; value = '%s'\n", token, value); */
131
    /* printf("token='%s' ; value = '%s'\n", token, value); */
132
    if (strcasecmp(token, "DIR") == 0) { /* custom directory entry */
132
    if (strcasecmp(token, "DIR") == 0) { /* custom directory entry */
Line 134... Line 134...
134
      int i;
134
      int i;
135
      /* find nearer space */
135
      /* find nearer space */
136
      for (i = 0; (value[i] != ' ') && (value[i] != 0); i++);
136
      for (i = 0; (value[i] != ' ') && (value[i] != 0); i++);
137
      if (value[i] == 0) {
137
      if (value[i] == 0) {
138
        kitten_printf(7, 11, nline); /* "Warning: Invalid 'DIR' directive found at line #%d" */
138
        kitten_printf(7, 11, nline); /* "Warning: Invalid 'DIR' directive found at line #%d" */
139
        puts(PKG_CFG);
139
        outputnl(PKG_CFG);
140
        continue;
140
        continue;
141
      }
141
      }
142
      value[i] = 0;
142
      value[i] = 0;
143
      location = value + i + 1;
143
      location = value + i + 1;
144
 
144
 
Line 146... Line 146...
146
      slash2backslash(location);
146
      slash2backslash(location);
147
      removeDoubleBackslashes(location);
147
      removeDoubleBackslashes(location);
148
      if (location[strlen(location) - 1] != '\\') strcat(location, "\\"); /* make sure to end dirs with a backslash */
148
      if (location[strlen(location) - 1] != '\\') strcat(location, "\\"); /* make sure to end dirs with a backslash */
149
      if (addnewdir(dirlist, value, location) != 0) {
149
      if (addnewdir(dirlist, value, location) != 0) {
150
        kitten_printf(2, 14, "addnewdir"); /* "Out of memory! (%s)" */
150
        kitten_printf(2, 14, "addnewdir"); /* "Out of memory! (%s)" */
151
        puts("");
151
        outputnl("");
152
        freeconf(dirlist);
152
        freeconf(dirlist);
153
        fclose(fd);
153
        fclose(fd);
154
        return(-1);
154
        return(-1);
155
      }
155
      }
156
    } else if (strcasecmp(token, "BOOTDRIVE") == 0) { /* boot drive (used for kernel and command.com installation */
156
    } else if (strcasecmp(token, "BOOTDRIVE") == 0) { /* boot drive (used for kernel and command.com installation */
157
      *bootdrive = value[0];
157
      *bootdrive = value[0];
158
      *bootdrive &= 0xDF; /* upcase it */
158
      *bootdrive &= 0xDF; /* upcase it */
159
      if ((*bootdrive < 'A') || (*bootdrive > 'Z')) {
159
      if ((*bootdrive < 'A') || (*bootdrive > 'Z')) {
160
        kitten_printf(7, 5, nline); /* Warning: Invalid bootdrive at line #%d */
160
        kitten_printf(7, 5, nline); /* Warning: Invalid bootdrive at line #%d */
161
        puts(PKG_CFG);
161
        outputnl(PKG_CFG);
162
        *bootdrive = 'C';
162
        *bootdrive = 'C';
163
      }
163
      }
164
    } else { /* unknown token */
164
    } else { /* unknown token */
165
      kitten_printf(7, 8, token, nline); /* "Warning: Unknown token '%s' at line #%d" */
165
      kitten_printf(7, 8, token, nline); /* "Warning: Unknown token '%s' at line #%d" */
166
      puts("");
166
      outputnl("");
167
    }
167
    }
168
  }
168
  }
169
  fclose(fd);
169
  fclose(fd);
170
 
170
 
171
  /* perform some validations */
171
  /* perform some validations */