6 * Copyright (C) 1987 by the Massachusetts Institute of Technology
10 #include <sys/types.h>
12 #include <sys/socket.h>
13 #include <netinet/in.h>
15 #include <moira_site.h>
21 typedef struct returned_tuples {
22 struct returned_tuples *next;
28 * This should be in the kerberos header file.
38 * This structure holds all per-client information; one of these is
39 * allocated for each active client.
42 typedef struct _client {
43 OPERATION pending_op; /* Primary pending operation */
44 CONNECTION con; /* Connection to the client */
45 int action; /* what action is pending? */
46 mr_params *args, reply;
47 int id; /* Unique id of client */
48 struct sockaddr_in haddr; /* IP address of client */
49 char clname[MAX_K_NAME_SZ]; /* Name client authenticated to */
50 struct krbname kname; /* Parsed version of the above */
51 int users_id; /* MR internal ID of authenticated user */
52 int client_id; /* MR internal ID of client for modby field */
53 returned_tuples *first, *last;
54 time_t last_time_used; /* Last time connection used */
55 char entity[9]; /* entity on other end of the connection */
73 extern char *krb_realm;
81 #define LOG_CONNECT 0x0001
82 #define LOG_REQUESTS 0x0002
83 #define LOG_ARGS 0x0004
84 #define LOG_RESP 0x0008
85 #define LOG_RES 0x0010
86 #define LOG_VALID 0x0020
87 #define LOG_SQL 0x0040
88 #define LOG_GDSS 0x0080
91 /* max length of query argument allowed */
93 /* Used to setup static argv, maximum argc */
96 /* statistics on number of queries by version number */
97 extern int newqueries, oldqueries;
99 /* Maximum and minimum values that will ever be chosen for IDs */
100 #define MAX_ID_VALUE 31999
101 #define MIN_ID_VALUE 100
103 /* Sleepy states for the server! */
110 /* state for the incremental update system */
111 extern int inc_running, inc_pid;
112 extern time_t inc_started, now;
113 #define INC_TIMEOUT (3 * 60) /* 3 minutes */
116 #define SQL_NO_MATCH 1403 /* oracle, not ingres (= 100) */
118 /* prototypes from gdb */
120 int gdb_debug(int flag);
121 void start_accepting_client(CONNECTION, OPERATION, CONNECTION *,
122 char *, int *, TUPLE *);
123 int initialize_operation(OPERATION, int (*init_function)(), char *,
124 int (*cancel_function)());
125 int reset_operation(OPERATION);
126 int delete_operation(OPERATION);
127 int start_replying_to_client(OPERATION, CONNECTION, int, char *, char *);
128 int op_select(LIST_OF_OPERATIONS, int, fd_set *, fd_set *, fd_set *,
131 /* prototypes from libmoira */
132 struct save_queue *sq_create(void);
133 int sq_save_data(struct save_queue *sq, void *data);
134 int sq_save_unique_data(struct save_queue *sq, void *data);
135 int sq_save_args(int argc, void *argv[], struct save_queue *sq);
136 int sq_get_data(struct save_queue *sq, void *data);
137 int sq_remove_data(struct save_queue *sq, void *data);
138 int sq_empty(struct save_queue *sq);
139 void sq_destroy(struct save_queue *sq);
141 void send_zgram(char *instance, char *buf);
142 void critical_alert(char *, char *, ...);
143 void mr_destroy_reply(mr_params *reply);
146 /* prototypes from increment.dc */
147 void incremental_init(void);
148 void next_incremental(void);
149 void incremental_update(void);
150 void incremental_flush(void);
152 /* prototypes from qrtn.dc */
154 void dosql(char *buffers[]);
155 int mr_open_database(void);
156 void mr_close_database(void);
157 int mr_process_query(client *cl, char *name, int argc, char *argv_ro[],
158 int (*action)(), char *actarg);
159 int mr_check_access(client *cl, char *name, int argc, char *argv_ro[]);
160 void sanity_check_queries(void);
161 int set_krb_mapping(char *name, char *login, int ok, int *kid, int *uid);
162 int find_member(char *list_type, int list_id, client *cl);
163 int do_for_all_rows(char *query, int count, int (*action)(), int actarg);
164 int build_qual(char *fmt, int argc, char *argv[], char *qual);
167 /* prototyoes from qsupport.dc */
168 int set_pop_usage(int id, int cnt);
170 /* prototypes from qvalidate.dc */
171 void sanity_check_database(void);
172 int add_string(char *name);
173 int convert_wildcards(char *arg);
175 /* prototypes from mr_main.c */
176 void clist_delete(client *cp);
178 /* prototypes from mr_sauth.c */
179 void do_auth(client *cl);
181 /* prototypes from mr_scall.c */
182 void do_client(client *cp);
183 int trigger_dcm(int dummy0, int dummy1, client *cl);
185 /* prototypes from mr_shutdown.c */
187 void do_shutdown(client *cl);
189 /* prototypes from mr_util.c */
190 char *requote(char *buf, char *cp, int len);
191 void log_args(char *tag, int version, int argc, char **argv);
192 void mr_com_err(const char *whoami, long code, const char *fmt, va_list pvar);
193 int mr_trim_args(int argc, char **argv);
194 char **mr_copy_args(char **argv, int argc);