1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23 /* All Rights Reserved */ 24 25 26 #ident "%Z%%M% %I% %E% SMI" /* from SVR4 bnu:bnuconvert.c 1.3.1.2 */ 27 28 #include "uucp.h" 29 30 main(argc, argv) 31 int argc; 32 char **argv; 33 { 34 char fdgrade(); 35 DIR *machdir, *spooldir; 36 char machname[MAXFULLNAME]; 37 char file1[NAMESIZE+1], file2[NAMESIZE+1]; 38 struct cs_struct svdcfile; 39 int c; 40 41 (void) strcpy(Progname, "bnuconvert"); 42 43 Uid = getuid(); 44 Euid = geteuid(); 45 if (Uid == 0) 46 (void) setuid(UUCPUID); 47 48 while ((c = getopt(argc, argv, "x:")) != EOF) 49 switch(c) { 50 case 'x': 51 Debug = atoi(optarg); 52 if (Debug < 0) 53 Debug = 1; 54 break; 55 default: 56 (void) fprintf(stderr, "usage: bnuconvert [-xLEVEL]\n"); 57 exit(-1); 58 } 59 60 DEBUG(5, "Progname (%s): STARTED\n", Progname); 61 62 /* find the default directory to queue to */ 63 64 if (eaccess(GRADES, 04) != -1) 65 svdcfile.grade = fdgrade(); 66 else 67 svdcfile.grade = D_QUEUE; 68 69 DEBUG(5, "All jobs will be placed in directory (%c) ", svdcfile.grade); 70 DEBUG(5, "under each remote name in the spool area.%c\n", NULLCHAR); 71 72 if ((spooldir = opendir(SPOOL)) == NULL) { 73 (void) fprintf(stderr, "CAN'T OPEN (%s): errno (%d)\n", 74 SPOOL, errno); 75 exit(1); 76 } 77 78 while (gdirf(spooldir, file1, SPOOL)) { 79 80 (void) sprintf(Rmtname, "%s", file1); 81 (void) sprintf(machname, "%s/%s", SPOOL, file1); 82 DEBUG(9, "File1 is (%s)\n", file1); 83 DEBUG(9, "Rmtname is (%s)\n", Rmtname); 84 DEBUG(9, "Machname is (%s)\n", machname); 85 86 if (chdir(machname) != 0) { 87 (void) fprintf(stderr, "CAN'T CHDIR (%s): errno (%d)\n", 88 machname, errno); 89 exit(1); 90 } 91 92 if ((machdir = opendir(machname)) == NULL) { 93 (void) fprintf(stderr, "CAN'T OPEN (%s): errno (%d)\n", 94 machname, errno); 95 continue; 96 } 97 98 DEBUG(7, "Directory: %s\n", machname); 99 100 while (gnamef(machdir, file2) == TRUE) { 101 102 DEBUG(9, "File read from (%s) ", machname); 103 DEBUG(9, "is (%s)\n", file2); 104 105 if (!EQUALSN(file2, "C.",2)) 106 continue; 107 108 /* build a saved C. file structure */ 109 110 (void) strncpy(svdcfile.file, file2, NAMESIZE-1); 111 (void) sprintf(svdcfile.sys, "%s/%c", Rmtname, svdcfile.grade); 112 113 DEBUG(9, "Rmtname is (%s)\n", Rmtname); 114 DEBUG(9, "Default directory to queue to is (%c)\n", svdcfile.grade); 115 DEBUG(7, "Directory to queue to is (%s)\n", svdcfile.sys); 116 117 /* place any and all D. files related to the 118 ** C. file in the proper spool area. 119 */ 120 121 putdfiles(svdcfile); 122 123 /* Now queue the C. file */ 124 125 wfcommit(svdcfile.file, svdcfile.file, svdcfile.sys); 126 } 127 closedir(machdir); 128 } 129 closedir(spooldir); 130 exit(0); 131 } 132 /* a dummy cleanup function to satisfy a .o file */ 133 void cleanup() {} 134