Subversion Repositories SvarDOS

Rev

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

Rev 348 Rev 558
Line 1... Line 1...
1
/*
1
/*
2
 * pkgnet - pulls SvarDOS packages from the project's online repository
2
 * pkgnet - pulls SvarDOS packages from the project's online repository
3
 * Copyright (C) 2021 Mateusz Viste
-
 
4
 *
3
 *
5
 * PUBLISHED UNDER THE TERMS OF THE MIT LICENSE
4
 * PUBLISHED UNDER THE TERMS OF THE MIT LICENSE
6
 *
5
 *
7
 * COPYRIGHT (C) 2016-2021 MATEUSZ VISTE, ALL RIGHTS RESERVED.
6
 * COPYRIGHT (C) 2016-2022 MATEUSZ VISTE, ALL RIGHTS RESERVED.
8
 *
7
 *
9
 * Permission is hereby granted, free of charge, to any person obtaining a
8
 * Permission is hereby granted, free of charge, to any person obtaining a
10
 * copy of this software and associated documentation files (the "Software"),
9
 * copy of this software and associated documentation files (the "Software"),
11
 * to deal in the Software without restriction, including without limitation
10
 * to deal in the Software without restriction, including without limitation
12
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
Line 37... Line 36...
37
#include "unchunk.h"
36
#include "unchunk.h"
38
 
37
 
39
#include "../pkg/lsm.h"
38
#include "../pkg/lsm.h"
40
 
39
 
41
 
40
 
42
#define PVER "20210906"
41
#define PVER "20220119"
43
#define PDATE "2021"
42
#define PDATE "2021-2022"
44
 
43
 
45
#define HOSTADDR "svardos.osdn.io"
44
#define HOSTADDR "svardos.osdn.io"
46
 
45
 
47
 
46
 
48
/* returns length of all http headers, or 0 if uncomplete yet */
47
/* returns length of all http headers, or 0 if uncomplete yet */
Line 72... Line 71...
72
  puts("");
71
  puts("");
73
  puts("pkgnet is the SvarDOS package downloader.");
72
  puts("pkgnet is the SvarDOS package downloader.");
74
  puts("");
73
  puts("");
75
  puts("usage:  pkgnet search <term>");
74
  puts("usage:  pkgnet search <term>");
76
  puts("        pkgnet pull <package>");
75
  puts("        pkgnet pull <package>");
-
 
76
  puts("        pkgnet pull <package>-<version>");
77
  puts("        pkgnet checkup");
77
  puts("        pkgnet checkup");
78
  puts("");
78
  puts("");
79
  puts("actions:");
79
  puts("actions:");
80
  puts(" search   - asks remote repository for the list of matching packages");
80
  puts(" search   - asks remote repository for the list of matching packages");
81
  puts(" pull     - downloads package into current directory");
81
  puts(" pull     - downloads package into current directory");
Line 94... Line 94...
94
  *url = 0;
94
  *url = 0;
95
  *ispost = 0;
95
  *ispost = 0;
96
  if ((argc == 3) && (strcasecmp(argv[1], "search") == 0)) {
96
  if ((argc == 3) && (strcasecmp(argv[1], "search") == 0)) {
97
    sprintf(url, "/repo/?a=search&p=%s", argv[2]);
97
    sprintf(url, "/repo/?a=search&p=%s", argv[2]);
98
  } else if ((argc == 3) && (strcasecmp(argv[1], "pull") == 0)) {
98
  } else if ((argc == 3) && (strcasecmp(argv[1], "pull") == 0)) {
99
    if ((strlen(argv[2]) > 8) || (argv[2][0] == 0)) {
-
 
100
      puts("ERROR: package name must be 8 characters maximum");
-
 
101
      return(-1);
99
    unsigned short i;
102
    }
-
 
103
    sprintf(url, "/repo/?a=pull&p=%s", argv[2]);
100
    sprintf(url, "/repo/?a=pull&p=%s", argv[2]);
-
 
101
    /* copy argv[2] into outfname, but stop at first '-' or null terminator
-
 
102
     * this trims any '-version' part in filename to respect 8+3 */
-
 
103
    for (i = 0; (argv[2][i] != 0) && (argv[2][i] != '-') && (i < 8); i++) {
-
 
104
      outfname[i] = argv[2][i];
-
 
105
    }
-
 
106
    /* add the zip extension to filename */
104
    sprintf(outfname, "%s.zip", argv[2]);
107
    strcpy(outfname + i, ".zip");
105
  } else if ((argc == 2) && (strcasecmp(argv[1], "checkup") == 0)) {
108
  } else if ((argc == 2) && (strcasecmp(argv[1], "checkup") == 0)) {
106
    sprintf(url, "/repo/?a=checkup");
109
    sprintf(url, "/repo/?a=checkup");
107
    *ispost = 1;
110
    *ispost = 1;
108
  } else {
111
  } else {
109
    help();
112
    help();