1 | /* |
---|
2 | * |
---|
3 | * Copyright (C) 1988, 1989 by the Massachusetts Institute of Technology |
---|
4 | * Developed by the MIT Student Information Processing Board (SIPB). |
---|
5 | * For copying information, see the file mit-copyright.h in this release. |
---|
6 | * |
---|
7 | */ |
---|
8 | /* |
---|
9 | * $Source: /afs/dev.mit.edu/source/repository/athena/bin/discuss/mclient/crmtgs.c,v $ |
---|
10 | * $Header: /afs/dev.mit.edu/source/repository/athena/bin/discuss/mclient/crmtgs.c,v 1.4 1989-06-03 00:30:40 srz Exp $ |
---|
11 | * |
---|
12 | * Fill out a .meetings file with the primary name of all the |
---|
13 | * meetings in it. This requires that the meeting be accessible |
---|
14 | * at this time; however, this program may be run several times |
---|
15 | * to get it right.. |
---|
16 | * |
---|
17 | * $Log: not supported by cvs2svn $ |
---|
18 | * Revision 1.3 89/01/05 07:14:35 raeburn |
---|
19 | * replaced included header files with <discuss/discuss.h> |
---|
20 | * |
---|
21 | * Revision 1.2 88/09/23 23:55:27 raeburn |
---|
22 | * Added declaration of getenv(), to satisfy prototypes of functions. |
---|
23 | * |
---|
24 | * Revision 1.1 87/04/08 04:00:53 wesommer |
---|
25 | * Initial revision |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | #ifndef lint |
---|
30 | static char rcsid_crmtgs_c[] = |
---|
31 | "$Header: /afs/dev.mit.edu/source/repository/athena/bin/discuss/mclient/crmtgs.c,v 1.4 1989-06-03 00:30:40 srz Exp $"; |
---|
32 | #endif /* lint */ |
---|
33 | |
---|
34 | #include <discuss/discuss.h> |
---|
35 | |
---|
36 | extern char *getenv (); |
---|
37 | |
---|
38 | main(argc, argv) |
---|
39 | int argc; |
---|
40 | char **argv; |
---|
41 | { |
---|
42 | int n_matches, code; |
---|
43 | register name_blk *nbp; |
---|
44 | name_blk *set; |
---|
45 | int i; |
---|
46 | mtg_info info; |
---|
47 | char **aliasv; |
---|
48 | int naliases; |
---|
49 | |
---|
50 | init_dsc_err_tbl(); |
---|
51 | |
---|
52 | dsc_expand_mtg_set(getenv("USER"), "*", &set, &n_matches, &code); |
---|
53 | |
---|
54 | if (code) |
---|
55 | punt_code("Can't expand meeting set", code); |
---|
56 | |
---|
57 | if (!n_matches) |
---|
58 | punt("No meetings?"); |
---|
59 | |
---|
60 | for (nbp = set; nbp < set + n_matches; ++nbp) { |
---|
61 | dsc_get_mtg_info(nbp, &info, &code); |
---|
62 | if (code) { |
---|
63 | printf("%s: %s\n", nbp->aliases[0], |
---|
64 | error_message(code)); |
---|
65 | continue; |
---|
66 | } |
---|
67 | if (strcmp(nbp->aliases[0], info.long_name)) { |
---|
68 | printf("Adding long_name %s to %s\n", |
---|
69 | info.long_name, nbp->aliases[0]); |
---|
70 | |
---|
71 | /* |
---|
72 | * Beware of dragons and fenceposts in the |
---|
73 | * following code. |
---|
74 | */ |
---|
75 | aliasv = nbp->aliases; |
---|
76 | while (*aliasv++) continue; |
---|
77 | naliases = aliasv - nbp->aliases; |
---|
78 | nbp->aliases = (char **) realloc(nbp->aliases, |
---|
79 | ++naliases * sizeof(nbp->aliases)); |
---|
80 | aliasv = nbp->aliases + naliases; |
---|
81 | while(naliases--) { |
---|
82 | *aliasv = aliasv[-1]; |
---|
83 | --aliasv; |
---|
84 | } |
---|
85 | if (aliasv != nbp->aliases) abort(); |
---|
86 | *aliasv = info.long_name; |
---|
87 | } else printf("Long name %s already present\n", |
---|
88 | info.long_name); |
---|
89 | } |
---|
90 | dsc_update_mtg_set(getenv("USER"), set, n_matches, &code); |
---|
91 | if (code) |
---|
92 | punt_code("update_mtg_set failed", code); |
---|
93 | } |
---|
94 | |
---|
95 | punt(string) |
---|
96 | char *string; |
---|
97 | { |
---|
98 | puts(string); |
---|
99 | exit(1); |
---|
100 | } |
---|
101 | |
---|
102 | punt_code(string, code) |
---|
103 | char *string; |
---|
104 | int code; |
---|
105 | { |
---|
106 | printf("%s: %s", string, error_message(code)); |
---|
107 | exit(1); |
---|
108 | } |
---|
109 | |
---|
110 | |
---|