[23882] | 1 | /* $Id: moira.h,v 1.36 2009-06-01 21:05:00 zacheiss Exp $ |
---|
[23095] | 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 */ |
---|
[23882] | 87 | void critical_alert(char *whoami, char *instance, char *msg, ...); |
---|
[23095] | 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 | |
---|
[23882] | 118 | /* prototypes from kname_parse.c */ |
---|
| 119 | int mr_kname_parse(char *np, char *ip, char *rp, char *fullname); |
---|
| 120 | |
---|
[23095] | 121 | /* prototypes from nfsparttype.c */ |
---|
| 122 | char *parse_filesys_type(char *fs_type_name); |
---|
| 123 | char *format_filesys_type(char *fs_status); |
---|
| 124 | |
---|
| 125 | /* prototypes from sq.c */ |
---|
| 126 | struct save_queue *sq_create(void); |
---|
| 127 | int sq_save_data(struct save_queue *sq, void *data); |
---|
| 128 | int sq_save_args(int argc, char *argv[], struct save_queue *sq); |
---|
| 129 | int sq_save_unique_data(struct save_queue *sq, void *data); |
---|
| 130 | int sq_save_unique_string(struct save_queue *sq, char *data); |
---|
| 131 | /* in sq_get_data and sq_remove_data, the `data' arg should be a |
---|
| 132 | pointer to a pointer */ |
---|
| 133 | int sq_get_data(struct save_queue *sq, void *data); |
---|
| 134 | int sq_remove_data(struct save_queue *sq, void *data); |
---|
| 135 | void sq_remove_last_data(struct save_queue *sq); |
---|
| 136 | int sq_empty(struct save_queue *sq); |
---|
| 137 | void sq_destroy(struct save_queue *sq); |
---|
| 138 | |
---|
| 139 | /* prototypes from strs.c */ |
---|
| 140 | char *strtrim(char *s); |
---|
| 141 | char *uppercase(char *s); |
---|
| 142 | char *lowercase(char *s); |
---|
| 143 | |
---|
| 144 | #ifndef HAVE_STRLCPY |
---|
| 145 | size_t strlcpy(char *dst, const char *src, size_t size); |
---|
| 146 | #endif |
---|
| 147 | #ifndef HAVE_STRLCAT |
---|
| 148 | size_t strlcat(char *dst, const char *src, size_t size); |
---|
| 149 | #endif |
---|
| 150 | |
---|
| 151 | /* mr_ functions */ |
---|
| 152 | int mr_access(char *handle, int argc, char **argv); |
---|
| 153 | int mr_auth(char *prog); |
---|
| 154 | int mr_connect(char *server); |
---|
| 155 | int mr_disconnect(void); |
---|
| 156 | int mr_do_update(void); |
---|
| 157 | int mr_host(char *host, int size); |
---|
| 158 | int mr_motd(char **motd); |
---|
| 159 | int mr_noop(void); |
---|
| 160 | int mr_proxy(char *principal, char *orig_authtype); |
---|
| 161 | int mr_query(char *handle, int argc, char **argv, |
---|
| 162 | int (*callback)(int, char **, void *), void *callarg); |
---|
| 163 | int mr_version(int version); |
---|
| 164 | |
---|
| 165 | /* error-name backward compatibility */ |
---|
| 166 | #define MR_INGRES_ERR MR_DBMS_ERR |
---|
| 167 | #define MR_INGRES_SOFTFAIL MR_DBMS_SOFTFAIL |
---|
| 168 | |
---|
| 169 | |
---|
| 170 | #ifdef __GNUC__ |
---|
| 171 | #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) |
---|
| 172 | #define __attribute__(x) |
---|
| 173 | #endif |
---|
| 174 | #else /* ! __GNUC __ */ |
---|
| 175 | #define __attribute__(x) |
---|
| 176 | #endif |
---|
| 177 | |
---|
| 178 | #define RCSID(id) static char *rcsid __attribute__ ((__unused__)) = id |
---|
| 179 | |
---|
| 180 | #endif /* _moira_h_ */ /* Do Not Add Anything after this line. */ |
---|