/* * CopyFile() * * This function copies a file into a room. */ char CopyFile(char *oldname, int room, long *size) { struct stat buf; char *temp; char buffer[150]; if ((temp = FindDirName(room)) == NULL) { mPrintf("Can't find room's directory.\n "); return FALSE; } if (stat(oldname, &buf) != 0 || !(buf.st_mode & S_IFREG)) { mPrintf("Is not a copyable file.\n "); return FALSE; } *size = buf.st_size; CitSystem(FALSE, "copy %s %s > nul", oldname, temp); if ((temp = strrchr(oldname, '\\')) != NULL) strcpy(oldname, temp + 1); else if (oldname[1] == ':') strcpy(oldname, oldname + 2); temp = FindDirName(room); sprintf(buffer, "%s%s%s", temp, (temp[strlen(temp) - 1] == ':') ? "" : "\\", oldname); return (access(buffer, 0) == 0); }
/* * MoveFile() * * This function will move a file to a new name and location. */ void MoveFile(char *oldname, char *newname) { char buffer[100]; FILE *infd, *outfd; int s; if (toUpper(*oldname) == toUpper(*newname)) { rename(oldname, newname); if (access(newname, 0) == 0) return; } CitSystem(FALSE, "copy %s %s > nul", oldname, newname); if (access(newname, 0) == 0) { unlink(oldname); } else { if ((infd = fopen(oldname, READ_ANY)) == NULL) return; if ((outfd = fopen(newname, WRITE_ANY)) == NULL) { fclose(infd); return; } while ((s = fread(buffer, sizeof buffer, 1, infd)) > 0) fwrite(buffer, s, 1, outfd); fclose(infd); fclose(outfd); unlink(oldname); } }
/* * OutsideEditorWork() * * This will execute an outside editor for anyone. */ void OutsideEditorWork(char *EditLine) { char cmdline[90]; extern FILE *upfd; extern int outPut; doCR(); /* this gets crtColumn back to zero */ sprintf(cmdline, "%stempmsg.sys", cfg.DepData.EditArea); if (!redirect(cmdline, INPLACE_OF)) return; mFormat(msgBuf.mbtext, oChar, doCR); undirect(); MakeCmdLine(cmdline, EditLine, "", sizeof cmdline - 1); if (cfg.DepData.IBM) ModemShutdown(FALSE); CitSystem(TRUE, "%s %stempmsg.sys", cmdline, cfg.DepData.EditArea); if (cfg.DepData.IBM) { ModemOpen(FALSE); if (!gotCarrier() && strLen(cfg.DepData.sDisable) == 0) DisableModem(FALSE); } /* homeSpace(); */ /* Commented out for 120.692 */ msgBuf.mbtext[0] = 0; sprintf(cmdline, "%stempmsg.sys", cfg.DepData.EditArea); msgBuf.mbtext[0] = 0; ingestFile(cmdline, msgBuf.mbtext); unlink(cmdline); }
void RunFax(void) { extern char *FaxString; if (FaxString != NULL) { printf("Fax detected, running %s\n", FaxString); CitSystem(TRUE, "%s", FaxString); HangUp(TRUE); /* yeah, TRUE */ } }