]> andersk Git - moira.git/blobdiff - gen/dhcp.pc
New strategy: use Pro*C so it's less absymally slow.
[moira.git] / gen / dhcp.pc
index ebdfba55a37664dc8f6006ecfd2b37586bce7258..31c49cc1f0875161fb2b9172441fde0cdc098d5a 100644 (file)
@@ -62,14 +62,22 @@ int main(int argc, char **argv)
 
   EXEC SQL WHENEVER SQLERROR DO sqlerr();
 
+  if (argc != 2)
+    {
+      fprintf(stderr, "usage: %s [outfile]\n", argv[0]);
+      exit(MR_ARGS);
+    }
+
   /* Get print spoolers for allow lists. */
-  EXEC SQL SELECT COUNT(service) INTO :alcount FROM serverhosts
-    WHERE service = 'PRINT';
+  EXEC SQL SELECT COUNT(service) INTO :alcount FROM serverhosts sh, machine m
+    WHERE sh.service = 'PRINT' AND sh.mach_id = m.mach_id 
+    AND m.status = 1 AND m.address != 'unassigned';
   allowlist = malloc(alcount * sizeof(*allowlist));
 
   EXEC SQL DECLARE csr_spool CURSOR FOR
     SELECT m.address, sh.value3 FROM machine m, serverhosts sh
-    WHERE m.mach_id = sh.mach_id AND sh.service = 'PRINT';
+    WHERE m.mach_id = sh.mach_id AND sh.service = 'PRINT'
+    AND m.status = 1 AND m.address != 'unassigned';
   EXEC SQL OPEN csr_spool;
   for (i = 0; i < alcount; i++)
     {
@@ -82,8 +90,7 @@ int main(int argc, char **argv)
   EXEC SQL CLOSE csr_spool;
 
   /* Now build the tar file. */
-  sprintf(filename, "%s/dhcp.out", DCM_DIR);
-  tf = tarfile_open(filename);
+  tf = tarfile_open(argv[1]);
 
   /* Build dhcpd.conf.print */
 
This page took 0.105354 seconds and 4 git commands to generate.