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