17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 22*462be471Sceastha /* 23*462be471Sceastha * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*462be471Sceastha * Use is subject to license terms. 25*462be471Sceastha */ 26*462be471Sceastha 277c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 287c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate 31*462be471Sceastha #pragma ident "%Z%%M% %I% %E% SMI" 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include "uucp.h" 347c478bd9Sstevel@tonic-gate 35*462be471Sceastha int 367c478bd9Sstevel@tonic-gate main(argc, argv) 377c478bd9Sstevel@tonic-gate int argc; 387c478bd9Sstevel@tonic-gate char **argv; 397c478bd9Sstevel@tonic-gate { 407c478bd9Sstevel@tonic-gate char fdgrade(); 417c478bd9Sstevel@tonic-gate DIR *machdir, *spooldir; 427c478bd9Sstevel@tonic-gate char machname[MAXFULLNAME]; 437c478bd9Sstevel@tonic-gate char file1[NAMESIZE+1], file2[NAMESIZE+1]; 447c478bd9Sstevel@tonic-gate struct cs_struct svdcfile; 457c478bd9Sstevel@tonic-gate int c; 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate (void) strcpy(Progname, "bnuconvert"); 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate Uid = getuid(); 507c478bd9Sstevel@tonic-gate Euid = geteuid(); 517c478bd9Sstevel@tonic-gate if (Uid == 0) 527c478bd9Sstevel@tonic-gate (void) setuid(UUCPUID); 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate while ((c = getopt(argc, argv, "x:")) != EOF) 557c478bd9Sstevel@tonic-gate switch(c) { 567c478bd9Sstevel@tonic-gate case 'x': 577c478bd9Sstevel@tonic-gate Debug = atoi(optarg); 587c478bd9Sstevel@tonic-gate if (Debug < 0) 597c478bd9Sstevel@tonic-gate Debug = 1; 607c478bd9Sstevel@tonic-gate break; 617c478bd9Sstevel@tonic-gate default: 627c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "usage: bnuconvert [-xLEVEL]\n"); 637c478bd9Sstevel@tonic-gate exit(-1); 647c478bd9Sstevel@tonic-gate } 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate DEBUG(5, "Progname (%s): STARTED\n", Progname); 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* find the default directory to queue to */ 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate if (eaccess(GRADES, 04) != -1) 717c478bd9Sstevel@tonic-gate svdcfile.grade = fdgrade(); 727c478bd9Sstevel@tonic-gate else 737c478bd9Sstevel@tonic-gate svdcfile.grade = D_QUEUE; 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate DEBUG(5, "All jobs will be placed in directory (%c) ", svdcfile.grade); 767c478bd9Sstevel@tonic-gate DEBUG(5, "under each remote name in the spool area.%c\n", NULLCHAR); 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate if ((spooldir = opendir(SPOOL)) == NULL) { 797c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "CAN'T OPEN (%s): errno (%d)\n", 807c478bd9Sstevel@tonic-gate SPOOL, errno); 817c478bd9Sstevel@tonic-gate exit(1); 827c478bd9Sstevel@tonic-gate } 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate while (gdirf(spooldir, file1, SPOOL)) { 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate (void) sprintf(Rmtname, "%s", file1); 877c478bd9Sstevel@tonic-gate (void) sprintf(machname, "%s/%s", SPOOL, file1); 887c478bd9Sstevel@tonic-gate DEBUG(9, "File1 is (%s)\n", file1); 897c478bd9Sstevel@tonic-gate DEBUG(9, "Rmtname is (%s)\n", Rmtname); 907c478bd9Sstevel@tonic-gate DEBUG(9, "Machname is (%s)\n", machname); 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate if (chdir(machname) != 0) { 937c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "CAN'T CHDIR (%s): errno (%d)\n", 947c478bd9Sstevel@tonic-gate machname, errno); 957c478bd9Sstevel@tonic-gate exit(1); 967c478bd9Sstevel@tonic-gate } 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate if ((machdir = opendir(machname)) == NULL) { 997c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "CAN'T OPEN (%s): errno (%d)\n", 1007c478bd9Sstevel@tonic-gate machname, errno); 1017c478bd9Sstevel@tonic-gate continue; 1027c478bd9Sstevel@tonic-gate } 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate DEBUG(7, "Directory: %s\n", machname); 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate while (gnamef(machdir, file2) == TRUE) { 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate DEBUG(9, "File read from (%s) ", machname); 1097c478bd9Sstevel@tonic-gate DEBUG(9, "is (%s)\n", file2); 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate if (!EQUALSN(file2, "C.",2)) 1127c478bd9Sstevel@tonic-gate continue; 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate /* build a saved C. file structure */ 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate (void) strncpy(svdcfile.file, file2, NAMESIZE-1); 1177c478bd9Sstevel@tonic-gate (void) sprintf(svdcfile.sys, "%s/%c", Rmtname, svdcfile.grade); 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate DEBUG(9, "Rmtname is (%s)\n", Rmtname); 1207c478bd9Sstevel@tonic-gate DEBUG(9, "Default directory to queue to is (%c)\n", svdcfile.grade); 1217c478bd9Sstevel@tonic-gate DEBUG(7, "Directory to queue to is (%s)\n", svdcfile.sys); 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate /* place any and all D. files related to the 1247c478bd9Sstevel@tonic-gate ** C. file in the proper spool area. 1257c478bd9Sstevel@tonic-gate */ 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate putdfiles(svdcfile); 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate /* Now queue the C. file */ 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate wfcommit(svdcfile.file, svdcfile.file, svdcfile.sys); 1327c478bd9Sstevel@tonic-gate } 1337c478bd9Sstevel@tonic-gate closedir(machdir); 1347c478bd9Sstevel@tonic-gate } 1357c478bd9Sstevel@tonic-gate closedir(spooldir); 136*462be471Sceastha return (0); 1377c478bd9Sstevel@tonic-gate } 1387c478bd9Sstevel@tonic-gate /* a dummy cleanup function to satisfy a .o file */ 1397c478bd9Sstevel@tonic-gate void cleanup() {} 140