1DOLLY 32MODULE upload34REQUIRES HEADER libc5REQUIRES HEADER process6REQUIRES TOOL cc7REQUIRES TOOL rm89FILE /tmp/upload/upload.c1011121314 int main(int argc, char **argv) {15 if (argc != 2 || strcmp(argv[1], "--help") == 0) {16 fprintf(argc == 2 ? stdout : stderr, "usage: upload DESTINATION\nChoose a file in the browser (up to 64 MiB). Existing files are never replaced.\n");17 return argc == 2 ? 0 : 2;18 }19 const size_t length = strlen(argv[1]);20 if (length == 0 || length >= 4096) return 2;21 unsigned char packet[sizeof(dolly_process_path_request) + 4096];22 const dolly_process_path_request request = {23 .directory_descriptor = UINT32_MAX, .path_size = (uint32_t)length,24 };25 memcpy(packet, &request, sizeof(request));26 memcpy(packet + sizeof(request), argv[1], length);27 puts("upload: choose a file in the browser, or cancel");28 fflush(stdout);29 const int64_t result = dolly_process_call(DOLLY_PROCESS_UPLOAD_FILE,30 packet, sizeof(request) + length, NULL, 0);31 if (result < 0) { fprintf(stderr, "upload: %s\n", strerror((int)-result)); return 1; }32 printf("upload: saved %s\n", argv[1]);33 return 0;34 }35SLOP cc -std=c17 -O1 /tmp/upload/upload.c -o /bin/upload36EXPORTS TOOL upload37SLOP rm -rf /tmp/upload38