Subversion Repositories SvarDOS

Rev

Rev 269 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 269 Rev 272
Line 27... Line 27...
27
static int checkfordoubledirlist(const struct customdirs *dirlist) {
27
static int checkfordoubledirlist(const struct customdirs *dirlist) {
28
  struct customdirs *curpos;
28
  struct customdirs *curpos;
29
  for (; dirlist != NULL; dirlist = dirlist->next) {
29
  for (; dirlist != NULL; dirlist = dirlist->next) {
30
    for (curpos = dirlist->next; curpos != NULL; curpos = curpos->next) {
30
    for (curpos = dirlist->next; curpos != NULL; curpos = curpos->next) {
31
      if (strcasecmp(curpos->name, dirlist->name) == 0) {
31
      if (strcasecmp(curpos->name, dirlist->name) == 0) {
32
        kitten_printf(7, 0, "Error: custom dir '%s' is listed twice!", curpos->name);
32
        kitten_printf(7, 0, "ERROR: custom dir '%s' is listed twice!", curpos->name);
33
        puts("");
33
        puts("");
34
        return(-1);
34
        return(-1);
35
      }
35
      }
36
    }
36
    }
37
  }
37
  }
Line 42... Line 42...
42
/* validates dirlist entries: check that they are absolute paths and are not using restricted names */
42
/* validates dirlist entries: check that they are absolute paths and are not using restricted names */
43
static int validatedirlist(const struct customdirs *dirlist) {
43
static int validatedirlist(const struct customdirs *dirlist) {
44
  for (; dirlist != NULL; dirlist = dirlist->next) {
44
  for (; dirlist != NULL; dirlist = dirlist->next) {
45
    /* the location must be at least 3 characters long to be a valid absolute path (like 'c:\')*/
45
    /* the location must be at least 3 characters long to be a valid absolute path (like 'c:\')*/
46
    if (strlen(dirlist->location) < 3) {
46
    if (strlen(dirlist->location) < 3) {
47
      kitten_printf(7, 15, "Error: custom dir '%s' is not a valid absolute path!", dirlist->name);
47
      kitten_printf(7, 15, "ERROR: custom dir '%s' is not a valid absolute path!", dirlist->name);
48
      puts("");
48
      puts("");
49
      return(-1);
49
      return(-1);
50
    }
50
    }
51
    /* is it a valid absolute path? should start with [a..Z]:\ */
51
    /* is it a valid absolute path? should start with [a..Z]:\ */
52
    if ((dirlist->location[1] != ':') ||
52
    if ((dirlist->location[1] != ':') ||
53
       ((dirlist->location[2] != '/') && (dirlist->location[2] != '\\')) ||
53
       ((dirlist->location[2] != '/') && (dirlist->location[2] != '\\')) ||
54
       (((dirlist->location[0] < 'a') || (dirlist->location[0] > 'z')) && ((dirlist->location[0] < 'A') || (dirlist->location[0] > 'Z')))) {
54
       (((dirlist->location[0] < 'a') || (dirlist->location[0] > 'z')) && ((dirlist->location[0] < 'A') || (dirlist->location[0] > 'Z')))) {
55
      kitten_printf(7, 15, "Error: custom dir '%s' is not a valid absolute path!", dirlist->name);
55
      kitten_printf(7, 15, "ERROR: custom dir '%s' is not a valid absolute path!", dirlist->name);
56
      puts("");
56
      puts("");
57
      return(-1);
57
      return(-1);
58
    }
58
    }
59
    /* check for forbidden names */
59
    /* check for forbidden names */
60
    if ((strcasecmp(dirlist->name, "appinfo") == 0) ||
60
    if ((strcasecmp(dirlist->name, "appinfo") == 0) ||
61
        (strcasecmp(dirlist->name, "bin") == 0) ||
61
        (strcasecmp(dirlist->name, "bin") == 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, "Error: custom dir '%s' is a reserved name!", dirlist->name);
66
      kitten_printf(7, 16, "ERROR: custom dir '%s' is a reserved name!", dirlist->name);
67
      puts("");
67
      puts("");
68
      return(-1);
68
      return(-1);
69
    }
69
    }
70
  }
70
  }
71
  return(0);
71
  return(0);
Line 94... Line 94...
94
  int nline = 0;
94
  int nline = 0;
95
 
95
 
96
  snprintf(token, sizeof(token), "%s\\cfg\\pkg.cfg", dosdir);
96
  snprintf(token, sizeof(token), "%s\\cfg\\pkg.cfg", dosdir);
97
  fd = fopen(token, "r");
97
  fd = fopen(token, "r");
98
  if (fd == NULL) {
98
  if (fd == NULL) {
99
    kitten_printf(7, 1, "Error: Could not open config file (%s)!", token);
99
    kitten_printf(7, 1, "ERROR: Could not open config file (%s)!", token);
100
    puts("");
100
    puts("");
101
    return(-1);
101
    return(-1);
102
  }
102
  }
103
 
103
 
104
  *dirlist = NULL;
104
  *dirlist = NULL;