]> andersk Git - moira.git/blobdiff - gen/www.pc
Once more.
[moira.git] / gen / www.pc
index bdd36f3fbea943578aed33b74486b2df8490cbe5..db0529a4a55a2150d59a47828bb9359bc7ae3f89 100644 (file)
@@ -55,7 +55,6 @@ int main(int argc, char **argv)
   FILE *outfsf;
   struct stat sb;
   char *c;
-  int flag;
 
   initialize_sms_error_table();
 
@@ -106,61 +105,38 @@ int main(int argc, char **argv)
   sprintf(wkgrp, "%s/group~", www_dir);
   sprintf(wkfs, "%s/filsys~", www_dir);
 
-  flag = 0;
-  if (stat(outfs, &sb) == 0)
+  fprintf(stderr, "%s: building fs database...\n", whoami);
+  if (!(outfsf = fopen(wkfs, "w")))
     {
-      if (ModDiff (&flag, "filesys", sb.st_mtime))
-        exit(MR_DATE);
+      fprintf(stderr, "%s: cannot open %s for writing (%s)\n", whoami,
+             wkfs, strerror(errno));
+      exit(MR_OCONFIG);
     }
-  if (flag < 0)
-    fprintf(stderr, "%s: %s does not need to be rebuilt.\n", whoami, outfs);
-  else
+  filsys(outfsf);
+  if (fclose(outfsf))
     {
-      fprintf(stderr, "%s: building fs database...\n", whoami);
-      if (!(outfsf = fopen(wkfs, "w")))
-       {
-         fprintf(stderr, "%s: cannot open %s for writing (%s)\n", whoami,
-                 wkfs, strerror(errno));
-         exit(MR_OCONFIG);
-       }
-      filsys(outfsf);
-      if (fclose(outfsf))
-       {
-         fprintf(stderr, "%s: close of %s failed (%s)", whoami,
-                 wkfs, strerror(errno));
-         exit(MR_CCONFIG);
-       }
-      fix_file(outfs);
+      fprintf(stderr, "%s: close of %s failed (%s)", whoami,
+             wkfs, strerror(errno));
+      exit(MR_CCONFIG);
     }
+  fix_file(outfs);
 
-  flag = 0;
-  if (stat(outgrp, &sb) == 0)
+  fprintf(stderr, "%s: building group database...\n", whoami);
+  if (!(outgrpf = fopen(wkgrp, "w")))
     {
-      if (ModDiff (&flag, "list", sb.st_mtime) ||
-         ModDiff (&flag, "users", sb.st_mtime))
-        exit(MR_DATE);
+      fprintf(stderr, "%s: cannot open %s for writing (%s)\n", whoami,
+             wkgrp, strerror(errno));
+      exit(MR_OCONFIG);
     }
-  if (flag < 0)
-    fprintf(stderr, "%s: %s does not need to be rebuilt.\n", whoami, outgrp);
-  else
+  group(outgrpf);
+  if (fclose(outgrpf))
     {
-      fprintf(stderr, "%s: building group database...\n", whoami);
-      if (!(outgrpf = fopen(wkgrp, "w")))
-       {
-         fprintf(stderr, "%s: cannot open %s for writing (%s)\n", whoami,
-                 wkgrp, strerror(errno));
-         exit(MR_OCONFIG);
-       }
-      group(outgrpf);
-      if (fclose(outgrpf))
-       {
-         fprintf(stderr, "%s: close of %s failed (%s)", whoami, wkgrp,
-                 strerror(errno));
-         exit(MR_CCONFIG);
-       }
-      fix_file(outgrp);
+      fprintf(stderr, "%s: close of %s failed (%s)", whoami, wkgrp,
+             strerror(errno));
+      exit(MR_CCONFIG);
     }
-
+  fix_file(outgrp);
+  
   fprintf(stderr, "%s: building tar file...\n", whoami);
   sprintf(cmd, "(cd %s; tar cf - . ) > %s.out", www_dir, www_dir);
   if (system(cmd))
@@ -175,6 +151,7 @@ void filsys(FILE *out)
   EXEC SQL BEGIN DECLARE SECTION;
   char label[FILESYS_LABEL_SIZE], path[FILESYS_NAME_SIZE];
   char type[FILESYS_TYPE_SIZE], key[FSGROUP_KEY_SIZE];
+  char alias[ALIAS_NAME_SIZE];
   int status, fid;
   EXEC SQL END DECLARE SECTION;
 
@@ -207,9 +184,30 @@ void filsys(FILE *out)
          EXEC SQL CLOSE group_cursor;
        }
 
+      EXEC SQL DECLARE alias_cursor CURSOR FOR
+       SELECT name INTO :alias FROM alias
+       WHERE type='FILESYS' AND trans=:label;
+
       if (!*strtrim(path))
        continue;
+      for (c = label; *c; c++)
+       *c = tolower(*c);
       fprintf(out, "%s:%s\n", label, path);
+
+      EXEC SQL OPEN alias_cursor;
+      while (1)
+       {
+         EXEC SQL FETCH alias_cursor INTO :alias;
+         if (sqlca.sqlcode)
+           break;
+         
+         if (!*strtrim(alias))
+           continue;
+         for (c = alias; *c; c++)
+           *c = tolower(*c);
+         fprintf(out, "%s:%s\n", alias, path);
+       }
+      EXEC SQL CLOSE alias_cursor;
     }
 
   EXEC SQL CLOSE filsys_cursor;
@@ -236,7 +234,7 @@ void group(FILE *out)
   EXEC SQL WHENEVER SQLERROR GOTO sqlerr;
 
   EXEC SQL DECLARE user_cursor CURSOR FOR
-    SELECT login FROM users WHERE status=1 OR status=2 OR status=6 
+    SELECT login FROM users WHERE status=1 OR status=2 OR status=6 OR status=9
     ORDER by login;
   EXEC SQL OPEN user_cursor;
 
This page took 0.043155 seconds and 4 git commands to generate.