Subversion Repositories SvarDOS

Rev

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

Rev 260 Rev 261
Line 79... Line 79...
79
  }
79
  }
80
}
80
}
81
 
81
 
82
 
82
 
83
static int pkginst(const char *file, int flags, const char *dosdir, const struct customdirs *dirlist) {
83
static int pkginst(const char *file, int flags, const char *dosdir, const struct customdirs *dirlist) {
84
  char pkgname[32];
84
  char pkgname[9];
85
  int t, lastpathdelim = -1, u = 0;
85
  int t, lastpathdelim = -1, lastdot = -1;
86
  struct ziplist *zipfileidx;
86
  struct ziplist *zipfileidx;
87
  FILE *zipfilefd;
87
  FILE *zipfilefd;
-
 
88
  /* copy the filename into pkgname (without path elements and without extension) */
88
  for (t = 0; file[t] != 0; t++) {
89
  for (t = 0; file[t] != 0; t++) {
89
    if ((file[t] == '/') || (file[t] == '\\')) lastpathdelim = t;
90
    switch (file[t]) {
90
  }
91
      case '/':
91
  /* copy the filename into pkgname (without path elements) */
-
 
92
  for (t = lastpathdelim + 1; file[t] != 0; t++) pkgname[u++] = file[t];
-
 
93
  pkgname[u] = 0; /* terminate the string */
92
      case '\\':
94
  /* truncate the file's extension (.zip) */
93
        lastpathdelim = t;
95
  for (t = u; t > 0; t--) {
94
        break;
96
    if (pkgname[t] == '.') {
95
      case '.':
97
      pkgname[t] = 0;
96
        lastdot = t;
98
      break;
97
        break;
99
    }
98
    }
100
  }
99
  }
-
 
100
  if (lastdot < lastpathdelim) lastdot = t; /* a dot before last path delimiters is not an extension prefix */
-
 
101
  t = lastdot - (lastpathdelim + 1);
-
 
102
  if (t + 1 > sizeof(pkgname)) {
-
 
103
    kitten_puts(3, 24, "ERROR: package name too long");
-
 
104
    return(1);
-
 
105
  }
-
 
106
  memcpy(pkgname, file + lastpathdelim + 1, t);
-
 
107
  pkgname[t] = 0;
101
  /* prepare the zip file and install it */
108
  /* prepare the zip file and install it */
102
  zipfileidx = pkginstall_preparepackage(pkgname, file, flags, &zipfilefd, dosdir, dirlist);
109
  zipfileidx = pkginstall_preparepackage(pkgname, file, flags, &zipfilefd, dosdir, dirlist);
103
  if (zipfileidx != NULL) {
110
  if (zipfileidx != NULL) {
104
    int res = 0;
-
 
105
    if (pkginstall_installpackage(pkgname, dosdir, dirlist, zipfileidx, zipfilefd) != 0) res = 1;
111
    t = pkginstall_installpackage(pkgname, dosdir, dirlist, zipfileidx, zipfilefd);
106
    fclose(zipfilefd);
112
    fclose(zipfilefd);
107
    return(res);
-
 
108
  } else {
-
 
109
    fclose(zipfilefd);
-
 
110
    return(1);
113
    return(t);
111
  }
114
  }
-
 
115
 
-
 
116
  fclose(zipfilefd);
-
 
117
  return(1);
112
}
118
}
113
 
119
 
114
 
120
 
115
int main(int argc, char **argv) {
121
int main(int argc, char **argv) {
116
  int res = 1;
122
  int res = 1;