/* * $Source$ * $Header$ */ #ifndef lint static char *rcsid_xfer_002_c = "$Header$"; #endif lint #include #include "gdb.h" #include #include #include #include "smsu_int.h" #include "kludge.h" #include extern CONNECTION conn; char buf[BUFSIZ]; extern int code, errno; extern int have_authorization, have_file, done; /* * * syntax: * >>> (STRING)"xfer_002" filesize checksum pathname * <<< (int)0 * >>> (STRING)data * <<< (int)code * >>> (STRING)data * <<< (int)code * ... * >>> (STRING)data (last data block) * <<< (int)code (from read, write, checksum verify) * * function: * perform initial preparations and receive file as * a single string, storing it into .sms_update. * * still to be done: file locking; perform transfers in pieces instead * of all at once; use checksums */ int xfer_002(str) char *str; { int file_size; int checksum; char *pathname; str += 8; while (*str == ' ') str++; if (!*str) { failure: reject_call(SMSU_BAD_ARGS); return; } file_size = atoi(str); while (isdigit(*str)) str++; while (*str == ' ') str++; checksum = atoi(str); while (isdigit(*str)) str++; while (*str == ' ') str++; if (*str != '/') goto failure; pathname = str; if (!have_authorization) { reject_call(SMSU_NO_AUTH); return; } if (done) /* re-initialize data */ initialize(); code = send_ok(); if (code) lose("sending ok for file xfer (2)"); code = get_file(pathname, file_size, checksum); if (!code) { char buf[BUFSIZ]; have_file = 1; strcpy(buf, "transferred file "); strcat(buf, pathname); sms_log_info(buf); } return; }