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 */
22462be471Sceastha /*
23462be471Sceastha * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24462be471Sceastha * Use is subject to license terms.
25462be471Sceastha */
26462be471Sceastha
277c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
287c478bd9Sstevel@tonic-gate /* All Rights Reserved */
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate #include "uucp.h"
317c478bd9Sstevel@tonic-gate
32462be471Sceastha int
main(argc,argv)337c478bd9Sstevel@tonic-gate main(argc, argv)
347c478bd9Sstevel@tonic-gate int argc;
357c478bd9Sstevel@tonic-gate char **argv;
367c478bd9Sstevel@tonic-gate {
377c478bd9Sstevel@tonic-gate char fdgrade();
387c478bd9Sstevel@tonic-gate DIR *machdir, *spooldir;
397c478bd9Sstevel@tonic-gate char machname[MAXFULLNAME];
407c478bd9Sstevel@tonic-gate char file1[NAMESIZE+1], file2[NAMESIZE+1];
417c478bd9Sstevel@tonic-gate struct cs_struct svdcfile;
427c478bd9Sstevel@tonic-gate int c;
437c478bd9Sstevel@tonic-gate
447c478bd9Sstevel@tonic-gate (void) strcpy(Progname, "bnuconvert");
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gate Uid = getuid();
477c478bd9Sstevel@tonic-gate Euid = geteuid();
487c478bd9Sstevel@tonic-gate if (Uid == 0)
497c478bd9Sstevel@tonic-gate (void) setuid(UUCPUID);
507c478bd9Sstevel@tonic-gate
517c478bd9Sstevel@tonic-gate while ((c = getopt(argc, argv, "x:")) != EOF)
527c478bd9Sstevel@tonic-gate switch(c) {
537c478bd9Sstevel@tonic-gate case 'x':
547c478bd9Sstevel@tonic-gate Debug = atoi(optarg);
557c478bd9Sstevel@tonic-gate if (Debug < 0)
567c478bd9Sstevel@tonic-gate Debug = 1;
577c478bd9Sstevel@tonic-gate break;
587c478bd9Sstevel@tonic-gate default:
597c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "usage: bnuconvert [-xLEVEL]\n");
607c478bd9Sstevel@tonic-gate exit(-1);
617c478bd9Sstevel@tonic-gate }
627c478bd9Sstevel@tonic-gate
637c478bd9Sstevel@tonic-gate DEBUG(5, "Progname (%s): STARTED\n", Progname);
647c478bd9Sstevel@tonic-gate
657c478bd9Sstevel@tonic-gate /* find the default directory to queue to */
667c478bd9Sstevel@tonic-gate
67*2a8bcb4eSToomas Soome if (eaccess(GRADES, 04) != -1)
687c478bd9Sstevel@tonic-gate svdcfile.grade = fdgrade();
69*2a8bcb4eSToomas Soome else
707c478bd9Sstevel@tonic-gate svdcfile.grade = D_QUEUE;
717c478bd9Sstevel@tonic-gate
727c478bd9Sstevel@tonic-gate DEBUG(5, "All jobs will be placed in directory (%c) ", svdcfile.grade);
737c478bd9Sstevel@tonic-gate DEBUG(5, "under each remote name in the spool area.%c\n", NULLCHAR);
747c478bd9Sstevel@tonic-gate
757c478bd9Sstevel@tonic-gate if ((spooldir = opendir(SPOOL)) == NULL) {
767c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "CAN'T OPEN (%s): errno (%d)\n",
777c478bd9Sstevel@tonic-gate SPOOL, errno);
787c478bd9Sstevel@tonic-gate exit(1);
797c478bd9Sstevel@tonic-gate }
807c478bd9Sstevel@tonic-gate
817c478bd9Sstevel@tonic-gate while (gdirf(spooldir, file1, SPOOL)) {
827c478bd9Sstevel@tonic-gate
837c478bd9Sstevel@tonic-gate (void) sprintf(Rmtname, "%s", file1);
847c478bd9Sstevel@tonic-gate (void) sprintf(machname, "%s/%s", SPOOL, file1);
857c478bd9Sstevel@tonic-gate DEBUG(9, "File1 is (%s)\n", file1);
867c478bd9Sstevel@tonic-gate DEBUG(9, "Rmtname is (%s)\n", Rmtname);
877c478bd9Sstevel@tonic-gate DEBUG(9, "Machname is (%s)\n", machname);
887c478bd9Sstevel@tonic-gate
897c478bd9Sstevel@tonic-gate if (chdir(machname) != 0) {
907c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "CAN'T CHDIR (%s): errno (%d)\n",
917c478bd9Sstevel@tonic-gate machname, errno);
927c478bd9Sstevel@tonic-gate exit(1);
937c478bd9Sstevel@tonic-gate }
947c478bd9Sstevel@tonic-gate
957c478bd9Sstevel@tonic-gate if ((machdir = opendir(machname)) == NULL) {
967c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "CAN'T OPEN (%s): errno (%d)\n",
977c478bd9Sstevel@tonic-gate machname, errno);
987c478bd9Sstevel@tonic-gate continue;
997c478bd9Sstevel@tonic-gate }
1007c478bd9Sstevel@tonic-gate
1017c478bd9Sstevel@tonic-gate DEBUG(7, "Directory: %s\n", machname);
1027c478bd9Sstevel@tonic-gate
1037c478bd9Sstevel@tonic-gate while (gnamef(machdir, file2) == TRUE) {
1047c478bd9Sstevel@tonic-gate
1057c478bd9Sstevel@tonic-gate DEBUG(9, "File read from (%s) ", machname);
1067c478bd9Sstevel@tonic-gate DEBUG(9, "is (%s)\n", file2);
1077c478bd9Sstevel@tonic-gate
1087c478bd9Sstevel@tonic-gate if (!EQUALSN(file2, "C.",2))
1097c478bd9Sstevel@tonic-gate continue;
1107c478bd9Sstevel@tonic-gate
1117c478bd9Sstevel@tonic-gate /* build a saved C. file structure */
1127c478bd9Sstevel@tonic-gate
1137c478bd9Sstevel@tonic-gate (void) strncpy(svdcfile.file, file2, NAMESIZE-1);
1147c478bd9Sstevel@tonic-gate (void) sprintf(svdcfile.sys, "%s/%c", Rmtname, svdcfile.grade);
1157c478bd9Sstevel@tonic-gate
1167c478bd9Sstevel@tonic-gate DEBUG(9, "Rmtname is (%s)\n", Rmtname);
1177c478bd9Sstevel@tonic-gate DEBUG(9, "Default directory to queue to is (%c)\n", svdcfile.grade);
1187c478bd9Sstevel@tonic-gate DEBUG(7, "Directory to queue to is (%s)\n", svdcfile.sys);
1197c478bd9Sstevel@tonic-gate
1207c478bd9Sstevel@tonic-gate /* place any and all D. files related to the
1217c478bd9Sstevel@tonic-gate ** C. file in the proper spool area.
1227c478bd9Sstevel@tonic-gate */
1237c478bd9Sstevel@tonic-gate
1247c478bd9Sstevel@tonic-gate putdfiles(svdcfile);
1257c478bd9Sstevel@tonic-gate
1267c478bd9Sstevel@tonic-gate /* Now queue the C. file */
1277c478bd9Sstevel@tonic-gate
1287c478bd9Sstevel@tonic-gate wfcommit(svdcfile.file, svdcfile.file, svdcfile.sys);
1297c478bd9Sstevel@tonic-gate }
1307c478bd9Sstevel@tonic-gate closedir(machdir);
1317c478bd9Sstevel@tonic-gate }
1327c478bd9Sstevel@tonic-gate closedir(spooldir);
133462be471Sceastha return (0);
1347c478bd9Sstevel@tonic-gate }
1357c478bd9Sstevel@tonic-gate /* a dummy cleanup function to satisfy a .o file */
cleanup()1367c478bd9Sstevel@tonic-gate void cleanup() {}
137