]> jfr.im git - irc.git/blame - software/ircd/www.irc.org/ftp/irc/clients/vms/doughirc/test.c
init
[irc.git] / software / ircd / www.irc.org / ftp / irc / clients / vms / doughirc / test.c
CommitLineData
3bd189cb
JR
1#include <stdio.h>
2#include <descrip.h>
3#include <lnmdef.h>
4#include <stdarg.h>
5#ifdef __GNUC__
6#define PSL$C_USER 3
7#else
8#include <psldef.h>
9#endif
10#include <string.h>
11#include <stdlib.h>
12#include <lib$routines.h>
13#include "nstype.h"
14#include "debug.h"
15#include "types.h"
16#include "qio.h"
17
18#ifndef FALSE
19#define FALSE 0
20#define TRUE (!FALSE)
21#endif
22
23extern int find_server(char *, DOMAIN, int), nslookup();
24
25#if 1
26void say(char *format, char *p1, char *p2, char *p3, char *p4, char *p5,
27 char *p6, char *p7, char *p8)
28{
29 char str[240];
30 printf(format, p1, p2, p3, p4, p5, p6, p7, p8);
31 printf("\n");
32}
33
34#else
35
36void say(char *format, ...)
37{
38 va_list arglist;
39 va_start(arglist, format);
40 vprintf(format, arglist);
41 va_end(arglist);
42}
43#endif
44
45int get_logical(name, translation)
46 char *name, *translation;
47{
48 $DESCRIPTOR(table_d, "LNM$SYSTEM");
49 struct dsc$descriptor_s name_d;
50 struct itemlistcell il[2];
51 char buffer[255];
52 unsigned status, len=0;
53 int flag1 = LNM$M_CASE_BLIND, flag2 = PSL$C_USER;
54 extern int sys$trnlnm();
55
56 name_d.dsc$b_dtype = DSC$K_DTYPE_T;
57 name_d.dsc$b_class = DSC$K_CLASS_S;
58 name_d.dsc$a_pointer = name;
59
60 il[0].buffer_length = sizeof(buffer)-1;
61 il[0].item_code = LNM$_STRING;
62 il[0].buffer_addr = (unsigned)buffer;
63 il[0].return_addr = (unsigned)(&len);
64 il[1].buffer_length = 0;
65 il[1].item_code = 0;
66 il[1].buffer_length = 0;
67 il[1].buffer_length = 0;
68 name_d.dsc$w_length = strlen(name);
69 status = sys$trnlnm(&flag1, &table_d, &name_d, &flag2, il);
70 if (!(status&1)) return FALSE;
71 if (len==0) return FALSE;
72 buffer[len] = 0;
73 (void)strcpy(translation, buffer);
74 return TRUE;
75}
76
77#ifdef USE_RELOC_QIO
78extern int setup_qio_hooks();
79#endif
80
81int main(argc, argv)
82 int argc;
83 char *argv[];
84{
85 DOMAIN ip;
86 $DESCRIPTOR(sym_d, "NAME_SERVER");
87 int loop, passed = 0, count = 0;
88 char str2[80];
89 char str[80], host[80], domain[80], *host_ptr;
90 struct dsc$descriptor_s ip_d;
91 unsigned status, len=0;
92
93#ifdef USE_RELOC_QIO
94 if (!setup_qio_hooks("disk$userdisk1:[mas0.masdough.irc]"))
95 exit(0);
96#endif
97 ip_d.dsc$a_pointer = str;
98 ip_d.dsc$b_dtype = DSC$K_DTYPE_T;
99 ip_d.dsc$b_class = DSC$K_CLASS_S;
100 if (argc>1) {
101 strcpy(host, argv[1]);
102 passed = 1;
103 } else {
104 if (tcp_gethostname(host)==-1)
105 {
106 printf("Enter your hostname: ");
107 gets(host);
108 }
109 else printf("You hostname is [%s]\n", host);
110 }
111
112 while (!find_server(host, ip, !passed) && (count++ < 10)) {
113 printf("Enter your full hostname: ");
114 if (!gets(host))
115 {
116 printf("not running at a terminal??\n");
117 exit(0);
118 }
119 }
120 (void)sprintf(str, "%d.%d.%d.%d\0", ip[0], ip[1], ip[2], ip[3]);
121 ip_d.dsc$w_length = strlen(str);
122 if (nslookup(str, host, ip))
123 sprintf(str2, "%u.%u.%u.%u\0", ip[0], ip[1], ip[2], ip[3]);
124 else strcpy(str2, "*unknown*");
125 (void)printf("Default nameserver for %s (%s) is %s\n", host, str2, str);
126 (void)lib$set_symbol(&sym_d, &ip_d, 0);
127}