]> andersk Git - moira.git/blame - reg_svr/genwords.pc
Command line printer manipulation client, and build goo.
[moira.git] / reg_svr / genwords.pc
CommitLineData
b9482d43 1/* $Id$
2 *
3 * Utility program to generate magic words for a given ID
4 *
5 * Copyright (C) 1998 by the Massachusetts Institute of Technology
6 * For copying and distribution information, please see the file
7 * <mit-copyright.h>.
8 *
9 */
10
11#include <mit-copyright.h>
12#include <moira.h>
13#include <moira_schema.h>
14#include "reg_svr.h"
15
16#include <stdio.h>
17#include <stdlib.h>
18
19EXEC SQL INCLUDE sqlca;
20
21RCSID("$Header$");
22
23int main(int argc, char **argv)
24{
25 char *words[6];
26 int verb;
27
28 if (argc > 1 && !strcmp(argv[1], "-v"))
29 {
30 verb++;
31 argv++;
32 argc--;
33 }
34
35 if (argc != 2)
36 {
37 fprintf(stderr, "Usage: genwords [-v] id\n");
38 exit(1);
39 }
40
41 if (!read_hmac_key())
42 {
43 fprintf(stderr, "Couldn't read hmac key\n");
44 exit(1);
45 }
46
47 getwordlist(argv[1], words);
48 if (verb)
49 {
50 EXEC SQL BEGIN DECLARE SECTION;
51 char first[USERS_FIRST_SIZE], middle[USERS_MIDDLE_SIZE];
52 char last[USERS_LAST_SIZE], *id, *database = "moira";
53 EXEC SQL END DECLARE SECTION;
54
55 EXEC SQL CONNECT :database IDENTIFIED BY :database;
56
57 id = argv[1];
58 EXEC SQL SELECT first, middle, last INTO :first, :middle, :last
59 FROM users WHERE clearid = :id;
60 if (sqlca.sqlcode)
61 {
62 sprintf(first, "%d", sqlca.sqlcode);
63 *middle = *last = '\0';
64 }
65 else
66 {
67 strtrim(first);
68 strtrim(middle);
69 strtrim(last);
70 }
71
1d9addc5 72 printf("(%s%s%s %s) (%s) (%s) (%s) (%s) (%s) (%s) (%s) dopage\n",
b9482d43 73 first, *middle ? " " : "", middle, last, id,
74 words[0], words[1], words[2], words[3], words[4], words[5]);
75 }
76 else
77 {
78 printf("%s %s %s %s %s %s\n", words[0], words[1], words[2],
79 words[3], words[4], words[5]);
80 }
81}
82
83/* used by words.c */
84void *xmalloc(size_t size)
85{
86 /* we won't run out of memory here */
87 return malloc(size);
88}
This page took 0.074184 seconds and 5 git commands to generate.