Subversion Repositories SvarDOS

Rev

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

Rev 185 Rev 186
Line 33... Line 33...
33
 
33
 
34
#define pVer "2021-01-13"
34
#define pVer "2021-01-13"
35
 
35
 
36
 
36
 
37
/* computes the BSD sum of a file and returns it. returns 0 on error. */
37
/* computes the BSD sum of a file and returns it. returns 0 on error. */
38
static uint16_t file2bsum(char *filename) {
38
static uint16_t file2bsum(const char *filename) {
39
  uint16_t result = 0;
39
  uint16_t result = 0;
40
  unsigned char buff[1024 * 1024];
40
  unsigned char buff[1024 * 1024];
41
  size_t i, buffread;
41
  size_t i, buffread;
42
  FILE *fd;
42
  FILE *fd;
43
  fd = fopen(filename, "rb");
43
  fd = fopen(filename, "rb");
Line 97... Line 97...
97
    }
97
    }
98
    if (linelen < maxlen) line[linelen++] = bytebuff;
98
    if (linelen < maxlen) line[linelen++] = bytebuff;
99
  }
99
  }
100
}
100
}
101
 
101
 
102
static int readlsm(char *filename, char *version, char *title, char *description) {
102
static int readlsm(const char *filename, char *version, char *title, char *description) {
103
  char linebuff[1024];
103
  char linebuff[1024];
104
  char *valuestr;
104
  char *valuestr;
105
  int x;
105
  int x;
106
  FILE *fd;
106
  FILE *fd;
107
  /* reset fields to be read to empty values */
107
  /* reset fields to be read to empty values */
Line 149... Line 149...
149
       to char", hence the following cast plus dereference */
149
       to char", hence the following cast plus dereference */
150
   return(strcasecmp(* (char * const *) p1, * (char * const *) p2));
150
   return(strcasecmp(* (char * const *) p1, * (char * const *) p2));
151
}
151
}
152
 
152
 
153
 
153
 
154
static void GenIndexes(char *repodir) {
154
static void GenIndexes(const char *repodir) {
155
  char *LsmFileList[4096];
155
  char *LsmFileList[4096];
156
  char tmpbuf[64];
156
  char tmpbuf[64];
157
  char *LsmFile, LSMpackage[64], LSMtitle[128], LSMversion[128], LSMdescription[1024];
157
  char *LsmFile, LSMpackage[64], LSMtitle[128], LSMversion[128], LSMdescription[1024];
158
  int LsmCount = 0, x;
158
  int LsmCount = 0, x;
159
  FILE *idx;
159
  FILE *idx;
Line 213... Line 213...
213
 
213
 
214
 
214
 
215
 
215
 
216
int main(int argc, char **argv) {
216
int main(int argc, char **argv) {
217
  char *repodir;
217
  char *repodir;
218
  char cmdbuff[1024];
218
  char cmdbuff[256];
219
 
219
 
220
  puts("FDNPKG server repository generator version " pVer);
220
  puts("SvarDOS repository index generator ver " pVer);
221
 
221
 
222
  if (argc != 2) {
222
  if (argc != 2) {
223
    puts("Usage: buildidx repodir");
223
    puts("Usage: buildidx repodir");
224
    return(1);
224
    return(1);
225
  }
225
  }
Line 236... Line 236...
236
 
236
 
237
  system("rm -rf appinfo");
237
  system("rm -rf appinfo");
238
  system("mkdir appinfo");
238
  system("mkdir appinfo");
239
 
239
 
240
  puts("Populating appinfo with LSM files from archives...");
240
  puts("Populating appinfo with LSM files from archives...");
241
  sprintf(cmdbuff, "unzip -C -j -L -o '%s/*.zip' 'appinfo/*.lsm' -d appinfo", repodir);
241
  snprintf(cmdbuff, sizeof(cmdbuff), "unzip -C -j -L -o '%s/*.zip' 'appinfo/*.lsm' -d appinfo", repodir);
242
  system(cmdbuff);
242
  system(cmdbuff);
243
 
243
 
244
  puts("Generating the index file...");
244
  puts("Generating the index file...");
245
  GenIndexes(repodir);
245
  GenIndexes(repodir);
246
 
246