]> andersk Git - moira.git/blob - include/moira.h
cb65936365addd34272789af48b863e9632cfc83
[moira.git] / include / moira.h
1 /* $Id$
2  *
3  * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
4  *
5  */
6
7 #ifndef _moira_h_
8 #define _moira_h_
9
10 #ifdef _WIN32
11 #include <windows.h>
12 #ifndef strcasecmp
13 #define strcasecmp      stricmp
14 #endif
15 #ifndef snprintf
16 #define snprintf      _snprintf
17 #endif
18 #endif /*_WIN32 */
19
20 /* return values from queries (and error codes) */
21 #include <stdlib.h>
22 #include <sys/types.h>
23 #include <com_err.h>
24 #include "mr_et.h"
25 #include "krb_et.h"
26 #include "ureg_err.h"
27
28 #define MR_SUCCESS 0            /* Query was successful */
29
30 #define MR_VERSION_1 1          /* Version in use from 7/87 to 4/88 */
31 #define MR_VERSION_2 2          /* After 4/88, new query lib */
32
33 /* return values for Moira server calls, used by clients */
34
35 #define MR_CONT 0               /* Everything okay, continue sending values. */
36 #define MR_ABORT -1             /* Something went wrong don't send anymore
37                                    values. */
38
39 #define MOIRA_SNAME     "moira" /* Kerberos service key to use */
40
41 /* Protocol operations */
42 #define MR_NOOP 0
43 #define MR_AUTH 1
44 #define MR_SHUTDOWN 2
45 #define MR_QUERY 3
46 #define MR_ACCESS 4
47 #define MR_DO_UPDATE 5
48 #define MR_MOTD 6
49 #define MR_PROXY 7
50 #define MR_SETVERSION 8
51 #define MR_KRB5_AUTH 9
52 #define MR_MAX_PROC 9
53
54 /* values used in NFS physical flags */
55 #define MR_FS_STUDENT   0x0001
56 #define MR_FS_FACULTY   0x0002
57 #define MR_FS_STAFF     0x0004
58 #define MR_FS_MISC      0x0008
59 #define MR_FS_GROUPQUOTA 0x0010
60
61 /* magic values to pass for list and user queries */
62 #define UNIQUE_GID      "create unique GID"
63 #define UNIQUE_UID      "create unique UID"
64 #define UNIQUE_LOGIN    "create unique login ID"
65
66 /* Structure used by Save Queue routines (for temporary storage of data) */
67 struct save_queue
68 {
69   struct save_queue *q_next;
70   struct save_queue *q_prev;
71   struct save_queue *q_lastget;
72   void *q_data;
73 };
74
75 /* Hash table declarations */
76 struct bucket {
77   struct bucket *next;
78   int key;
79   void *data;
80 };
81 struct hash {
82   int size;
83   struct bucket **data;
84 };
85
86 /* prototypes from critical.c */
87 void critical_alert(char *instance, char *msg, ...);
88 void send_zgram(char *inst, char *msg);
89
90 /* prototypes from fixhost.c */
91 char *canonicalize_hostname(char *s);
92
93 /* prototypes from fixname.c */
94 void FixName(char *ilnm, char *ifnm, char *last, char *first, char *middle);
95 void FixCase(unsigned char *p);
96 void LookForJrAndIII(char *nm, int *pends_jr, int *pends_sr,
97                      int *pends_ii, int *pends_iii,
98                      int *pends_iv, int *pends_v);
99 void LookForSt(char *nm);
100 void LookForO(char *nm);
101 void TrimTrailingSpace(char *ip);
102 void GetMidInit(char *nm, char *mi);
103 void RemoveHyphens(char *str);
104
105 /* prototypes from hash.c */
106 struct hash *create_hash(int size);
107 void *hash_lookup(struct hash *h, int key);
108 int hash_update(struct hash *h, int key, void *value);
109 int hash_store(struct hash *h, int key, void *value);
110 void hash_search(struct hash *h, void *value, void (*callback)(int));
111 void hash_step(struct hash *h, void (*callback)(int, void *, void *),
112                void *hint);
113 void hash_destroy(struct hash *h);
114
115 /* prototypes from kname_unparse.c */
116 char *mr_kname_unparse(char *p, char *i, char *r);
117
118 /* prototypes from nfsparttype.c */
119 char *parse_filesys_type(char *fs_type_name);
120 char *format_filesys_type(char *fs_status);
121
122 /* prototypes from sq.c */
123 struct save_queue *sq_create(void);
124 int sq_save_data(struct save_queue *sq, void *data);
125 int sq_save_args(int argc, char *argv[], struct save_queue *sq);
126 int sq_save_unique_data(struct save_queue *sq, void *data);
127 int sq_save_unique_string(struct save_queue *sq, char *data);
128 /* in sq_get_data and sq_remove_data, the `data' arg should be a
129    pointer to a pointer */
130 int sq_get_data(struct save_queue *sq, void *data);
131 int sq_remove_data(struct save_queue *sq, void *data);
132 void sq_remove_last_data(struct save_queue *sq);
133 int sq_empty(struct save_queue *sq);
134 void sq_destroy(struct save_queue *sq);
135
136 /* prototypes from strs.c */
137 char *strtrim(char *s);
138 char *uppercase(char *s);
139 char *lowercase(char *s);
140
141 #ifndef HAVE_STRLCPY
142 size_t strlcpy(char *dst, const char *src, size_t size);
143 #endif
144 #ifndef HAVE_STRLCAT
145 size_t strlcat(char *dst, const char *src, size_t size);
146 #endif
147
148 /* mr_ functions */
149 int mr_access(char *handle, int argc, char **argv);
150 int mr_auth(char *prog);
151 int mr_connect(char *server);
152 int mr_disconnect(void);
153 int mr_do_update(void);
154 int mr_host(char *host, int size);
155 int mr_motd(char **motd);
156 int mr_noop(void);
157 int mr_proxy(char *principal, char *orig_authtype);
158 int mr_query(char *handle, int argc, char **argv,
159              int (*callback)(int, char **, void *), void *callarg);
160 int mr_version(int version);
161
162 /* error-name backward compatibility */
163 #define MR_INGRES_ERR           MR_DBMS_ERR
164 #define MR_INGRES_SOFTFAIL      MR_DBMS_SOFTFAIL
165
166
167 #ifdef __GNUC__
168 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
169 #define __attribute__(x)
170 #endif
171 #else /* ! __GNUC __ */
172 #define __attribute__(x)
173 #endif
174
175 #define RCSID(id) static char *rcsid __attribute__ ((__unused__)) = id
176
177 #endif /* _moira_h_ */          /* Do Not Add Anything after this line. */
This page took 0.046984 seconds and 3 git commands to generate.