]> andersk Git - moira.git/commitdiff
Begone, Ctrl-Ms.
authorzacheiss <zacheiss>
Fri, 16 Oct 2009 16:23:10 +0000 (16:23 +0000)
committerzacheiss <zacheiss>
Fri, 16 Oct 2009 16:23:10 +0000 (16:23 +0000)
gen/cups-lpd.pc

index 5652f6a842d7eae08fadd6722def588ba12913e7..7f43a2f4c697684ca2c463c9ec58aaf56d27b255 100644 (file)
-/* $Id$\r
- *\r
- * This generates printcaps and other files for Athena print servers\r
- *\r
- * Copyright (C) 1992-1998 by the Massachusetts Institute of Technology.\r
- * For copying and distribution information, please see the file\r
- * <mit-copyright.h>.\r
- */\r
-\r
-#include <mit-copyright.h>\r
-#include <moira.h>\r
-#include <moira_site.h>\r
-\r
-#include <sys/stat.h>\r
-#include <sys/types.h>\r
-\r
-#include <ctype.h>\r
-#include <stdio.h>\r
-#include <string.h>\r
-\r
-#include <time.h>\r
-#ifdef HAVE_KRB4\r
-#include <krb.h>\r
-#endif\r
-#include <krb5.h>\r
-\r
-#include "util.h"\r
-\r
-EXEC SQL INCLUDE sqlca;\r
-\r
-RCSID("$Header$");\r
-\r
-char *whoami = "cups-lpd-print.gen";\r
-char *db = "moira/moira";\r
-\r
-/* OMG, I hate this, but it's cleaner, I guess? */\r
-\r
-void do_host(char *host);\r
-void sqlerr(void);\r
-#ifndef MAX\r
-#define MAX(a, b) ( (a) > (b) ? (a) : (b) )\r
-#endif\r
-\r
-int main(int argc, char **argv)\r
-{\r
-  EXEC SQL BEGIN DECLARE SECTION;\r
-  char name[MACHINE_NAME_SIZE];\r
-  EXEC SQL END DECLARE SECTION;\r
-\r
-  init_acls();\r
-\r
-  EXEC SQL CONNECT :db;\r
-\r
-  EXEC SQL WHENEVER SQLERROR DO sqlerr();\r
-\r
-  EXEC SQL DECLARE csr_hosts CURSOR FOR\r
-    SELECT m.name FROM machine m, serverhosts sh\r
-    WHERE m.mach_id = sh.mach_id AND sh.service = 'CUPS-LPD' AND sh.enable = 1;\r
-  EXEC SQL OPEN csr_hosts;\r
-  while (1)\r
-    {\r
-      EXEC SQL FETCH csr_hosts INTO :name;\r
-      if (sqlca.sqlcode)\r
-       break;\r
-\r
-      strtrim(name);\r
-      do_host(name);\r
-    }\r
-  EXEC SQL CLOSE csr_hosts;\r
-\r
-  exit(MR_SUCCESS);\r
-}\r
-\r
-void printer_user_list(FILE *out, char *type, int id, char *str)\r
-{\r
-  struct save_queue *sq;\r
-  struct imember *m;\r
-\r
-  sq = get_acl(type, id, NULL);\r
-  while (sq_remove_data(sq, &m))\r
-    {\r
-      if (m->type == 'U')\r
-        fprintf(out, "%s %s\n", str, m->name);\r
-      freeimember(m);\r
-    }\r
-  sq_destroy(sq);\r
-}\r
-\r
-\r
-\r
-void do_host(char *host)\r
-{\r
-  EXEC SQL BEGIN DECLARE SECTION;\r
-  char rp[PRINTERS_RP_SIZE], name[PRINTERS_NAME_SIZE];\r
-  char duplexname[PRINTERS_DUPLEXNAME_SIZE], location[PRINTERS_LOCATION_SIZE];\r
-  char hwtype[PRINTERS_HWTYPE_SIZE], lowerhwtype[PRINTERS_HWTYPE_SIZE];\r
-  char modtime[PRINTERS_MODTIME_SIZE], lmodtime[LIST_MODTIME_SIZE];\r
-  char contact[PRINTERS_CONTACT_SIZE], hostname[MACHINE_NAME_SIZE];\r
-  char cupshosts[MACHINE_NAME_SIZE], prtype [PRINTERS_TYPE_SIZE];\r
-  char *spoolhost = host, *unixtime_fmt = UNIXTIME_FMT, *p;\r
-  char *lhost;\r
-  int ka, pc, ac, lpc_acl, top_lpc_acl, banner, rm;\r
-  EXEC SQL END DECLARE SECTION;\r
-  TARFILE *tf;\r
-  FILE *out;\r
-  char filename[MAXPATHLEN], *duptc;\r
-  time_t mtime, now = time(NULL);\r
-\r
-  lhost = (char *) strdup (host);\r
-  for (p = lhost; *p; p++)\r
-     *p = tolower(*p);\r
-\r
-  sprintf(filename, "%s/cups-lpd/%s", DCM_DIR, host);\r
-  tf = tarfile_open(filename);\r
-\r
-  /* LPRng printers */\r
-  out = tarfile_start(tf, "/etc/cups/lprng.printers.txt", 0644, 0, 0,\r
-                     "root", "lp", now);\r
-\r
-  EXEC SQL DECLARE csr_lprng CURSOR FOR\r
-    SELECT pr.rp, pr.name, pr.duplexname, pr.hwtype,\r
-    m.name, pr.banner, pr.location, pr.contact, pr.ka,\r
-    pr.ac, pr.type as prtype\r
-    FROM printers pr, machine m, serverhosts sh\r
-    WHERE m.mach_id = sh.mach_id AND sh.service = 'PRINT' AND sh.enable = 1\r
-    AND pr.rm = m.mach_id ORDER BY pr.name;\r
-  EXEC SQL OPEN csr_lprng;\r
-  while (1)\r
-    {\r
-      EXEC SQL FETCH csr_lprng INTO :rp, :name, :duplexname,\r
-       :hwtype, :hostname, :banner, :location, :contact, :ka, :ac, :prtype;\r
-      if (sqlca.sqlcode)\r
-       break;\r
-\r
-      strtrim(rp);\r
-      strtrim(name);\r
-      strtrim(duplexname);\r
-      strtrim(hwtype);\r
-      strtrim(hostname);\r
-      strtrim(location);\r
-      strtrim(contact);\r
-      strcpy(lowerhwtype, hwtype);\r
-      for (p = lowerhwtype; *p; p++)\r
-       *p = tolower(*p);\r
-      for (p = name;*p;p++)\r
-       *p = tolower(*p);\r
-      for (p = duplexname;*p;p++)\r
-       *p = tolower(*p);\r
-\r
-      fprintf(out, "%s|%s|%s|%s|%s|%s\n", name,duplexname,hostname,location,hwtype,prtype);\r
-    }\r
-  EXEC SQL CLOSE csr_lprng;\r
-  tarfile_end(tf);\r
-\r
-  /* CUPS printers */\r
-  out = tarfile_start(tf, "/etc/cups/cups.printers.txt", 0644, 0, 0,\r
-                     "root", "lp", now);\r
-\r
-  EXEC SQL DECLARE csr_cups CURSOR FOR\r
-    SELECT pr.rp, pr.name, pr.duplexname, pr.hwtype,\r
-    m.name, pr.banner, pr.location, pr.contact, pr.ka,\r
-    pr.ac, pr.type as prtype\r
-    FROM printers pr, machine m, serverhosts sh\r
-    WHERE m.mach_id = sh.mach_id AND sh.service = 'CUPS-PRINT' AND sh.enable = 1\r
-    AND pr.rm = m.mach_id ORDER BY pr.name;\r
-  EXEC SQL OPEN csr_cups;\r
-  while (1)\r
-    {\r
-      EXEC SQL FETCH csr_cups INTO :rp, :name, :duplexname,\r
-       :hwtype, :hostname, :banner, :location, :contact, :ka, :ac, :prtype;\r
-      if (sqlca.sqlcode)\r
-       break;\r
-\r
-      strtrim(rp);\r
-      strtrim(name);\r
-      strtrim(duplexname);\r
-      strtrim(hwtype);\r
-      strtrim(hostname);\r
-      strtrim(location);\r
-      strtrim(contact);\r
-      strcpy(lowerhwtype, hwtype);\r
-      for (p = lowerhwtype; *p; p++)\r
-       *p = tolower(*p);\r
-      for (p = name;*p;p++)\r
-       *p = tolower(*p);\r
-      for (p = duplexname;*p;p++)\r
-       *p = tolower(*p);\r
-\r
-      fprintf(out, "%s|%s|%s|%s|%s|%s\n", name,duplexname,hostname,location,hwtype,prtype);\r
-    }\r
-  EXEC SQL CLOSE csr_cups;\r
-  tarfile_end(tf);\r
-  tarfile_close(tf);\r
-}\r
-\r
-void sqlerr(void)\r
-{\r
-  db_error(sqlca.sqlcode);\r
-}\r
+/* $Id$
+ *
+ * This generates printcaps and other files for Athena print servers
+ *
+ * Copyright (C) 1992-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
+ */
+
+#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <time.h>
+#ifdef HAVE_KRB4
+#include <krb.h>
+#endif
+#include <krb5.h>
+
+#include "util.h"
+
+EXEC SQL INCLUDE sqlca;
+
+RCSID("$Header$");
+
+char *whoami = "cups-lpd-print.gen";
+char *db = "moira/moira";
+
+/* OMG, I hate this, but it's cleaner, I guess? */
+
+void do_host(char *host);
+void sqlerr(void);
+#ifndef MAX
+#define MAX(a, b) ( (a) > (b) ? (a) : (b) )
+#endif
+
+int main(int argc, char **argv)
+{
+  EXEC SQL BEGIN DECLARE SECTION;
+  char name[MACHINE_NAME_SIZE];
+  EXEC SQL END DECLARE SECTION;
+
+  init_acls();
+
+  EXEC SQL CONNECT :db;
+
+  EXEC SQL WHENEVER SQLERROR DO sqlerr();
+
+  EXEC SQL DECLARE csr_hosts CURSOR FOR
+    SELECT m.name FROM machine m, serverhosts sh
+    WHERE m.mach_id = sh.mach_id AND sh.service = 'CUPS-LPD' AND sh.enable = 1;
+  EXEC SQL OPEN csr_hosts;
+  while (1)
+    {
+      EXEC SQL FETCH csr_hosts INTO :name;
+      if (sqlca.sqlcode)
+       break;
+
+      strtrim(name);
+      do_host(name);
+    }
+  EXEC SQL CLOSE csr_hosts;
+
+  exit(MR_SUCCESS);
+}
+
+void printer_user_list(FILE *out, char *type, int id, char *str)
+{
+  struct save_queue *sq;
+  struct imember *m;
+
+  sq = get_acl(type, id, NULL);
+  while (sq_remove_data(sq, &m))
+    {
+      if (m->type == 'U')
+        fprintf(out, "%s %s\n", str, m->name);
+      freeimember(m);
+    }
+  sq_destroy(sq);
+}
+
+
+
+void do_host(char *host)
+{
+  EXEC SQL BEGIN DECLARE SECTION;
+  char rp[PRINTERS_RP_SIZE], name[PRINTERS_NAME_SIZE];
+  char duplexname[PRINTERS_DUPLEXNAME_SIZE], location[PRINTERS_LOCATION_SIZE];
+  char hwtype[PRINTERS_HWTYPE_SIZE], lowerhwtype[PRINTERS_HWTYPE_SIZE];
+  char modtime[PRINTERS_MODTIME_SIZE], lmodtime[LIST_MODTIME_SIZE];
+  char contact[PRINTERS_CONTACT_SIZE], hostname[MACHINE_NAME_SIZE];
+  char cupshosts[MACHINE_NAME_SIZE], prtype [PRINTERS_TYPE_SIZE];
+  char *spoolhost = host, *unixtime_fmt = UNIXTIME_FMT, *p;
+  char *lhost;
+  int ka, pc, ac, lpc_acl, top_lpc_acl, banner, rm;
+  EXEC SQL END DECLARE SECTION;
+  TARFILE *tf;
+  FILE *out;
+  char filename[MAXPATHLEN], *duptc;
+  time_t mtime, now = time(NULL);
+
+  lhost = (char *) strdup (host);
+  for (p = lhost; *p; p++)
+     *p = tolower(*p);
+
+  sprintf(filename, "%s/cups-lpd/%s", DCM_DIR, host);
+  tf = tarfile_open(filename);
+
+  /* LPRng printers */
+  out = tarfile_start(tf, "/etc/cups/lprng.printers.txt", 0644, 0, 0,
+                     "root", "lp", now);
+
+  EXEC SQL DECLARE csr_lprng CURSOR FOR
+    SELECT pr.rp, pr.name, pr.duplexname, pr.hwtype,
+    m.name, pr.banner, pr.location, pr.contact, pr.ka,
+    pr.ac, pr.type as prtype
+    FROM printers pr, machine m, serverhosts sh
+    WHERE m.mach_id = sh.mach_id AND sh.service = 'PRINT' AND sh.enable = 1
+    AND pr.rm = m.mach_id ORDER BY pr.name;
+  EXEC SQL OPEN csr_lprng;
+  while (1)
+    {
+      EXEC SQL FETCH csr_lprng INTO :rp, :name, :duplexname,
+       :hwtype, :hostname, :banner, :location, :contact, :ka, :ac, :prtype;
+      if (sqlca.sqlcode)
+       break;
+
+      strtrim(rp);
+      strtrim(name);
+      strtrim(duplexname);
+      strtrim(hwtype);
+      strtrim(hostname);
+      strtrim(location);
+      strtrim(contact);
+      strcpy(lowerhwtype, hwtype);
+      for (p = lowerhwtype; *p; p++)
+       *p = tolower(*p);
+      for (p = name;*p;p++)
+       *p = tolower(*p);
+      for (p = duplexname;*p;p++)
+       *p = tolower(*p);
+
+      fprintf(out, "%s|%s|%s|%s|%s|%s\n", name,duplexname,hostname,location,hwtype,prtype);
+    }
+  EXEC SQL CLOSE csr_lprng;
+  tarfile_end(tf);
+
+  /* CUPS printers */
+  out = tarfile_start(tf, "/etc/cups/cups.printers.txt", 0644, 0, 0,
+                     "root", "lp", now);
+
+  EXEC SQL DECLARE csr_cups CURSOR FOR
+    SELECT pr.rp, pr.name, pr.duplexname, pr.hwtype,
+    m.name, pr.banner, pr.location, pr.contact, pr.ka,
+    pr.ac, pr.type as prtype
+    FROM printers pr, machine m, serverhosts sh
+    WHERE m.mach_id = sh.mach_id AND sh.service = 'CUPS-PRINT' AND sh.enable = 1
+    AND pr.rm = m.mach_id ORDER BY pr.name;
+  EXEC SQL OPEN csr_cups;
+  while (1)
+    {
+      EXEC SQL FETCH csr_cups INTO :rp, :name, :duplexname,
+       :hwtype, :hostname, :banner, :location, :contact, :ka, :ac, :prtype;
+      if (sqlca.sqlcode)
+       break;
+
+      strtrim(rp);
+      strtrim(name);
+      strtrim(duplexname);
+      strtrim(hwtype);
+      strtrim(hostname);
+      strtrim(location);
+      strtrim(contact);
+      strcpy(lowerhwtype, hwtype);
+      for (p = lowerhwtype; *p; p++)
+       *p = tolower(*p);
+      for (p = name;*p;p++)
+       *p = tolower(*p);
+      for (p = duplexname;*p;p++)
+       *p = tolower(*p);
+
+      fprintf(out, "%s|%s|%s|%s|%s|%s\n", name,duplexname,hostname,location,hwtype,prtype);
+    }
+  EXEC SQL CLOSE csr_cups;
+  tarfile_end(tf);
+  tarfile_close(tf);
+}
+
+void sqlerr(void)
+{
+  db_error(sqlca.sqlcode);
+}
This page took 0.071953 seconds and 5 git commands to generate.