Subversion Repositories SvarDOS

Rev

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

Rev 225 Rev 235
Line 6... Line 6...
6
#include <ctype.h>    /* toupper() */
6
#include <ctype.h>    /* toupper() */
7
#include <stdio.h>
7
#include <stdio.h>
8
#include <string.h>    /* strlen() */
8
#include <string.h>    /* strlen() */
9
#include <stdlib.h>    /* free() */
9
#include <stdlib.h>    /* free() */
10
#include <unistd.h>    /* rmdir(), unlink() */
10
#include <unistd.h>    /* rmdir(), unlink() */
11
 
-
 
12
#ifdef __WATCOMC__
-
 
13
#include <direct.h>  /* watcom needs this for the rmdir() prototype */
11
#include <direct.h>  /* watcom needs this for the rmdir() prototype */
14
#endif
-
 
15
 
12
 
16
#include "fileexst.h"
13
#include "fileexst.h"
17
#include "getdelim.h"
14
#include "getdelim.h"
18
#include "helpers.h"   /* slash2backslash() */
15
#include "helpers.h"   /* slash2backslash() */
19
#include "kprintf.h"
16
#include "kprintf.h"
Line 27... Line 24...
27
  char dirname[2]; /* this must be the last item in the structure */
24
  char dirname[2]; /* this must be the last item in the structure */
28
};
25
};
29
 
26
 
30
 
27
 
31
/* adds a directory to dirlist, if not already present */
28
/* adds a directory to dirlist, if not already present */
32
static struct dirliststruct *rememberdir(struct dirliststruct *dirlist, char *path) {
29
static struct dirliststruct *rememberdir(struct dirliststruct *dirlist, const char *path) {
33
  struct dirliststruct *res;
30
  struct dirliststruct *res;
34
  /* if already present, do nothing */
31
  /* if already present, do nothing */
35
  for (res = dirlist; res != NULL; res = res->next) {
32
  for (res = dirlist; res != NULL; res = res->next) {
36
    if (strcasecmp(res->dirname, path) == 0) return(dirlist);
33
    if (strcasecmp(res->dirname, path) == 0) return(dirlist);
37
  }
34
  }
Line 67... Line 64...
67
  return(dirlist);
64
  return(dirlist);
68
}
65
}
69
 
66
 
70
 
67
 
71
/* removes a package from the system. Returns 0 on success, non-zero otherwise */
68
/* removes a package from the system. Returns 0 on success, non-zero otherwise */
72
int pkgrem(char *pkgname, char *dosdir) {
69
int pkgrem(const char *pkgname, const char *dosdir) {
73
  char fpath[512];
70
  char fpath[256];
74
  char shellcmd[512];
71
  char shellcmd[256];
75
  char *lineptr;
72
  char *lineptr;
76
  FILE *flist;
73
  FILE *flist;
77
  int getdelimlen;
74
  int getdelimlen;
78
  int lastdirsep;
75
  int lastdirsep;
79
  int x;
76
  int x;
80
  size_t getdelimcount = 0;
77
  size_t getdelimcount = 0;
81
  struct dirliststruct *dirlist = NULL; /* used to remember directories to remove */
78
  struct dirliststruct *dirlist = NULL; /* used to remember directories to remove */
82
  char pkglistfile[512];
79
  char pkglistfile[256];
83
 
80
 
84
  /* Check if the file %DOSDIR%\packages\pkgname.lst exists (if not, the package is not installed) */
81
  /* Check if the file %DOSDIR%\packages\pkgname.lst exists (if not, the package is not installed) */
85
  sprintf(fpath, "%s\\packages\\%s.lst", dosdir, pkgname);
82
  sprintf(fpath, "%s\\packages\\%s.lst", dosdir, pkgname);
86
  if (fileexists(fpath) == 0) { /* file does not exist */
83
  if (fileexists(fpath) == 0) { /* file does not exist */
87
    kitten_printf(4, 0, "Package %s is not installed, so not removed.", pkgname);
84
    kitten_printf(4, 0, "Package %s is not installed, so not removed.", pkgname);