]> git.sur5r.net Git - openldap/blob - contrib/whois++/whois++.h
Annoying little son of a `free' BUG fixed.
[openldap] / contrib / whois++ / whois++.h
1 /*
2  *                      W H O I S + +
3  *
4  * Author:      Mark R. Prior
5  *              Communications and Systems Branch
6  *              Information Technology Division
7  *              The University of Adelaide
8  * E-mail:      mrp@itd.adelaide.edu.au
9  * Date:        October 1992
10  * Copyright:   (C) 1992, The University of Adelaide
11  * Version:     1.7
12  * Description:
13  *      This is an experimental implementation of the proposed IETF
14  *      WNILS WG update to the whois/nicname protocol (whois++).
15  *
16  * Redistribution and use in source and binary forms are permitted
17  * provided that the above copyright notice and this paragraph are
18  * duplicated in all such forms and that any documentation,
19  * advertising materials, and other materials related to such
20  * distribution and use acknowledge that the software was developed
21  * by the University of Adelaide. The name of the University may not
22  * be used to endorse or promote products derived from this software
23  * without specific prior written permission.
24  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
25  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
26  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27  */
28
29 #include <stdio.h>
30 #include <string.h>
31 #include <ctype.h>
32 #include <errno.h>
33 #include <dirent.h>
34 #if defined(INTERNATIONAL)
35 #include <langinfo.h>
36 #include <locale.h>
37 #include <nl_types.h>
38 #endif
39 #include <sys/types.h>
40 #include <sys/param.h>
41 #include <sys/time.h>
42 #include <netinet/in.h>
43 #include "syslog.h"
44 #include "lber.h"
45 #include "ldap.h"
46
47 #define EQ(x,y)         (strcasecmp(x,y) == 0)
48
49 #if defined(sun)
50 extern  int     sys_nerr;
51 extern  char    *sys_errlist[];
52 #define strerror(_e)    ( ( ( (_e) >= 0 ) && ( (_e) < sys_nerr ) ) ? \
53                 sys_errlist[(_e)] : "Undocumented error code" )
54 #endif
55
56 #if !defined(TRUE)
57 #define TRUE                    1
58 #define FALSE                   0
59 #endif
60
61 #if defined(MAIN)
62 #define EXTERN
63 #else
64 #define EXTERN                  extern
65 #endif
66
67 #if !defined(ABRIDGED_LIMIT)
68 #define ABRIDGED_LIMIT          10
69 #endif
70 #if !defined(DEFAULT_LDAPHOST)
71 #define DEFAULT_LDAPHOST        "localhost"
72 #endif
73 #if !defined(DEFAULT_SIZELIMIT)
74 #define DEFAULT_SIZELIMIT       50
75 #endif
76 #if !defined(DEFAULT_TIMELIMIT)
77 #define DEFAULT_TIMELIMIT       60
78 #endif
79 #if !defined(HELP_DIRECTORY)
80 #define HELP_DIRECTORY          "/usr/local/isode/help/whois++"
81 #endif
82 #if !defined(CONFIG_DIRECTORY)
83 #define CONFIG_DIRECTORY        "/usr/local/isode/etc/whois++"
84 #endif
85 #if !defined(DEFAULT_LANGUAGE)
86 #define DEFAULT_LANGUAGE        "english"
87 #endif
88
89 #define ATTRIBUTE_INCREMENT     10
90 #define TABLE_INCREMENT         10
91 #define DEFAULT_LINE_LENGTH     80
92 #define MIN_LINE_LENGTH         40
93 #define MAX_LINE_LENGTH         200
94
95 /*
96  * Tokens
97  */
98 #define HELP            1
99 #define LIST            2
100 #define DESCRIBE        3
101 #define VERSION         4
102 #define SHOW            5
103 #define CONSTRAINTS     6
104 #define SEARCH          7
105 #define TEMPLATE        8
106 #define HANDLE          9
107 #define ATTRIBUTE       10
108 #define VALUE           11
109 #define SEARCH_ALL      12
110 #define COMMA           13
111 #define ERROR           14
112 #define EQUALS          15
113 #define COLON           16
114 #define SEMICOLON       17
115 #define FULL            18
116 #define ABRIDGED        19
117 #define SUMMARY         20
118 #define READ            21
119 #define LANGUAGE        22
120 #define FORMAT          23
121 #define HOLD            24
122 #define MAXHITS         25
123 #define MATCH           26
124 #define LINE_LENGTH     27
125 #define COMMAND         28
126 #define TRACE           29
127
128 typedef struct {
129         char    *key;
130         char    *value;
131         } table;
132
133 EXTERN int              debug, outputFormat, lineLength, holdConnection, log;
134 EXTERN int              maxHits, numberOfTemplates, tableSize, maximumSize;
135 EXTERN char             *program, *ldaphost, *language, *locale, *base;
136 EXTERN char             *contact, *hostname, *user, *password, *helpDir;
137 EXTERN char             *configDir, *organisation, *defaultLanguage;
138 EXTERN char             *banner;
139 EXTERN char             **category;
140 EXTERN table            *templateTranslationTable;
141
142 extern int              displayDescribe(), parseCommand(char *query);
143 extern void             needHelp(char *reason);
144 extern void             showTemplate(char *template), listTemplates(char *query);
145 extern char             **specifyAttributes(char *objectClass);
146 extern char             *lowerCase(char *string), *version(void), *attributeLabel();
147 extern char             *rfc931_name();
148 extern char             *templateToObjectClass(char *template);