X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fdownloads.c;h=d29e7fc7ebd635f8658436332dd2ccaca2c7fbf8;hb=bedf5c0b955473d8ad02eaf628e8d209f534f2b6;hp=a1d2984c459615e8e0ef53f453f92f9527cdc60e;hpb=a98b77122767a5ab63763b37715f2b8a5403de34;p=citadel.git diff --git a/webcit/downloads.c b/webcit/downloads.c index a1d2984c4..d29e7fc7e 100644 --- a/webcit/downloads.c +++ b/webcit/downloads.c @@ -1,5 +1,5 @@ /* - * $Id: downloads.c 4849 2007-01-08 20:05:56Z ajc $ + * $Id$ */ #include "webcit.h" @@ -50,7 +50,32 @@ void display_room_directory(void) wprintf("\n"); } - wprintf("\n"); + wprintf("\n"); + + /** Now offer the ability to upload files... */ + if (WC->room_flags & QR_UPLOAD) + { + wprintf("
"); + wprintf("
\n" + ); + wprintf("\n", WC->nonce); + + wprintf(_("Upload a file:")); + wprintf("  \n"); + wprintf(_("Description:")); + wprintf("  "); + wprintf("\n", _("Upload")); + + wprintf("
\n"); + } + + wprintf("\n"); wDumpContent(1); } @@ -61,9 +86,13 @@ void download_file(char *filename) off_t bytes; char content_type[256]; char *content = NULL; - int force_download = 0; + + /* Setting to nonzero forces a MIME type of application/octet-stream */ + int force_download = 1; - serv_printf("OPEN %s", filename); + safestrncpy(buf, filename, sizeof buf); + unescape_input(buf); + serv_printf("OPEN %s", buf); serv_getln(buf, sizeof buf); if (buf[0] == '2') { bytes = extract_long(&buf[4], 0); @@ -90,3 +119,42 @@ void download_file(char *filename) } + + +void upload_file(void) +{ + char buf[1024]; + size_t bytes_transmitted = 0; + size_t blocksize; + + serv_printf("UOPN %s|%s", WC->upload_filename, bstr("description")); + serv_getln(buf, sizeof buf); + if (buf[0] != '2') + { + strcpy(WC->ImportantMessage, &buf[4]); + display_room_directory(); + return; + } + + while (bytes_transmitted < WC->upload_length) + { + blocksize = 4096; + if (blocksize > (WC->upload_length - bytes_transmitted)) + { + blocksize = (WC->upload_length - bytes_transmitted); + } + serv_printf("WRIT %d", blocksize); + serv_getln(buf, sizeof buf); + if (buf[0] == '7') + { + blocksize = atoi(&buf[4]); + serv_write(&WC->upload[bytes_transmitted], blocksize); + bytes_transmitted += blocksize; + } + } + + serv_puts("UCLS 1"); + serv_getln(buf, sizeof buf); + strcpy(WC->ImportantMessage, &buf[4]); + display_room_directory(); +}