Tools for working with Cidco Mailstations
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

sendload: add -r flag for sending raw files without size header

+30 -9
+30 -9
util/sendload.c
··· 8 8 */ 9 9 10 10 #include <stdio.h> 11 + #include <stdlib.h> 11 12 #include <string.h> 12 13 #include <signal.h> 13 14 #include <err.h> ··· 28 29 _exit(1); 29 30 } 30 31 32 + void 33 + usage(void) 34 + { 35 + printf("usage: %s [-r] <file to send>\n", getprogname()); 36 + exit(1); 37 + } 38 + 31 39 int 32 40 main(int argc, char *argv[]) 33 41 { 34 42 FILE *pFile; 35 43 struct stat sb; 36 - unsigned int sent = 0, size = 0; 44 + unsigned int sent = 0, size = 0, raw = 0; 45 + int ch; 37 46 char *fn; 38 47 39 - if (argc != 2) { 40 - printf("usage: %s <binary file to send>\n", argv[0]); 41 - return 1; 48 + while ((ch = getopt(argc, argv, "r")) != -1) { 49 + switch (ch) { 50 + case 'r': 51 + raw = 1; 52 + break; 53 + default: 54 + usage(); 55 + } 42 56 } 57 + argc -= optind; 58 + argv += optind; 59 + 60 + if (argc != 1) 61 + usage(); 43 62 44 63 if (geteuid() != 0) 45 64 errx(1, "must be run as root"); ··· 54 73 #endif 55 74 #endif 56 75 57 - fn = argv[1]; 76 + fn = argv[0]; 58 77 pFile = fopen(fn, "rb"); 59 78 if (!pFile) 60 79 err(1, "open: %s", fn); ··· 71 90 fflush(stdout); 72 91 73 92 /* loader expects two bytes, the low and then high of the file size */ 74 - alarm(10); 75 - sendbyte(size & 0xff); 76 - sendbyte((size >> 8) & 0xff); 93 + if (!raw) { 94 + alarm(10); 95 + sendbyte(size & 0xff); 96 + sendbyte((size >> 8) & 0xff); 97 + } 77 98 78 99 while (sent < size) { 79 100 alarm(1); ··· 82 103 if (sent++ == 0) 83 104 printf("\n"); 84 105 85 - if (sent % 1024 == 0 || sent == size) { 106 + if (sent % (raw ? 64 : 1024) == 0 || sent == size) { 86 107 printf("\rsent: %07d/%07d", sent, size); 87 108 fflush(stdout); 88 109 }