home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / msdos / c / crcbbs.arc / CRCPC1C.C < prev    next >
Text File  |  1985-10-22  |  18KB  |  564 lines

  1. #include    "crcpchdr.h"
  2.  
  3. disp_dir(c,args,opts)
  4. char c, *args, *opts;
  5. {
  6. int quiet,subs,users,boards,current;
  7.  
  8. quiet = find_option(opts,'q');
  9. current = find_options(opts,'c');
  10. subs = find_option(opts,'s');
  11. users = find_option(opts,'u');
  12. boards = find_option(opts,'b');
  13.  
  14.                 /* If none specifically asked for, give all */
  15. if (!(current||subs||users||boards)) subs = users = boards = current = TRUE;
  16.  
  17. if (!quiet && beginner) disp_msg(10);
  18.  
  19. if (current && !subs) print_cd();    /* "SUBS SHOWS CURDIR ANYWAYS" */
  20.  
  21. if (subs) {
  22.     cr();
  23.     sysdir(cur_dir,cur_root);
  24.     printf("Subdirectories on: %s\r\n",
  25.         prefix_dir(file_buff,cur_dir,cur_root));
  26.     if (dir("*.*",DIR_TYP)) printf("None\r\n");
  27.     }
  28.  
  29. if (users && !quit) {
  30.     output = TRUE;
  31.     cr();
  32.     printf("%s user directories:\r\n",SYSNAME);
  33.     sysdir("",user_root);
  34.     if (dir("*.*",DIR_TYP)) printf("None\r\n");
  35.     }
  36. if (boards && !quit) {
  37.     output = TRUE;
  38.     cr();
  39.     if (!sysdir("",MESSAGES)) {
  40.         printf("%s message board directories:\r\n",SYSNAME);
  41.         if (dir("*.*",DIR_TYP)) printf("None\r\n");
  42.         }
  43.     else printf("%s message system not setup.\r\n");
  44.     }
  45. cr();
  46. }
  47.  
  48. type_file(c,args,opts)
  49. char c, *args, *opts;
  50. {
  51. char filename[17];
  52. if (!has_auth("R",cur_dir,cur_root)) return(not_auth('R',cur_dir,cur_root));
  53. if (!*args) {
  54.     disp_reply(file_prompt(beginner,"type to terminal"),filename,14);
  55.     if (filename[0]=='\0') return(nothing_done());
  56.     args = filename;
  57.     }
  58. if (check_fn(args,TRUE)) return;
  59. if (check_rsvf(args,TRUE)) return;    /* Can't use reserved filename */
  60. typefile(args,opts);
  61. cr();
  62. }
  63.  
  64. erase_file(c,args,opts)
  65. char c, *args, *opts;
  66. {
  67. char filename[17], *t1, *t2, *t3;
  68. if (!*args && !find_option(opts,'q') && beginner) disp_msg(14);
  69. if (!has_auth("W",cur_dir,cur_root)) return(not_auth('W',cur_dir,cur_root));
  70. threeparse(args,&t1,&t2,&t3);
  71. if (!*t1) {
  72.     t1 = disp_reply(file_prompt(beginner,"erase"),filename,14);
  73.     if (t1[0]=='\0') return(nothing_done());
  74.     }
  75. if (check_fn(t1,TRUE)) return;
  76. if (check_rsvf(t1,TRUE)) return;    /* Can't use reserved filename */
  77. if (unlink(t1)) 
  78.     printf("File '%s' not found or illegal name.\r\n",t1);
  79. else printf("File '%s' erased.\r\n",t1);
  80. }
  81.  
  82. list_file(c,args,opts)
  83. char c, *args, *opts;
  84. {
  85. char fn[DIRSIZE+ROOTSIZE+20];
  86. char *t1;
  87. if (!*args && !find_option(opts,'q') && beginner) disp_msg(51);
  88. if (!*args) args = "*.*";
  89. if (t1=stpchr(args,INVDIRCHR)) return(bad_fn(*t1)); /* Can't use special chars in filename */
  90. prefix_dir(workstr,cur_dir,cur_root);
  91. prefix_dir(fn,args,workstr);
  92. dirc(fn,opts);
  93. }
  94.  
  95. mk_dir(c,args,opts)
  96. char c, *args, *opts;
  97. {
  98. int quiet;
  99. int rc;
  100. char curdir[DIRSIZE+ROOTSIZE], *type;
  101.  
  102. quiet = find_option(opts,'q');
  103. if (beginner && !*args && !quiet) disp_msg(30);
  104. if (!has_auth("W",cur_dir,cur_root)) return(not_auth('W',cur_dir,cur_root));
  105. prefix_dir(curdir,cur_dir,cur_root);
  106. if (!quiet) printf("Subdirectory will be attached to: %s\r\n",curdir);
  107. if (*args) {
  108.     stptok(args,workstr,9," ");
  109.     goto trymd1;
  110.     }
  111. getmdagn:
  112. if (*args) return(1000);
  113. disp_reply("Name for new subdirectory? ",workstr,9);
  114. if (!workstr[0]) return(nothing_done()&0);
  115. trymd1:     
  116. if (type=stpbrk(workstr,INVDOSFNCHR)) {
  117.      bad_dn(*type);
  118.      goto getmdagn;
  119.      }
  120. uppercase(workstr);
  121. if (!sysdir(workstr,curdir)) {
  122.      printf("Already '%s' subdirectory on %s!\r\n",workstr,curdir);
  123.     goto getmdagn;
  124.     }
  125. printf("Standby:\r\n");
  126.             /* Rc==2 when using -XT (??) */
  127. if ((rc=sysmkdir(workstr,curdir))!=0 && rc!=2) {
  128.     printf("Oops!  Error during subdirectory creation.\r\n");
  129.     printf("Not today: sorry.\r\n");
  130.     sprintf(file_buff,"SUBDIRECTORY CREATION (%s\\%s) FAILURE FOR %s: RC=%d",
  131.         curdir,workstr,user_id,rc);
  132.     logevent(file_buff);
  133.     }
  134. else {
  135.     if (!quiet) printf("Subdirectory '%s' created on %s and ready for use.\r\n",workstr,curdir);
  136.     }
  137. return(0);
  138. }
  139.  
  140. rm_dir(c,args,opts)
  141. char c, *args, *opts;
  142. {
  143. int gnl_flag, quiet;
  144. char curdir[DIRSIZE+ROOTSIZE];
  145. char *type;
  146.  
  147. quiet = find_option(opts,'q');
  148. if (!*args && !quiet && beginner) disp_msg(31);
  149. if (!has_auth("W",cur_dir,cur_root)) return(not_auth('W',cur_dir,cur_root));
  150. prefix_dir(curdir,cur_dir,cur_root);
  151. if (*args) {
  152.     stptok(args,workstr,9," ");
  153.     goto tryrm2;
  154.     }
  155. g2trmagn:
  156. if (*args) return;
  157. printf("Name of subdirectory to kill? ");
  158. strcpy(workstr,lineinput(9));
  159. if (!workstr[0]) return(nothing_done());
  160. tryrm2:
  161. if (type=stpbrk(workstr,INVDOSFNCHR)) {
  162.     bad_dn(*type);
  163.     goto g2trmagn;
  164.     }
  165. uppercase(workstr);
  166. if (sysdir(workstr,curdir)) {
  167.     printf("No such subdirectory '%s' attached to current directory\r\n",workstr);
  168.     return;
  169.     }
  170. else if (!setup_dir("*.*",FILE_TYP)) {
  171.     printf("Subdirectory '%s' has files in it!\r\n",workstr);
  172.     if (!quiet) printf("Please erase all files first!\r\n");
  173.     return;
  174.     }
  175. printf("Please wait; this takes awhile sometimes ...\r\n");
  176. sysdir("",curdir);
  177. if (gnl_flag=sysrmdir(workstr,curdir)) {
  178.     if (gnl_flag==5) {
  179.         printf("'%s' has files in it!\r\n",workstr);
  180.         return;
  181.         }
  182.     else if (gnl_flag==3) printf("No such subdir: '%s'!\r\n",workstr);
  183.     goto g2trmagn;
  184.     }
  185. else {
  186.     if (!quiet) printf("Ok %s, subdirectory '%s' has been removed.\r\n",usname(),workstr);
  187.     }
  188. }
  189.  
  190. int pchdir(prefixed,homeroot,homedir,curroot,curdir,destroot,destdir,where)
  191. int prefixed;
  192. char *homeroot, *curroot, *destroot;
  193. char *homedir, *curdir, *destdir;
  194. char *where;
  195. {
  196. /*
  197. 1. 'marty'  ->  curroot + curdir + '\marty'
  198. 2. '$home'  ->  homeroot + homedir   (i.e. '\users\marty')
  199. 3. '\jeff'  ->  cur_root + '\jeff'   (NO Global System Read Access)
  200. 4. '\jeff'  ->  '\jeff'             (Global System Read/Write Access Only)
  201. */
  202.  
  203. if (!*where) {
  204.     strcpy(destdir,curdir);
  205.     strcpy(destroot,curroot);
  206.     return 0;
  207.     }
  208.  
  209. if (*where == ESCSYM) {            /* He wants to specify entire thing */
  210.     where++;            /* Chop off redund. ESCSYM */
  211.     if (prefixed) strcpy(destroot,curroot);    /* Tack on current root */
  212.     else *destroot = '\0';            /* System access: no root */
  213.     strcpy(destdir,where);
  214.     return 0;
  215.     }
  216. else if (*where == SPCSYM) {        /* For special prenamed directories */
  217.     ++where;
  218.     if (!strcmp(SPCHOME,where)) {
  219.         strcpy(destdir,homedir);
  220.         strcpy(destroot,homeroot);
  221.         return 0;
  222.         }
  223.     return 1;            /* Error - no such special directory */
  224.     }
  225. else {                    /* Append (logically) to current dir */
  226.     prefix_dir(destdir,where,curdir);    /* Logical 'curdir+where' */
  227.     strcpy(destroot,curroot);
  228.     return 0;
  229.     }
  230. }
  231.  
  232. jump_dir(c,args,opts)
  233. char c, *args, *opts;
  234. {
  235. char *type, *t1, *t2, *t3;
  236. int quiet;
  237. char workbuf[10];
  238.  
  239. quiet = find_option(opts,'q');
  240. threeparse(args,&t1,&t2,&t3);
  241.  
  242. if (!*t1) {
  243.         if (!strcmp(cur_dir,home_dir) &&        /* If he's at home ... */
  244.             !strcmp(cur_root,user_root)) {
  245.                         if (!quiet && beginner) disp_msg(19);
  246.                 }       
  247.         else printf("Type '*' to go to home directory\r\n");
  248.         }
  249. getfdn:
  250. if (!*t1) t1 = disp_reply("Enter message board name: ",workbuf,9);
  251. uppercase(t1);
  252. if (*t1) {
  253.         if (!strcmp(t1,"*")) {
  254.                 t1 = home_dir;
  255.                 strcpy(cur_root,user_root);
  256.                 }
  257.         else if (type=stpbrk(t1,INVDOSFNCHR)) {
  258.                 bad_dn(*type);
  259.                 t1 = "";
  260.                 goto jumpdone;
  261.                 }
  262. /* else */
  263. /* we will check the message system for a matching board name */
  264.         else if (!sysdir(t1,MESSAGES)) {
  265.                 if (!quiet && beginner) {
  266.             printf("You are currently logged to the %s message board\r\n",t1);
  267.             printf("Use 'JUMP *' to return to home directory\r\n");
  268.             }
  269.                 strcpy(cur_dir,t1);
  270.                 strcpy(cur_root,MESSAGES);
  271.                 goto jumpdone;
  272.                 }
  273. /* else we try the user root */
  274.         if (sysdir(t1,user_root)) {
  275.                 printf("Can't find %s\r\n",t1);
  276.                 t1 = "";
  277.                 goto jumpdone;
  278.                 }
  279. /* AND he must at least have Read access to the Main directory, */
  280.         else if (!has_auth("R",t1,user_root)) {  
  281.                 printf("Access denied.  ");
  282.         if (beginner) printf("Contact %s for assistance",SYSOP);
  283.         printf("\r\n");
  284.                 goto jumpdone;
  285.                 }
  286.        else {
  287.         strcpy(cur_dir,t1);
  288.         strcpy(cur_root,user_root);
  289.         }
  290.        }
  291. else nothing_done();
  292. jumpdone:
  293. sysdir(cur_dir,cur_root);
  294. if (!quiet) print_cd();
  295. }
  296.  
  297. go_dir(c,args,opts)
  298. char c, *args, *opts;
  299. {
  300. char *type, *t1, *t2, *t3;
  301. int quiet;
  302. int rc;
  303. char testdir[DIRSIZE];
  304. char test_dir[DIRSIZE];
  305. char test_root[ROOTSIZE];
  306. char workbuf[50];
  307.  
  308. quiet = find_option(opts,'q');
  309. threeparse(args,&t1,&t2,&t3);
  310.  
  311. if (!*t1) {
  312.         if (!strcmp(cur_dir,home_dir) &&        /* If he's at home ... */
  313.             !strcmp(cur_root,user_root)) {
  314.                         if (!quiet && beginner) disp_msg(18);
  315.                 }       
  316.         else printf("Type '*' to go home\r\n");
  317.         }
  318. getddn:
  319. if (!*t1) t1 = disp_reply("Enter directory (path) name: ",workbuf,48);
  320. uppercase(t1);
  321. if (*t1) {
  322.         if (!strcmp(t1,"*")) {
  323.                 strcpy(cur_dir,home_dir);
  324.                 strcpy(cur_root,user_root);
  325.         goto godone;
  326.                 }
  327.         else if (type=stpbrk(t1,INVDOSPNCHR)) {
  328.                 bad_pn(*type);
  329.                 t1 = "";
  330.                 goto godone;
  331.                 }
  332. /* else */
  333. /* we will prepare a logical pathname from what he/she typed  */
  334.         else if (rc=pchdir(!sysread,
  335.         user_root,home_dir,cur_root,cur_dir,test_root,test_dir,t1)) {
  336. /* No. Probably unrecognized special pathname */
  337.         if (rc==1) printf("Unknown special path: %s\r\n",t1);
  338.         else printf("pCHdir error\r\n");
  339.         }
  340.     else {
  341. /* Yes. Preparation was O.K. - check for system understanding of pathname ?! */
  342.         /* Make printable version in case of error */
  343.                 prefix_dir(testdir,test_dir,test_root);
  344.         if (!sysdir(test_dir,test_root)) {
  345. /* AND he must at least have Read access to this directory, test_root */
  346.             if (!has_auth("R",test_dir,test_root)) {  
  347.                         printf("Access denied: %s\r\n",testdir);
  348.                         goto godone;
  349.                         }
  350.             strcpy(cur_dir,test_dir);
  351.             strcpy(cur_root,test_root);
  352.             goto godone;
  353.             }
  354.             else {
  355.                     t1 = "";
  356.                     printf("Can't access %s\r\n",testdir);
  357.                     goto godone;
  358.                     }
  359.         }
  360.        }
  361. else nothing_done();
  362. godone:
  363. sysdir(cur_dir,cur_root);
  364. if (!quiet) print_cd();
  365. }
  366.  
  367. /* Strip_Arg:  Subroutine to DIREXPAND (forward) */
  368. int strip_arg(outptr,inptr,brksym)
  369. char **outptr;
  370. char **inptr;
  371. char brksym;
  372. {
  373. char *testptr;
  374. *inptr=stpblk(*inptr);
  375. if (testptr=stpchr(*inptr,brksym)) {
  376.     *outptr = *inptr;
  377.     *testptr = '\0';    /* Zap out ESC CHR */
  378.     *inptr = testptr+1;    
  379.     return(0);
  380.     }
  381. else {
  382.     *outptr = *inptr;
  383.     *inptr = NULL;
  384.     return(1);    /* Error signalling end of list - no more tokens */
  385.     }
  386. }
  387.  
  388.  
  389. #define MAXNODES  32   /* 32 for safety ? */
  390. int direxpand(outpath,inpath,cur_dir,maxlen)
  391. char *outpath, *inpath,*cur_dir;
  392. int maxlen;
  393. {
  394. char *nodes[MAXNODES];
  395. char *outnodes[MAXNODES];
  396. int i,j,k;
  397. int absolute;
  398. char ourpath[DIRSIZE+ROOTSIZE];      /* Holding buffer for work string array */
  399.  
  400. inpath=stpblk(inpath);
  401.  
  402. if (*inpath==ESCSYM) { inpath++; absolute = TRUE; }
  403. else absolute = FALSE;
  404.  
  405. if (!absolute) {
  406.     strcpy(ourpath,cur_dir);
  407.     if (*ourpath) 
  408.         if (ourpath[strlen(ourpath)-1]!=ESCSYM) strcat(ourpath,ESCSTR);
  409.     }
  410. else strcpy(ourpath,ESCSTR);
  411. strcat(ourpath,inpath);
  412.  
  413. inpath=ourpath;              /* Use our own copy from now on */
  414.  
  415. i=0; 
  416. while(strip_arg(&nodes[i++],&inpath,ESCSYM)==0) if (i==MAXNODES) break; 
  417. j=i;
  418. for (k=i=0;i<j;i++) {
  419.     if (!strcmp(nodes[i],CURDIR)) ;        /* "." */
  420.     else if (!strcmp(nodes[i],UPLEVEL)) {   /* ".." */
  421.         if (k>0) k--; 
  422.         else return(1);    /* Error 1 = tried to back up too far */
  423.         }
  424.     else outnodes[k++]=nodes[i];
  425.     if (i==MAXNODES) return(2);    /* Error 2 = too many nodes specified */
  426.     }
  427. *outpath='\0';
  428. for (i=0;i<k;) {
  429.     if ((strlen(outpath)+strlen(outnodes[i])+1)<maxlen) strcat(outpath,outnodes[i]);
  430.     else return(3);        /* Error 3 = Output string too long */
  431.     i++;
  432.     if (i<k) strcat(outpath,ESCSTR);
  433.     }
  434. return(0);
  435. }
  436.  
  437. dup_file(c,args,opts)
  438. char c, *args, *opts;
  439. {
  440. char filename[DIRSIZE+1], destfile[DIRSIZE+1], *t1, *t2, *t3, *format;
  441. char filetest[DIRSIZE+1], desttest[DIRSIZE+1];
  442. char filedir[DIRSIZE+1], destdir[DIRSIZE+1];
  443. char origname[DIRSIZE+1], destname[DIRSIZE+1];
  444. int append, text;
  445. int rc;
  446.  
  447. threeparse(args,&t1,&t2,&t3);
  448. uppercase(t1); uppercase(t2);
  449.  
  450. append = find_option(opts,'a');
  451. text = find_option(opts,'t');    /* Select CONTROL-Z as file EOF */
  452.                 /* (default is BINARY file copy) */
  453. threeparse(args,&t1,&t2,&t3);
  454. uppercase(t1); uppercase(t2);
  455. if (!*t1) {             /* No first argument */
  456.         if (!find_option(opts,'q') && beginner) disp_msg(11);
  457.         disp_reply("Input [path\\]filename: ",filename,sizeof(filename)-1);
  458.         }
  459. else stccpy(filename,t1,sizeof(filename));
  460. if (!*filename) return(nothing_done());
  461. if (rc=direxpand(origname,filename,cur_dir,sizeof(origname))) 
  462.     return(invpath(rc,filename)); /* Expand filename into ORIGNAME */
  463. stccpy(filename,origname,sizeof(filename));    /* Make them equal */
  464. sep_dir_fn(filename,filedir,filetest);
  465. if (!*filetest) return(nothing_done());
  466. if (!*filedir) stccpy(filedir,cur_dir,sizeof(filedir));
  467. if (check_fn(filetest,TRUE)) return;
  468. if (check_rsvf(filetest,TRUE)) return;  /* Can't use reserved filename */
  469. if (*filedir==ESCSYM) strcpy(filedir,filedir+1);
  470. if (!has_auth("R",filedir,cur_root)) return(not_auth('R',filedir,cur_root));
  471.                         /* We prompt for second argument only iff no first */
  472. if (!*t1) disp_reply("Output [path\\]filename: ",destfile,sizeof(destfile)-1);
  473.                 /* If second argument, it is file 2 */
  474. else if (*t2) stccpy(destfile,t2,sizeof(destfile));
  475.                 /* else use filename of file1, and current directory */
  476. else strcpy(destfile,CURDIR);   /* Write in "." */
  477. if (!*destfile) return(nothing_done());
  478. if (!strcmp(destfile,CURDIR)||!strcmp(destfile,UPLEVEL)) strcat(destfile,ESCSTR);
  479. if (rc=direxpand(destname,destfile,cur_dir,sizeof(destname))) 
  480.         return(invpath(rc,destfile)); /* Expand destfile into destname */ 
  481. stccpy(destfile,destname,sizeof(destfile));
  482. sep_dir_fn(destfile,destdir,desttest);
  483. if (!*desttest) stccpy(desttest,filetest,sizeof(desttest));
  484. if (!*destdir) stccpy(destdir,cur_dir,sizeof(destdir));
  485. if (check_fn(desttest,TRUE)) return;
  486. if (check_rsvf(desttest,TRUE)) return;  /* Can't use reserved filename */
  487. if (*destdir==ESCSYM) strcpy(destdir,destdir+1);
  488. uppercase(filetest);uppercase(desttest);uppercase(filedir);uppercase(destdir);
  489. if (!strcmp(filetest,desttest) && !strcmp(filedir,destdir)) return(cusfn());
  490. if (!has_auth("W",destdir,cur_root)) return(not_auth('W',destdir,cur_root));
  491. prefix_dir(destname,destdir,cur_root);
  492. prefix_dir(origname,filedir,cur_root);
  493. if (sysfcopy(destname,desttest,origname,filetest,text,!append)) 
  494.     printf("File not copied.\r\n");
  495. else {
  496.     if (text) printf("Text translation used; ^Z is file EOF\r\n");
  497.         if (append) format = "File %s appended to %s\r\n";
  498.         else format = "File %s copied to %s\r\n";
  499.         printf(format,filename,destfile);
  500.         }
  501. }
  502.  
  503. rename_file(c,args,opts)
  504. char c, *args, *opts;
  505. {
  506. char filename[DIRSIZE+1], destfile[DIRSIZE+1], *t1, *t2, *t3;
  507. char filetest[DIRSIZE+1], desttest[DIRSIZE+1];
  508. char filedir[DIRSIZE+1], destdir[DIRSIZE+1];
  509. char origname[DIRSIZE+1], destname[DIRSIZE+1];
  510. int rc;
  511.  
  512. threeparse(args,&t1,&t2,&t3);
  513. uppercase(t1); uppercase(t2);
  514. if (!*t1) {             /* No first argument */
  515.         if (!find_option(opts,'q') && beginner) disp_msg(12);
  516.         printf("Enter [path\\]name of file to rename: ");
  517.         disp_reply("",filename,sizeof(filename)-1);
  518.         }
  519. else stccpy(filename,t1,sizeof(filename));
  520. if (!*filename) return(nothing_done());
  521. if (!strcmp(filename,CURDIR)||!strcmp(filename,UPLEVEL)) strcat(filename,ESCSTR);
  522. if (rc=direxpand(origname,filename,cur_dir,sizeof(origname))) 
  523.     return(invpath(rc,filename)); /* Expand filename into ORIGNAME */
  524. stccpy(filename,origname,sizeof(filename));
  525. sep_dir_fn(filename,filedir,filetest);
  526. if (!*filetest) return(nothing_done());
  527. if (!*filedir) stccpy(filedir,cur_dir,sizeof(filedir));
  528. if (check_fn(filetest,TRUE)) return;
  529. if (check_rsvf(filetest,TRUE)) return;  /* Can't use reserved filename */
  530. if (*filedir==ESCSYM) strcpy(filedir,filedir+1);
  531. if (!has_auth("W",filedir,cur_root)) return(not_auth('W',filedir,cur_root));
  532. if (!*t2) {
  533.         printf("Enter new [path\\]filename for '%s': ",filename);
  534.         disp_reply("",destfile,sizeof(destfile)-1);
  535.         }
  536. else stccpy(destfile,t2,sizeof(destfile));
  537. if (!*destfile) return(nothing_done());
  538.                 /* else use filename of file1, and current directory */
  539. if (!strcmp(destfile,CURDIR)||!strcmp(destfile,UPLEVEL)) strcat(destfile,ESCSTR);
  540. if (rc=direxpand(destname,destfile,cur_dir,sizeof(destname))) 
  541.     return(invpath(rc,destfile)); /* Expand destfile into destname */
  542. stccpy(destfile,destname,sizeof(destfile));
  543. sep_dir_fn(destfile,destdir,desttest);
  544. if (!*desttest) stccpy(desttest,filetest,sizeof(desttest));
  545. if (!*destdir) stccpy(destdir,filedir,sizeof(destdir));
  546. if (check_fn(desttest,TRUE)) return;
  547. if (check_rsvf(desttest,TRUE)) return;  /* Can't use reserved filename */
  548. if (*destdir==ESCSYM) strcpy(destdir,destdir+1);
  549. uppercase(filetest);uppercase(desttest);uppercase(filedir);uppercase(destdir);
  550. if (!strcmp(filetest,desttest) && !strcmp(filedir,destdir)) return(cusfn());
  551. if (!has_auth("W",destdir,cur_root)) return(not_auth('W',destdir,cur_root));
  552. else {
  553.         prefix_dir(destfile,destdir,cur_root);
  554.         prefix_dir(destdir,desttest,destfile);
  555.         stccpy(destfile,destdir,sizeof(destfile));
  556.         prefix_dir(filename,filedir,cur_root);
  557.         prefix_dir(filedir,filetest,filename);
  558.         stccpy(filename,filedir,sizeof(filename));
  559.         if (rc=rename(filename,destfile)) printf("RENAME error %d: %s -> %s\r\n",rc,filename,destfile);
  560.         else printf("%s -> %s ok.\r\n",origname,destname);
  561.         }
  562. }
  563. 
  564.