1 | #ifndef READ_QUERY_COMMAND 2 | #define READ_QUERY_COMMAND 3 | 4 | /*************************************** 5 | $Revision: 1.23 $ 6 | 7 | Query command module (qc) 8 | 9 | Status: NOT REVUED, TESTED 10 | 11 | ******************/ /****************** 12 | Copyright (c) 1999 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 | 58 | #include <glib.h> 59 | #include "bitmask.h" 60 | #include "sk.h" 61 | 62 | 63 | typedef enum { 64 | QC_EMPTY, 65 | QC_PARERR, 66 | QC_SYNERR, 67 | QC_NOKEY, 68 | QC_TEMPLATE, 69 | QC_HELP, 70 | QC_REAL, 71 | QC_FILTERED, 72 | 73 | QC_TYPE_MAX 74 | } qc_qtype_t; 75 | /* now this must be sync'ed with that: */ 76 | #ifdef QC_IMPL 77 | char *qrytype_str[] = { 78 | "EMPTY", 79 | "PARAMETER ERROR", 80 | "SYNTAX ERROR", 81 | "NO KEY", 82 | "TEMPLATE", 83 | "HELP", 84 | "REAL", 85 | "FILTERED" 86 | }; 87 | #endif 88 | 89 | 90 | /* types of -q queries */ 91 | #define QC_Q_SOURCES 0 92 | #define QC_Q_VERSION 1 93 | 94 | 95 | 96 | typedef struct Query_environ_t { 97 | sk_conn_st condat; 98 | unsigned int k; 99 | GList *sources_list; 100 | char *version; 101 | ip_addr_t pIP; /* passed IP */ 102 | } Query_environ; 103 | 104 | typedef struct Query_command_t { 105 | qc_qtype_t query_type; 106 | int d; 107 | int e; 108 | int fast; 109 | int g; 110 | mask_t inv_attrs_bitmap; 111 | int recursive; 112 | int l; 113 | int m; 114 | int q; 115 | int t; 116 | int v; 117 | int x; 118 | int filtered; 119 | int L; 120 | int M; 121 | int R; 122 | int S; 123 | mask_t object_type_bitmap; 124 | mask_t keytypes_bitmap; 125 | char *keys; 126 | } Query_command; 127 | 128 | char *QC_bitmap_to_string(mask_t bitmap); 129 | char *QC_environ_to_string(Query_environ qe); 130 | char *QC_query_command_to_string(Query_command *query_command); 131 | void QC_environ_free(Query_environ *qe); 132 | void QC_free(Query_command *qc); 133 | Query_command *QC_create(char *query_str, Query_environ *qe); 134 | Query_environ *QC_environ_new(char *ip, int sock); 135 | Query_environ *QC_environ_update(Query_command *qc, Query_environ *qe); 136 | char *QC_get_qrytype(qc_qtype_t qrytype); 137 | #endif /* READ_QUERY_COMMAND */