2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: DtPrintinfo.C /main/6 1998/07/24 16:10:28 mgreess $ */
24 // User Interface headers
26 #include "DtPrinterIcon.h"
31 #include <Dt/EnvControlP.h>
37 #include "PrintSubSys.h"
40 #include "dtprintinfomsg.h"
41 nl_catd dtprintinfo_cat = NULL;
43 #include <stdlib.h> // This is for the getenv function
44 #include <unistd.h> // This is for the getuid function
48 #if defined(aix) || defined(USL) || defined(__uxp__)
49 extern "C" { extern int seteuid(uid_t); }
53 static char **msg_strings = NULL;
55 // Cannot use multiple catgets paramemter calls in functions because the
56 // previous catgets returned value is overwritten by later catgets calls
57 // Example: this would fail on HP systems
58 // sprintf(buf, "%s %s" catgets(...), catgets(...))
60 char *Catgets(nl_catd catd, int set_num, int msg_num, char *s)
65 if (!msg_strings[msg_num])
66 msg_strings[msg_num] = strdup(catgets(catd, set_num, msg_num, s));
67 return msg_strings[msg_num];
71 int main(int argc, char **argv)
74 _DtEnvControl(DT_ENV_SET);
79 setresuid(getuid(), getuid(), (uid_t)0);
84 setlocale(LC_ALL, "");
86 char *lang = getenv("LANG");
87 if (lang && strcmp(lang, "C"))
92 dtprintinfo_cat = catopen("dtprintinfo", NL_CAT_LOCALE);
94 dtprintinfo_cat = catopen("dtprintinfo", 0);
98 dtprintinfo_cat = (nl_catd) -1;
101 msg_strings = (char **)calloc(LAST_MSG_NO, sizeof(char *));
105 if (dtprintinfo_cat == NULL) {
106 dtprintinfo_cat = (nl_catd) -1;
109 if (!STRCMP(argv[1], "-help"))
112 char *cmd = new char [strlen(LIST_QUEUES) + 30];
113 sprintf(cmd, "%s | awk '{print \"\\t\", $1}'", LIST_QUEUES);
114 Invoke *_thread = new Invoke(cmd, &output);
115 printf(MESSAGE(CommandLineHelpL), output);
123 char *progname = strrchr(argv[0], '/');
128 if (!STRCMP(argv[1], "-populate"))
132 fprintf(stderr, MESSAGE(RootUserL), progname, "-populate");
133 fprintf(stderr, "\n");
137 PrintSubSystem *prt = new PrintSubSystem(NULL);
138 int n_queues = prt->NumChildren();
139 // Get Print Subsystem children, (these are queues)
140 Queue **queues = (Queue **)prt->Children();
142 for (i = 0; i < n_queues; i++)
144 DtPrinterIcon *icon = new DtPrinterIcon(NULL, NULL, queues[i],
145 INITIALIZE_PRINTERS);
146 icon->CreateActionFile();
152 DtApp *app = new DtApp(progname, &argc, argv);