1DOLLY 82PACKAGE transfer3REQUIRES HOST runtime@04REQUIRES HOST download@05REQUIRES HOST upload@067# The page's file exchange: download offers a file of the session to the8# browser, upload takes one the user chooses.9FROM /Dollyfile-system-build 0c72e09eba84571d4f8634cf6e7507eb1be1b9b8aa1fae61f6b0ec884b26b6fb10USE /Dollyfile-libdolly-download c4fcb208423787a23dba384fa56a9e7a94680d3fbe8a107e3e59b2237ab6dc1611USE /Dollyfile-libdolly-upload 8ac6d3294c36592ef7147a9d0fddfe1558ab9edfae12e51b857aeea90527d7d912REQUIRES HEADER libc13REQUIRES HEADER download14REQUIRES HEADER upload15REQUIRES TOOL cc16REQUIRES TOOL rm1718FILE /tmp/download/download.c19    #include <stdio.h>20    #include <string.h>21    22    #include <dolly/download.h>23    24    int main(int argc, char **argv) {25      if (argc == 2 && strcmp(argv[1], "--help") == 0) {26        fputs("usage: download FILE\n", stdout);27        return 0;28      }29      if (argc != 2) {30        fputs("download: expected one file\n", stderr);31        return 2;32      }33      const int status = dolly_download_file(argv[1]);34      if (status != 0) {35        fprintf(stderr, "download: %s failed (%d)\n", argv[1], status);36        return 1;37      }38      printf("download: requested %s\n", argv[1]);39      return 0;40    }4142SLOP cc \43  /tmp/download/download.c \44  -o /bin/download4546EXPORTS TOOL download47SLOP download --help > /usr/share/man/cat1/download.14849FILE /tmp/upload/upload.c50    #include <dolly/upload.h>51    #include <stdio.h>52    #include <stdlib.h>53    #include <string.h>54    int main(int argc, char **argv) {55      if (argc != 2 || strcmp(argv[1], "--help") == 0) {56        fprintf(argc == 2 ? stdout : stderr, "usage: upload DESTINATION\nChoose a file in the browser (up to %u MiB). Existing files are never replaced.\n",57                DOLLY_UPLOAD_MAX_SIZE >> 20);58        return argc == 2 ? 0 : 2;59      }60      puts("upload: choose a file in the browser, or cancel");61      fflush(stdout);62      const int result = dolly_upload_file(argv[1]);63      if (result < 0) { fprintf(stderr, "upload: %s\n", strerror((int)-result)); return 1; }64      printf("upload: saved %s\n", argv[1]);65      return 0;66    }67SLOP cc -O1 /tmp/upload/upload.c -o /bin/upload68EXPORTS TOOL upload69SLOP upload --help > /usr/share/man/cat1/upload.17071FILE /usr/share/man/cat1/download.172FILE /usr/share/man/cat1/upload.173SLOP rm -rf /tmp/download /tmp/upload74