# 2.11BSD#431 - /usr/src/usr.bin/uucp/cpmv.c

##### Functions

    xcp               X
    xmv               X

       1: #ifndef lint
       2: static char sccsid[] = "@(#)cpmv.c	5.5 (Berkeley) 10/9/85";
       3: #endif
       4:
       5: #include "uucp.h"
       6: #include <sys/stat.h>
       7:
       8: /*LINTLIBRARY*/
       9:
      10: /*
      11:  *	copy f1 to f2
      12:  *
      13:  *	return - SUCCESS | FAIL
      14:  */
      15: xcp(f1, f2)
      16: char *f1, *f2;
      17: {
      18:     char buf[BUFSIZ];
      19:     register int len;
      20:     register int fp1, fp2;
      21:     char *lastpart();
      22:     char full[MAXFULLNAME];
      23:     struct stat s;
      24:
      25:     if ((fp1 = open(subfile(f1), 0)) < 0)
      26:         return FAIL;
      27:     strcpy(full, f2);
      28:     if (stat(subfile(f2), &s) == 0) {
      29:         /* check for directory */
      30:         if ((s.st_mode & S_IFMT) == S_IFDIR) {
      31:             strcat(full, "/");
      32:             strcat(full, lastpart(f1));
      33:         }
      34:     }
      35:     DEBUG(4, "full %s\n", full);
      36:     if ((fp2 = creat(subfile(full), 0666)) < 0) {
      37:         close(fp1);
      38:         return FAIL;
      39:     }
      40:     while((len = read(fp1, buf, BUFSIZ)) > 0)
      41:          if (write(fp2, buf, len) != len) {
      42:             len = -1;
      43:             break;
      44:         }
      45:
      46:     close(fp1);
      47:     close(fp2);
      48:     return len < 0 ? FAIL: SUCCESS;
      49: }
      50:
      51:
      52: /*
      53:  *	move f1 to f2
      54:  *
      55:  *	return  0 ok  |  FAIL failed
      56:  */
      57: xmv(f1, f2)
      58: register char *f1, *f2;
      59: {
      60:     register int ret;
      61:
      62:     (void) unlink(subfile(f2));
      63:     if (link(subfile(f1), subfile(f2)) < 0) {
      64:         /*  copy file  */
      65:         ret = xcp(f1, f2);
      66:         if (ret == 0)
      67:             unlink(subfile(f1));
      68:         return ret;
      69:     }
      70:     (void) unlink(subfile(f1));
      71:     return 0;
      72: }

#### Defined functions

xcp defined in line 15; used 4 times

- in line 65
- in /usr/src/usr.bin/uucp/uucp.c line 262, 327
- in /usr/src/usr.bin/uucp/uux.c line 303

xmv defined in line 57; used 12 times

- in /usr/src/usr.bin/uucp/anlwrk.c line 62
- in /usr/src/usr.bin/uucp/cntrl.c line 200, 433, 507, 572, 608, 899
- in /usr/src/usr.bin/uucp/uux.c line 413, 431
- in /usr/src/usr.bin/uucp/uuxqt.c line 343, 446, 541

#### Defined variables

sccsid defined in line 2; never used

Last modified: 1987-02-17 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 634 |