[23740] | 1 | /* $Id: query.h,v 2.15 2008-08-29 14:50:08 zacheiss Exp $ |
---|
[23095] | 2 | * |
---|
| 3 | * Structures and constants used in the query dispatch table |
---|
| 4 | * |
---|
| 5 | * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology. |
---|
| 6 | * For copying and distribution information, please see the file |
---|
| 7 | * <mit-copyright.h>. |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | /* Query Types */ |
---|
[23178] | 11 | enum query_type {MR_Q_RETRIEVE, MR_Q_UPDATE, MR_Q_APPEND, MR_Q_DELETE, MR_Q_SPECIAL}; |
---|
[23095] | 12 | |
---|
| 13 | /* Query Definition Structure */ |
---|
| 14 | struct query |
---|
| 15 | { |
---|
| 16 | char *name; /* query name */ |
---|
| 17 | char *shortname; /* abbreviated query name (must be 4 chars) */ |
---|
| 18 | int version; /* query version */ |
---|
| 19 | enum query_type type; /* query type */ |
---|
| 20 | char *rvar; /* range variable */ |
---|
| 21 | enum tables rtable; /* range table */ |
---|
| 22 | char *tlist; /* target list */ |
---|
| 23 | char **fields; /* input and output variable names (for help) */ |
---|
| 24 | int vcnt; /* variable count */ |
---|
| 25 | char *qual; /* format string for "where" clause */ |
---|
| 26 | int argc; /* number of args for qualifier */ |
---|
| 27 | char *sort; /* fields to sort on */ |
---|
| 28 | struct validate *validate; /* validation support */ |
---|
| 29 | int acl; /* hint as to query ACL for this query */ |
---|
| 30 | int everybody; /* is the default user on this ACL? */ |
---|
| 31 | }; |
---|
| 32 | |
---|
| 33 | /* Query Validation Structure */ |
---|
| 34 | struct validate |
---|
| 35 | { |
---|
| 36 | /* object validation (e.g., user, filesys, type) */ |
---|
| 37 | struct valobj *valobj; /* array of object validation descriptors */ |
---|
| 38 | int objcnt; /* size of array */ |
---|
| 39 | /* row validation - retrieve (exists = any(rvar.field where qual)) */ |
---|
| 40 | char *field; /* field to check for */ |
---|
| 41 | char *qual; /* format string for "where" clause */ |
---|
| 42 | int argc; /* number of args used in qual */ |
---|
| 43 | /* values field containing current max object id */ |
---|
| 44 | char *object_id; |
---|
| 45 | /* routine to verify access permission on objects */ |
---|
| 46 | int (*acs_rtn)(struct query *q, char *Argv[], client *cl); |
---|
| 47 | /* pre-processing routine (var setup only) */ |
---|
| 48 | int (*pre_rtn)(struct query *q, char *Argv[], client *cl); |
---|
| 49 | /* post-processing routine */ |
---|
| 50 | int (*post_rtn)(); |
---|
| 51 | }; |
---|
| 52 | |
---|
| 53 | /* Validated Object Types */ |
---|
| 54 | enum vo_type {V_NAME, V_ID, V_TYPE, V_TYPEDATA, V_RENAME, V_CHAR, |
---|
| 55 | V_LEN, V_NUM}; |
---|
| 56 | |
---|
| 57 | /* Validated Object Definition */ |
---|
| 58 | struct valobj |
---|
| 59 | { |
---|
| 60 | enum vo_type type; |
---|
| 61 | int index; /* index of object to validate */ |
---|
| 62 | enum tables table; /* table containing object */ |
---|
| 63 | char *namefield; /* table's fieldname for object */ |
---|
| 64 | char *idfield; /* table's corresponding id field (if any) */ |
---|
| 65 | int error; |
---|
| 66 | }; |
---|
| 67 | |
---|
| 68 | /* prototypes from increment.dc */ |
---|
| 69 | void incremental_before(enum tables table, char *qualx, char **argv); |
---|
| 70 | void incremental_clear_before(void); |
---|
| 71 | void incremental_after(enum tables table, char *qualx, char **argv); |
---|
| 72 | void incremental_clear_after(void); |
---|
| 73 | |
---|
| 74 | /* prototypes from qrtn.dc */ |
---|
| 75 | int check_query_access(struct query *q, char *argv[], client *cl); |
---|
| 76 | int set_next_object_id(char *objectx, enum tables table, int limit); |
---|
| 77 | int name_to_id(char *name, enum tables type, int *id); |
---|
| 78 | int id_to_name(int id, enum tables type, char **name); |
---|
| 79 | |
---|
| 80 | /* prototypes from qsubs.c */ |
---|
| 81 | void list_queries(client *cl, int (*action)(int, char *[], void *), |
---|
| 82 | void *actarg); |
---|
| 83 | void help_query(struct query *q, int (*action)(int, char *[], void *), |
---|
| 84 | void *actarg); |
---|
| 85 | struct query *get_query_by_name(char *name, int version); |
---|