-
-
-/*
- * cmd_ndop() - open a network spool file for downloading
- */
-void cmd_ndop(char *cmdbuf)
-{
- char pathname[256];
- struct stat statbuf;
-
- if (IsEmptyStr(CC->net_node)) {
- cprintf("%d Not authenticated as a network node.\n",
- ERROR + NOT_LOGGED_IN);
- return;
- }
-
- if (CC->download_fp != NULL) {
- cprintf("%d You already have a download file open.\n",
- ERROR + RESOURCE_BUSY);
- return;
- }
-
- snprintf(pathname, sizeof pathname,
- "%s/%s",
- ctdl_netout_dir,
- CC->net_node);
-
- /* first open the file in append mode in order to create a
- * zero-length file if it doesn't already exist
- */
- CC->download_fp = fopen(pathname, "a");
- if (CC->download_fp != NULL)
- fclose(CC->download_fp);
-
- /* now open it */
- CC->download_fp = fopen(pathname, "r");
- if (CC->download_fp == NULL) {
- cprintf("%d cannot open %s: %s\n",
- ERROR + INTERNAL_ERROR, pathname, strerror(errno));
- return;
- }
-
-
- /* set this flag so other routines know that the download file
- * currently open is a network spool file
- */
- CC->dl_is_net = 1;
-
- stat(pathname, &statbuf);
- CC->download_fp_total = statbuf.st_size;
- cprintf("%d %ld\n", CIT_OK, (long)statbuf.st_size);
-}
-
-/*
- * cmd_nuop() - open a network spool file for uploading
- */
-void cmd_nuop(char *cmdbuf)
-{
- static int seq = 1;
-
- if (IsEmptyStr(CC->net_node)) {
- cprintf("%d Not authenticated as a network node.\n",
- ERROR + NOT_LOGGED_IN);
- return;
- }
-
- if (CC->upload_fp != NULL) {
- cprintf("%d You already have an upload file open.\n",
- ERROR + RESOURCE_BUSY);
- return;
- }
-
- snprintf(CC->upl_path, sizeof CC->upl_path,
- "%s/%s.%04lx.%04x",
- ctdl_nettmp_dir,
- CC->net_node,
- (long)getpid(),
- ++seq);
-
- CC->upload_fp = fopen(CC->upl_path, "r");
- if (CC->upload_fp != NULL) {
- fclose(CC->upload_fp);
- CC->upload_fp = NULL;
- cprintf("%d '%s' already exists\n",
- ERROR + ALREADY_EXISTS, CC->upl_path);
- return;
- }
-
- CC->upload_fp = fopen(CC->upl_path, "w");
- if (CC->upload_fp == NULL) {
- cprintf("%d Cannot open %s: %s\n",
- ERROR + INTERNAL_ERROR, CC->upl_path, strerror(errno));
- return;
- }
-
- CC->upload_type = UPL_NET;
- cprintf("%d Ok\n", CIT_OK);
-}