1    | #ifndef READ_QUERY_COMMAND
2    | #define READ_QUERY_COMMAND
3    | 
4    | /***************************************
5    |   $Revision: 1.26 $
6    | 
7    |   Query command module (qc)
8    | 
9    |   Status: NOT REVUED, TESTED
10   | 
11   |   ******************/ /******************
12   |   Copyright (c) 1999,2000,2001,2002               RIPE NCC
13   |  
14   |   All Rights Reserved
15   |   
16   |   Permission to use, copy, modify, and distribute this software and its
17   |   documentation for any purpose and without fee is hereby granted,
18   |   provided that the above copyright notice appear in all copies and that
19   |   both that copyright notice and this permission notice appear in
20   |   supporting documentation, and that the name of the author not be
21   |   used in advertising or publicity pertaining to distribution of the
22   |   software without specific, written prior permission.
23   |   
24   |   THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
25   |   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
26   |   AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
27   |   DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
28   |   AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
29   |   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30   |   ***************************************/
31   | #define USAGE  "% Usage: whois [-aFKlLmMrRx] [-s sources] [-T type(s)] [-i attr] keys\n" \
32   | "% whois {-t|-v} type\n"\
33   | "% whois -q {version|sources}\n"\
34   | "% \n"\
35   | "% Where:\n"\
36   | "% \n"\
37   | "% -k                         open/close session (persistent connection)\n"\
38   | "% -r                         turn off recursive lookups\n"\
39   | "% -F                         fast raw output (implies -r)\n"\
40   | "% -K                         print only primary keys (implies -r)\n"\
41   | "% -R                         show local copy of the domain object (no referral)\n"\
42   | "% -a                         search all databases\n"\
43   | "% -s source[[,source] ... ]  search only databases with source 'source'\n"\
44   | "% -T type[[,type] ... ]      only look for objects of type 'type'\n"\
45   | "% -i [attr][[,attr] ... ]    do an inverse lookup for specified attributes\n"\
46   | "% -d                         include reverse domains for look-up by IP\n"\
47   | "% -l                         find first level Less specific matches\n"\
48   | "% -L                         find all Less specific matches\n"\
49   | "% -m                         find first level more specific matches\n"\
50   | "% -M                         find all More specific matches\n"\
51   | "% -x                         find exact matches only\n"\
52   | "% -t type                    requests template for object of type 'type'\n"\
53   | "% -v type                    requests verbose template for object of type 'type'\n"\
54   | "% \n"\
55   | "% Please note that most of these flags are NOT understood by\n"\
56   | "% non RIPE whois servers\n\n"
57   |                        /* ^^^  output must end with this blank line */
58   | 
59   | #include <glib.h>
60   | #include "bitmask.h"
61   | #include "sk.h"
62   | 
63   | 
64   | typedef enum {
65   |   QC_EMPTY,
66   |   QC_PARERR,
67   |   QC_SYNERR,
68   |   QC_NOKEY,
69   |   QC_TEMPLATE,
70   |   QC_HELP,
71   |   QC_REAL,
72   |   QC_FILTERED,
73   | 
74   |   QC_TYPE_MAX
75   | } qc_qtype_t;
76   | /* now this must be sync'ed with that: */
77   | #ifdef QC_IMPL
78   | char *qrytype_str[] = {
79   |   "EMPTY",
80   |   "PARAMETER ERROR",
81   |   "SYNTAX ERROR",
82   |   "NO KEY",
83   |   "TEMPLATE",
84   |   "HELP",
85   |   "REAL",
86   |   "FILTERED"
87   | };
88   | #endif
89   | 
90   | 
91   | /* types of -q queries */
92   | #define QC_Q_SOURCES 0
93   | #define QC_Q_VERSION 1
94   | 
95   | 
96   | 
97   | typedef struct Query_environ_t {
98   |   sk_conn_st   condat;
99   |   unsigned int k;
100  |   GList *sources_list;
101  |   char *version;
102  |   ip_addr_t pIP; /* passed IP */
103  | } Query_environ;
104  | 
105  | typedef struct Query_command_t {
106  |   qc_qtype_t   query_type;
107  | 
108  |   /* -c: query for the most specific inetnum/inet6num with the "mnt-irt:" 
109  |          attribute set */
110  |   gboolean c_irt_search;
111  | 
112  |   int d;
113  |   int e;
114  |   int fast;
115  |   int g;
116  |   mask_t inv_attrs_bitmap;
117  |   int recursive;
118  |   int l;
119  |   int m;
120  |   int q;
121  |   int t;
122  |   int v;
123  |   int x;
124  |   int filtered;
125  |   int L;
126  |   int M;
127  |   int R;
128  |   int S;
129  |   mask_t object_type_bitmap;
130  |   mask_t keytypes_bitmap;
131  |   char *keys;
132  | } Query_command;
133  | 
134  | char *QC_bitmap_to_string(mask_t bitmap);
135  | char *QC_environ_to_string(Query_environ qe);
136  | char *QC_query_command_to_string(Query_command *query_command);
137  | void QC_environ_free(Query_environ *qe);
138  | void QC_free(Query_command *qc);
139  | Query_command *QC_create(char *query_str, Query_environ *qe);
140  | Query_environ *QC_environ_new(char *ip, int sock);
141  | Query_environ *QC_environ_update(Query_command *qc, Query_environ *qe);
142  | char *QC_get_qrytype(qc_qtype_t qrytype);
143  | #endif /* READ_QUERY_COMMAND */