Subversion Repositories SvarDOS

Compare Revisions

No changes between revisions

Ignore whitespace Rev 712 → Rev 711

/pkgnet/trunk/svarlang.lib
File deleted
\ No newline at end of file
Property changes:
Deleted: svn:special
-*
\ No newline at end of property
/pkgnet/trunk/nls/pl_utf8.txt
File deleted
/pkgnet/trunk/nls/en_utf8.txt
File deleted
/pkgnet/trunk/Makefile
3,7 → 3,7
#
 
CFLAGS = -j -ml -0 -bt=dos -wx -we -d0 -ox -dNOLFN -i=watt32\inc
LIB = watt32\lib\wattcpwl.lib svarlang.lib\svarlngl.lib
LIB = watt32\lib\wattcpwl.lib
 
all: pkgnet.exe
 
10,28 → 10,15
release: pkgnet.exe .symbolic
mkdir bin
mkdir appinfo
mkdir nls
copy pkgnet.exe bin
copy pkgnet.lsm appinfo
copy pkgnet.lng nls
if exist pkgnet.svp del pkgnet.svp
zip -9krDX -m pkgnet.svp bin appinfo nls
zip -9krDX -m pkgnet.svp bin appinfo
rmdir bin
rmdir appinfo
rmdir nls
if exist pkgnet.zip del pkgnet.zip
zip -9krDX pkgnet.zip Makefile *.c *.h pkgnet.lsm watt32 svarlang.lib
zip -9krDX pkgnet.zip Makefile *.c *.h pkgnet.lsm watt32
 
pkgnet.exe: pkgnet.obj net.obj unchunk.obj lsm.obj helpers.obj trim.obj
cd nls
utf8tocp 437 en_utf8.txt > en.txt
utf8tocp maz pl_utf8.txt > pl.txt
..\svarlang.lib\tlumacz en pl
del ??.txt
move /y deflang.c ..\deflang.c
move /y out.lng ..\pkgnet.lng
cd ..
*wcl -lr -k4096 $(LIB) pkgnet.obj deflang.c net.obj unchunk.obj lsm.obj helpers.obj trim.obj -fe=pkgnet.exe
wcl -lr -k4096 $(LIB) pkgnet.obj net.obj unchunk.obj lsm.obj helpers.obj trim.obj -fe=pkgnet.exe
 
pkgnet.obj: pkgnet.c
*wcc $(CFLAGS) pkgnet.c
/pkgnet/trunk/pkgnet.c
23,7 → 23,7
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* http://svardos.org
* http://svardos.osdn.io
*/
 
#include <direct.h> /* opendir() and friends */
35,21 → 35,15
#include "net.h"
#include "unchunk.h"
 
#include "svarlang.lib\svarlang.h"
 
#include "../../pkg/trunk/lsm.h"
 
 
#define PVER "20220215"
#define PVER "20220214"
#define PDATE "2021-2022"
 
#define HOSTADDR "svardos.org"
 
 
/* convenience define that outputs nls strings to screen (followed by CR/LF) */
#define putsnls(x,y) puts(svarlang_strid((x << 8) | y))
 
 
/* returns length of all http headers, or 0 if uncomplete yet */
static unsigned short detecthttpheadersend(const unsigned char *buff) {
char lastbyteislf = 0;
75,21 → 69,21
static void help(void) {
puts("pkgnet ver " PVER " -- Copyright (C) " PDATE " Mateusz Viste");
puts("");
putsnls(1, 0); /* "pkgnet is the SvarDOS package downloader" */
puts("pkgnet is the SvarDOS package downloader.");
puts("");
putsnls(1, 1); /* "usage: pkgnet search <term>" */
putsnls(1, 2); /* " pkgnet pull <package>" */
putsnls(1, 3); /* " pkgnet pull <package>-<version>" */
putsnls(1, 6); /* " pkgnet checkup" */
puts("usage: pkgnet search <term>");
puts(" pkgnet pull <package>");
puts(" pkgnet pull <package>-<version>");
puts(" pkgnet checkup");
puts("");
putsnls(1, 7); /* "actions:" */
puts("actions:");
puts(" search - asks remote repository for the list of matching packages");
puts(" pull - downloads package into current directory");
puts(" checkup - lists updates available for your system");
puts("");
putsnls(1, 8); /* "search - asks remote repository for the list of matching packages" */
putsnls(1, 9); /* "pull - downloads package into current directory" */
putsnls(1, 10); /* "checkup - lists updates available for your system" */
puts("");
printf("Watt32 kernel: %s", net_engine());
puts("");
puts("");
}
 
 
192,7 → 186,7
if (dosdir == NULL) {
dosdir = getenv("DOSDIR");
if ((dosdir == NULL) || (dosdir[0] == 0)) {
putsnls(9, 0); /* "ERROR: %DOSDIR% not set" */
puts("ERROR: %DOSDIR% not set");
return(0);
}
}
202,7 → 196,7
sprintf(buff, "%s\\packages", dosdir);
dp = opendir(buff);
if (dp == NULL) {
putsnls(9, 1); /* "ERROR: Could not access %DOSDIR%\\packages directory" */
puts("ERROR: Could not access %DOSDIR%\\packages directory");
return(0);
}
}
252,8 → 246,7
 
sock = net_connect(ipaddr, 80);
if (sock == NULL) {
printf(svarlang_strid(0x0902), HOSTADDR); /* "ERROR: failed to connect to " HOSTADDR */
puts("");
puts("ERROR: failed to connect to " HOSTADDR);
goto SHITQUIT;
}
 
262,8 → 255,7
int connstate = net_isconnected(sock);
if (connstate > 0) break;
if (connstate < 0) {
printf(svarlang_strid(0x0902), HOSTADDR); /* "ERROR: failed to connect to " HOSTADDR */
puts("");
puts("ERROR: connection error");
goto SHITQUIT;
}
_asm int 28h; /* DOS idle */
277,7 → 269,7
}
 
if (net_send(sock, buffer, strlen((char *)buffer)) != (int)strlen((char *)buffer)) {
putsnls(9, 3); /* "ERROR: failed to send a HTTP query to remote server" */
puts("ERROR: failed to send HTTP query to remote server");
goto SHITQUIT;
}
 
294,7 → 286,7
hlen = sprintf(hbuf, "%X\r\n", blen);
}
if (net_send(sock, hbuf, hlen) != hlen) {
putsnls(9, 4); /* "ERROR: failed to send POST data to remote server" */
puts("ERROR: failed to send POST data to remote server");
goto SHITQUIT;
}
/* add trailing CR/LF to buffer as required by chunked mode */
301,7 → 293,7
buffer[blen++] = '\r';
buffer[blen++] = '\n';
if (net_send(sock, buffer, blen) != blen) {
putsnls(9, 4); /* "ERROR: failed to send POST data to remote server" */
puts("ERROR: failed to send POST data to remote server");
goto SHITQUIT;
}
} while (blen != 2);
312,7 → 304,7
 
/* transmission error? */
if (byteread < 0) {
printf(svarlang_strid(0x0905), byteread); /* "ERROR: TCP communication error #%d" */
printf("ERROR: communication error (%d)", byteread);
puts("");
goto SHITQUIT;
}
321,7 → 313,7
if ((httpcode >= 200) && (httpcode <= 299) && (*outfname != 0)) {
fd = fopen(outfname, "wb");
if (fd == NULL) {
printf(svarlang_strid(0x0906), outfname); /* "ERROR: failed to create file %s" */
printf("ERROR: failed to create file %s", outfname);
puts("");
goto SHITQUIT;
}
341,7 → 333,7
if (fd != NULL) {
int i;
if (fwrite(buffer, 1, byteread, fd) != byteread) {
printf(svarlang_strid(0x0907), outfname, flen); /* "ERROR: failed to write data to file %s after %ld bytes" */
printf("ERROR: failed to write data to file %s after %ld bytes", outfname, flen);
puts("");
break;
}
371,7 → 363,7
 
} else { /* check for timeout (byteread == 0) */
if (time(NULL) - lastactivity > 20) { /* TIMEOUT! */
putsnls(9, 8); /* "ERROR: Timeout while waiting for data" */
puts("ERROR: Timeout while waiting for data");
goto SHITQUIT;
}
/* waiting for packets - release a CPU cycle in the meantime */
412,12 → 404,10
char outfname[16];
} *mem;
 
svarlang_autoload("PKGNET");
 
/* allocate memory */
mem = malloc(sizeof(*mem));
if (mem == NULL) {
putsnls(9, 9); /* "ERROR: out of memory" */
puts("ERROR: out of memory");
return(1);
}
 
426,7 → 416,7
 
/* if outfname requested, make sure that file does not exist yet */
if ((mem->outfname[0] != 0) && (fexists(mem->outfname))) {
printf(svarlang_strid(0x090A), mem->outfname); /* "ERROR: file %s already exists" */
printf("ERROR: file %s already exists", mem->outfname);
puts("");
return(1);
}
433,7 → 423,7
 
/* init network stack */
if (net_init() != 0) {
putsnls(9, 11); /* "ERROR: Network subsystem initialization failed" */
puts("ERROR: Network subsystem initialization failed");
return(1);
}
 
440,7 → 430,7
puts(""); /* required because watt-32 likes to print out garbage sometimes ("configuring through DHCP...") */
 
if (net_dnsresolve(mem->ipaddr, HOSTADDR) != 0) {
putsnls(9, 12); /* "ERROR: DNS resolution failed" */
puts("ERROR: DNS resolution failed");
return(1);
}
 
449,7 → 439,7
 
if (mem->outfname[0] != 0) {
/* print bsum, size, filename */
printf(svarlang_strid(0x0200), flen >> 10, mem->outfname, bsum); /* Downloaded %ld KiB into %s (BSUM: %04X) */
printf("Downloaded %ld KiB into %s (BSUM: %04X)", flen >> 10, mem->outfname, bsum);
puts("");
}
 
/pkgnet/trunk/pkgnet.lsm
1,3 → 1,3
version: 20220215
description: pulls packages and updates from the online SvarDOS repository
version: 20220214
description: pulls packages and updates from the internet SvarDOS repository
license: MIT