remove xvm/ipagent
[unleashed.git] / usr / src / cmd / bnu / bnuconvert.c
blob873ae0d0447f0cdb4a897b85643ca8cbfafe89e9
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 #pragma ident "%Z%%M% %I% %E% SMI"
33 #include "uucp.h"
35 int
36 main(argc, argv)
37 int argc;
38 char **argv;
40 char fdgrade();
41 DIR *machdir, *spooldir;
42 char machname[MAXFULLNAME];
43 char file1[NAMESIZE+1], file2[NAMESIZE+1];
44 struct cs_struct svdcfile;
45 int c;
47 (void) strcpy(Progname, "bnuconvert");
49 Uid = getuid();
50 Euid = geteuid();
51 if (Uid == 0)
52 (void) setuid(UUCPUID);
54 while ((c = getopt(argc, argv, "x:")) != EOF)
55 switch(c) {
56 case 'x':
57 Debug = atoi(optarg);
58 if (Debug < 0)
59 Debug = 1;
60 break;
61 default:
62 (void) fprintf(stderr, "usage: bnuconvert [-xLEVEL]\n");
63 exit(-1);
66 DEBUG(5, "Progname (%s): STARTED\n", Progname);
68 /* find the default directory to queue to */
70 if (eaccess(GRADES, 04) != -1)
71 svdcfile.grade = fdgrade();
72 else
73 svdcfile.grade = D_QUEUE;
75 DEBUG(5, "All jobs will be placed in directory (%c) ", svdcfile.grade);
76 DEBUG(5, "under each remote name in the spool area.%c\n", NULLCHAR);
78 if ((spooldir = opendir(SPOOL)) == NULL) {
79 (void) fprintf(stderr, "CAN'T OPEN (%s): errno (%d)\n",
80 SPOOL, errno);
81 exit(1);
84 while (gdirf(spooldir, file1, SPOOL)) {
86 (void) sprintf(Rmtname, "%s", file1);
87 (void) sprintf(machname, "%s/%s", SPOOL, file1);
88 DEBUG(9, "File1 is (%s)\n", file1);
89 DEBUG(9, "Rmtname is (%s)\n", Rmtname);
90 DEBUG(9, "Machname is (%s)\n", machname);
92 if (chdir(machname) != 0) {
93 (void) fprintf(stderr, "CAN'T CHDIR (%s): errno (%d)\n",
94 machname, errno);
95 exit(1);
98 if ((machdir = opendir(machname)) == NULL) {
99 (void) fprintf(stderr, "CAN'T OPEN (%s): errno (%d)\n",
100 machname, errno);
101 continue;
104 DEBUG(7, "Directory: %s\n", machname);
106 while (gnamef(machdir, file2) == TRUE) {
108 DEBUG(9, "File read from (%s) ", machname);
109 DEBUG(9, "is (%s)\n", file2);
111 if (!EQUALSN(file2, "C.",2))
112 continue;
114 /* build a saved C. file structure */
116 (void) strncpy(svdcfile.file, file2, NAMESIZE-1);
117 (void) sprintf(svdcfile.sys, "%s/%c", Rmtname, svdcfile.grade);
119 DEBUG(9, "Rmtname is (%s)\n", Rmtname);
120 DEBUG(9, "Default directory to queue to is (%c)\n", svdcfile.grade);
121 DEBUG(7, "Directory to queue to is (%s)\n", svdcfile.sys);
123 /* place any and all D. files related to the
124 ** C. file in the proper spool area.
127 putdfiles(svdcfile);
129 /* Now queue the C. file */
131 wfcommit(svdcfile.file, svdcfile.file, svdcfile.sys);
133 closedir(machdir);
135 closedir(spooldir);
136 return (0);
138 /* a dummy cleanup function to satisfy a .o file */
139 void cleanup() {}