3 * This generates a list of everyone's poboxes for the mitdir.
5 * Copyright (C) 1992-1998 by the Massachusetts Institute of Technology.
6 * For copying and distribution information, please see the file
10 #include <mit-copyright.h>
14 #include <sys/types.h>
22 EXEC SQL INCLUDE sqlca;
26 char *whoami = "pobox.gen";
27 char *db = "moira/moira";
29 int main(int argc, char **argv)
32 char *outf = NULL, outft[MAXPATHLEN];
34 EXEC SQL BEGIN DECLARE SECTION;
35 char login[USERS_LOGIN_SIZE], id[USERS_CLEARID_SIZE];
36 char string[STRINGS_STRING_SIZE];
37 EXEC SQL END DECLARE SECTION;
44 sprintf(outft, "%s~", outf);
45 if (!(out = fopen(outft, "w")))
47 fprintf(stderr, "unable to open %s for output\n", outf);
53 fprintf(stderr, "usage: %s [outfile]\n", argv[0]);
59 /* The following is declarative, not executed,
60 * and so is dependent on where it is in the file,
61 * not in the order of execution of statements.
63 EXEC SQL WHENEVER SQLERROR GOTO sqlerr;
65 EXEC SQL DECLARE x CURSOR FOR SELECT
67 FROM users WHERE status != 3 AND potype != 'NONE';
71 EXEC SQL FETCH x INTO :id, :login;
77 fprintf(out, "%s %s@MIT.EDU\n", id, login);
86 perror("close failed");
94 db_error(sqlca.sqlcode);