1 | #ifndef READ_QUERY_COMMAND 2 | #define READ_QUERY_COMMAND 3 | 4 | /*************************************** 5 | $Revision: 1.14 $ 6 | 7 | Query command module (qc) 8 | 9 | Status: NOT REVUED, NOT 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 [-aFLmMrSvR] [-h hostname] [-s sources] [-T types] [-i attr] keys\n" \ 32 | "whois -t type whois -v type\n" \ 33 | "\n"\ 34 | "Where:\n"\ 35 | "\n"\ 36 | "-a search all databases\n"\ 37 | "-F fast raw output\n"\ 38 | "-h hostname search alternate server\n"\ 39 | "-i [attr][[,attr] ... ] do an inverse lookup for specified attributes\n"\ 40 | "-l ???\n"\ 41 | "-L find all Less specific matches\n"\ 42 | "-m find first level more specific matches\n"\ 43 | "-M find all More specific matches\n"\ 44 | "-r turn off recursive lookups\n"\ 45 | "-s source[[,source] ... ] search databases with source 'source'\n"\ 46 | "-S tell server to leave out 'syntactic sugar'\n"\ 47 | "-t type requests template for object of type 'type'\n"\ 48 | "-v type requests verbose template for object of type 'type'\n"\ 49 | "-R force to show local copy of the domain object even if it contains referral\n"\ 50 | "-T type[[,type] ... ] only look for objects of type 'type'\n"\ 51 | "\n"\ 52 | "Please note that most of these flags are NOT understood by\n"\ 53 | "non RIPE whois servers\n\n" 54 | 55 | #include <glib.h> 56 | #include "bitmask.h" 57 | #include "socket.h" 58 | 59 | 60 | typedef enum { 61 | PW_EMPTY, 62 | PW_NOKEY, 63 | PW_TEMPLATE, 64 | PW_HELP, 65 | PW_REAL 66 | } qc_qtype_t; 67 | 68 | typedef struct Query_environ_t { 69 | sk_conn_st condat; 70 | unsigned int k; 71 | GList *sources_list; 72 | char *version; 73 | ip_addr_t pIP; /* passed IP */ 74 | } Query_environ; 75 | 76 | typedef struct Query_command_t { 77 | qc_qtype_t query_type; 78 | unsigned int e; 79 | unsigned int fast; 80 | unsigned int g; 81 | mask_t inv_attrs_bitmap; 82 | unsigned int recursive; 83 | unsigned int l; 84 | unsigned int m; 85 | unsigned int q; 86 | unsigned int t; 87 | unsigned int v; 88 | unsigned int x; 89 | unsigned int filtered; 90 | unsigned int L; 91 | unsigned int M; 92 | unsigned int R; 93 | unsigned int S; 94 | mask_t object_type_bitmap; 95 | mask_t keytypes_bitmap; 96 | char *keys; 97 | } Query_command; 98 | 99 | char *QC_bitmap_to_string(mask_t bitmap); 100 | char *QC_environ_to_string(Query_environ qe); 101 | char *QC_query_command_to_string(Query_command *query_command); 102 | void QC_environ_free(Query_environ *qe); 103 | void QC_free(Query_command *qc); 104 | Query_command *QC_create(char *query_str, Query_environ *qe); 105 | Query_environ *QC_environ_new(char *ip, unsigned sock); 106 | Query_environ *QC_environ_update(Query_command *qc, Query_environ *qe); 107 | 108 | #endif /* READ_QUERY_COMMAND */