Annotation of libwww/Robot/src/HTRobot.c, revision 1.6.2.2
1.1 frystyk 1: /* HTRobot.c
2: ** W3C MINI ROBOT
3: **
4: ** (c) COPRIGHT MIT 1995.
5: ** Please first read the full copyright statement in the file COPYRIGH.
6: **
7: ** This program illustrates how to travers links using the Anchor object
8: **
9: ** Authors:
10: ** HFN Henrik Frystyk Nielsen, (frystyk@w3.org)
11: **
12: ** History:
13: ** Dec 04 95 First version
14: */
15:
16: #include "WWWLib.h" /* Global Library Include file */
17: #include "WWWApp.h" /* Application stuff */
1.4 frystyk 18: #include "HText.h"
1.1 frystyk 19:
20: #include "HTRobot.h" /* Implemented here */
21:
22: #ifndef VR
23: #define VR "unspecified"
24: #endif
25:
26: #define APP_NAME "W3CRobot"
27: #define APP_VERSION VR
28:
29: /* Default page for "-help" command line option */
30: #define HELP "http://www.w3.org/pub/WWW/Robot/User/CommandLine.html"
31:
32: #define DEFAULT_OUTPUT_FILE "robot.out"
33: #define DEFAULT_RULE_FILE "robot.conf"
34: #define DEFAULT_LOG_FILE "robot.log"
1.6.2.1 frystyk 35: #define DEFAULT_DEPTH 0
1.1 frystyk 36:
37: #define SHOW_MSG (WWWTRACE || HTAlert_interactive())
38:
1.6.2.2 ! frystyk 39: #define DEFAULT_TIMEOUT 10 /* timeout in seconds */
1.1 frystyk 40:
41: #if defined(__svr4__)
42: #define CATCH_SIG
43: #endif
44:
45: typedef enum _MRFlags {
1.2 frystyk 46: MR_IMG = 0x1,
47: MR_LINK = 0x2,
48: MR_PREEMTIVE= 0x4
1.1 frystyk 49: } MRFlags;
50:
51: typedef struct _Robot {
52: HTRequest * request;
1.6.2.2 ! frystyk 53: HTRequest * timeout; /* Until we get a server eventloop */
1.1 frystyk 54: HTParentAnchor * anchor;
1.2 frystyk 55: int depth; /* How deep is our tree */
56: HTList * hyperdoc; /* List of our HyperDoc Objects */
1.4 frystyk 57: HTList * htext; /* List of our HText Objects */
1.1 frystyk 58: struct timeval * tv; /* Timeout on socket */
59: char * cwd; /* Current dir URL */
60: HTList * converters;
61: char * rules;
62: char * logfile;
63: char * outputfile;
64: FILE * output;
65: MRFlags flags;
66: } Robot;
67:
68: typedef enum _LoadState {
69: L_INVALID = -2,
70: L_LOADING = -1,
71: L_SUCCESS = 0,
72: L_ERROR
73: } LoadState;
74:
75: /*
76: ** The HyperDoc object is bound to the anchor and contains information about
77: ** where we are in the search for recursive searches
78: */
79: typedef struct _HyperDoc {
80: HTParentAnchor * anchor;
81: LoadState state;
82: int depth;
83: } HyperDoc;
84:
85: /*
86: ** This is the HText object that is created every time we start parsing a
87: ** HTML object
88: */
1.4 frystyk 89: struct _HText {
1.1 frystyk 90: HTRequest * request;
1.4 frystyk 91: };
1.1 frystyk 92:
93: PUBLIC HText * HTMainText = NULL;
94: PUBLIC HTParentAnchor * HTMainAnchor = NULL;
95: PUBLIC HTStyleSheet * styleSheet = NULL;
96:
97: /* ------------------------------------------------------------------------- */
98:
1.2 frystyk 99: /* Create a "HyperDoc" object
100: ** --------------------------
101: ** A HyperDoc object contains information about whether we have already
102: ** started checking the anchor and the depth in our search
103: */
104: PRIVATE HyperDoc * HyperDoc_new (Robot * mr,HTParentAnchor * anchor, int depth)
105: {
106: HyperDoc * hd;
107: if ((hd = (HyperDoc *) calloc(1, sizeof(HyperDoc))) == NULL)
108: outofmem(__FILE__, "HyperDoc_new");
109: hd->state = L_INVALID;
110: hd->depth = depth;
111:
112: /* Bind the HyperDoc object together with the Anchor Object */
113: hd->anchor = anchor;
114: HTAnchor_setDocument(anchor, (void *) hd);
115:
116: /* Add this HyperDoc object to our list */
117: if (!mr->hyperdoc) mr->hyperdoc = HTList_new();
118: HTList_addObject(mr->hyperdoc, (void *) hd);
119: return hd;
120: }
121:
122: /* Delete a "HyperDoc" object
123: ** --------------------------
124: */
125: PRIVATE BOOL HyperDoc_delete (HyperDoc * hd)
126: {
127: if (hd) {
128: free (hd);
129: return YES;
130: }
131: return NO;
132: }
133:
1.1 frystyk 134: /* Create a Command Line Object
135: ** ----------------------------
136: */
137: PRIVATE Robot * Robot_new (void)
138: {
139: Robot * me;
140: if ((me = (Robot *) calloc(1, sizeof(Robot))) == NULL ||
141: (me->tv = (struct timeval*) calloc(1, sizeof(struct timeval))) == NULL)
142: outofmem(__FILE__, "Robot_new");
1.2 frystyk 143: me->hyperdoc = HTList_new();
1.4 frystyk 144: me->htext = HTList_new();
1.1 frystyk 145: me->tv->tv_sec = DEFAULT_TIMEOUT;
146: me->cwd = HTFindRelatedName();
147: me->output = OUTPUT;
148:
1.6.2.2 ! frystyk 149: /* We keep an extra timeout request object for the timeout_handler */
! 150: me->timeout = HTRequest_new();
! 151: HTRequest_setContext (me->timeout, me);
! 152:
1.1 frystyk 153: /* Bind the Robot object together with the Request Object */
154: me->request = HTRequest_new();
155: HTRequest_setContext (me->request, me);
156: return me;
157: }
158:
159: /* Delete a Command Line Object
160: ** ----------------------------
161: */
162: PRIVATE BOOL Robot_delete (Robot * me)
163: {
164: if (me) {
1.2 frystyk 165: if (me->hyperdoc) {
166: HTList * cur = me->hyperdoc;
167: HyperDoc * pres;
168: while ((pres = (HyperDoc *) HTList_nextObject(cur)))
169: HyperDoc_delete(pres);
170: HTList_delete(me->hyperdoc);
171: }
1.4 frystyk 172: if (me->htext) {
173: HTList * cur = me->htext;
174: HText * pres;
175: while ((pres = (HText *) HTList_nextObject(cur)))
176: HText_free(pres);
177: HTList_delete(me->htext);
178: }
1.1 frystyk 179: if (me->logfile) HTLog_close();
180: if (me->output && me->output != STDOUT) fclose(me->output);
181: FREE(me->cwd);
182: free(me->tv);
183: free(me);
184: return YES;
185: }
186: return NO;
187: }
188:
1.2 frystyk 189: /*
190: ** This function creates a new request object and initializes it
191: */
192: PRIVATE HTRequest * Thread_new (Robot * mr, HTMethod method)
193: {
194: HTRequest * newreq = HTRequest_new();
195: HTRequest_setContext (newreq, mr);
196: if (mr->flags & MR_PREEMTIVE) HTRequest_setPreemtive(newreq, YES);
1.5 frystyk 197: HTRequest_addRqHd(newreq, HT_C_HOST);
1.2 frystyk 198: HTRequest_setMethod(newreq, method);
199: return newreq;
200: }
201:
202: PRIVATE BOOL Thread_delete (Robot * mr, HTRequest * request)
203: {
204: if (mr && request) {
205: HTRequest_delete(request);
206: return YES;
207: }
208: return NO;
209: }
210:
211: /*
212: ** Cleanup and make sure we close all connections including the persistent
213: ** ones
214: */
1.1 frystyk 215: PRIVATE void Cleanup (Robot * me, int status)
216: {
1.2 frystyk 217: HTNet_killAll();
1.1 frystyk 218: Robot_delete(me);
219: HTLibTerminate();
220: #ifdef VMS
221: exit(status ? status : 1);
222: #else
223: exit(status ? status : 0);
224: #endif
225: }
226:
227: #ifdef CATCH_SIG
228: #include <signal.h>
229: /* SetSignal
230: ** This function sets up signal handlers. This might not be necessary to
231: ** call if the application has its own handlers (lossage on SVR4)
232: */
233: PRIVATE void SetSignal (void)
234: {
235: /* On some systems (SYSV) it is necessary to catch the SIGPIPE signal
236: ** when attemting to connect to a remote host where you normally should
237: ** get `connection refused' back
238: */
239: if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
240: if (PROT_TRACE) TTYPrint(TDEST, "HTSignal.... Can't catch SIGPIPE\n");
241: } else {
242: if (PROT_TRACE) TTYPrint(TDEST, "HTSignal.... Ignoring SIGPIPE\n");
243: }
244: }
245: #endif /* CATCH_SIG */
246:
247: PRIVATE void VersionInfo (void)
248: {
249: TTYPrint(OUTPUT,"\n\nW3C Reference Software\n\n");
250: TTYPrint(OUTPUT,"\tW3C Mini Robot (%s) version %s.\n",
251: APP_NAME, APP_VERSION);
252: TTYPrint(OUTPUT,"\tW3C Reference Library version %s.\n\n",HTLib_version());
253: TTYPrint(OUTPUT,"Please send feedback to <libwww@w3.org>\n");
254: }
255:
256: /* terminate_handler
257: ** -----------------
1.2 frystyk 258: ** This function is registered to handle the result of the request.
259: ** If no more requests are pending then terminate program
1.1 frystyk 260: */
261: PRIVATE int terminate_handler (HTRequest * request, int status)
262: {
263: Robot * mr = (Robot *) HTRequest_context(request);
264: if (mr->logfile) HTLog_add(request, status);
1.2 frystyk 265: Thread_delete(mr, request);
1.3 frystyk 266: if (HTNet_isEmpty()) Cleanup(mr, 0);
1.1 frystyk 267: return HT_OK;
268: }
269:
270: /* timeout_handler
271: ** ---------------
272: ** This function is registered to handle timeout in select eventloop
1.6.2.1 frystyk 273: **
274: ** BUG: This doesn't work as we don't get the right request object
275: ** back from the event loop
1.1 frystyk 276: */
277: PRIVATE int timeout_handler (HTRequest * request)
278: {
1.2 frystyk 279: Robot * mr = (Robot *) HTRequest_context(request);
280: if (SHOW_MSG) TTYPrint(TDEST, "Robot....... Request timeout...\n");
1.6.2.1 frystyk 281: #if 0
1.1 frystyk 282: HTRequest_kill(request);
1.2 frystyk 283: Thread_delete(mr, request);
1.6.2.1 frystyk 284: #endif
1.6.2.2 ! frystyk 285: Cleanup(mr, -1);
1.4 frystyk 286: return HT_OK;
1.1 frystyk 287: }
288:
289: /* ------------------------------------------------------------------------- */
290: /* HTEXT INTERFACE */
291: /* ------------------------------------------------------------------------- */
292:
293: PUBLIC HText * HText_new2 (HTRequest * request, HTParentAnchor * anchor,
294: HTStream * stream)
295: {
296: HText * me;
1.4 frystyk 297: Robot * mr = (Robot *) HTRequest_context(request);
1.1 frystyk 298: if ((me = (HText *) calloc(1, sizeof(HText))) == NULL)
299: outofmem(__FILE__, "HText_new2");
1.4 frystyk 300:
301: /* Bind the HText object together with the Request Object */
1.1 frystyk 302: me->request = request;
1.4 frystyk 303:
304: /* Add this HyperDoc object to our list */
305: if (!mr->htext) mr->htext = HTList_new();
306: HTList_addObject(mr->htext, (void *) me);
1.1 frystyk 307: return me;
308: }
309:
1.4 frystyk 310: PUBLIC void HText_free (HText * me) {
311: if (me) free (me);
312: }
313:
1.1 frystyk 314: PUBLIC void HText_beginAnchor (HText * text, HTChildAnchor * anchor)
315: {
316: if (text && anchor) {
1.2 frystyk 317: Robot * mr = (Robot *) HTRequest_context(text->request);
1.1 frystyk 318: HTAnchor * dest = HTAnchor_followMainLink((HTAnchor *) anchor);
319: HTParentAnchor * dest_parent = HTAnchor_parent(dest);
1.6.2.1 frystyk 320: char * uri = HTAnchor_address((HTAnchor *) dest_parent);
1.1 frystyk 321: HyperDoc * hd = HTAnchor_document(dest_parent);
322:
1.6.2.1 frystyk 323: if (SHOW_MSG) TTYPrint(TDEST, "Robot....... Found `%s\' - ", uri ? uri : "NULL");
324:
1.2 frystyk 325: /* Test whether we already have a hyperdoc for this document */
326: if (mr->flags & MR_LINK && dest_parent && !hd) {
1.1 frystyk 327: HTParentAnchor * parent = HTRequest_parent(text->request);
328: HyperDoc * last = HTAnchor_document(parent);
329: int depth = last ? last->depth+1 : 0;
1.2 frystyk 330: HTRequest * newreq = Thread_new(mr, METHOD_GET);
331: HyperDoc_new(mr, dest_parent, depth);
1.6.2.1 frystyk 332: HTRequest_setParent(newreq, HTRequest_anchor(text->request));
333: if (depth >= mr->depth) {
334: if (SHOW_MSG)
335: TTYPrint(TDEST, "loading at depth %d using HEAD\n", depth);
336: HTRequest_setMethod(newreq, METHOD_HEAD);
337: HTRequest_setOutputFormat(newreq, WWW_MIME);
338: } else {
339: if (SHOW_MSG) TTYPrint(TDEST, "loading at depth %d\n", depth);
1.2 frystyk 340: }
341: if (HTLoadAnchor((HTAnchor *) dest_parent, newreq) != YES) {
1.6.2.1 frystyk 342: if (SHOW_MSG) TTYPrint(TDEST, "not tested!\n");
1.2 frystyk 343: Thread_delete(mr, newreq);
344: }
1.6.2.1 frystyk 345: } else {
346: if (SHOW_MSG) TTYPrint(TDEST, "duplicate\n");
1.2 frystyk 347: }
1.6.2.1 frystyk 348: FREE(uri);
1.2 frystyk 349: }
350: }
351:
352: PUBLIC void HText_appendImage (HText * text, HTChildAnchor * anchor,
353: CONST char *alt, CONST char * align, BOOL isMap)
354: {
355: if (text && anchor) {
356: Robot * mr = (Robot *) HTRequest_context(text->request);
357: HTParentAnchor * dest = (HTParentAnchor *)
358: HTAnchor_followMainLink((HTAnchor *) anchor);
359: HyperDoc * hd = HTAnchor_document(dest);
1.1 frystyk 360:
1.2 frystyk 361: /* Test whether we already have a hyperdoc for this document */
362: if (mr->flags & MR_IMG && dest && !hd) {
363: HTParentAnchor * parent = HTRequest_parent(text->request);
364: HyperDoc * last = HTAnchor_document(parent);
365: int depth = last ? last->depth+1 : 0;
366: HTRequest * newreq = Thread_new(mr, METHOD_HEAD);
367: HyperDoc_new(mr, dest, depth);
368: if (SHOW_MSG) {
369: char * uri = HTAnchor_address((HTAnchor *) dest);
370: TTYPrint(TDEST, "Robot....... Checking Image `%s\'\n", uri);
371: free(uri);
372: }
373: if (HTLoadAnchor((HTAnchor *) dest, newreq) != YES) {
374: if (SHOW_MSG)
375: TTYPrint(TDEST, "Robot....... Image not tested!\n");
376: Thread_delete(mr, newreq);
1.1 frystyk 377: }
378: }
379: }
380: }
381:
382: PUBLIC void HText_endAnchor (HText * text) {}
383: PUBLIC void HText_appendText (HText * text, CONST char * str) {}
384: PUBLIC void HText_appendCharacter (HText * text, char ch) {}
385: PUBLIC void HText_endAppend (HText * text) {}
386: PUBLIC void HText_setStyle (HText * text, HTStyle * style) {}
387: PUBLIC void HText_beginAppend (HText * text) {}
388: PUBLIC void HText_appendParagraph (HText * text) {}
389:
390: /* ------------------------------------------------------------------------- */
391: /* MAIN PROGRAM */
392: /* ------------------------------------------------------------------------- */
393:
394: int main (int argc, char ** argv)
395: {
396: int status = 0;
397: int arg;
398: HTChunk * keywords = NULL; /* From command line */
399: int keycnt = 0;
400: Robot * mr = Robot_new(); /* Create new Robot instance */
401:
402: /* Starts Mac GUSI socket library */
403: #ifdef GUSI
404: GUSISetup(GUSIwithSIOUXSockets);
405: GUSISetup(GUSIwithInternetSockets);
406: #endif
407:
408: #ifdef __MWERKS__ /* STR */
409: InitGraf((Ptr) &qd.thePort);
410: InitFonts();
411: InitWindows();
412: InitMenus(); TEInit();
413: InitDialogs(nil);
414: InitCursor();
415: SIOUXSettings.asktosaveonclose = false;
416: argc=ccommand(&argv);
417: #endif
418:
419: /* Initiate W3C Reference Library */
420: HTLibInit(APP_NAME, APP_VERSION);
421:
422: /* Initialize the protocol modules */
423: HTAccessInit();
424:
425: /* Initialize set of converters */
426: mr->converters = HTList_new();
427: HTConverterInit(mr->converters);
428: HTFormat_setConversion(mr->converters);
429:
430: /* Initialize bindings between file suffixes and media types */
431: HTFileInit();
432:
433: /* Get any proxy or gateway environment variables */
434: HTProxy_getEnvVar();
435:
436: /* Scan command Line for parameters */
437: for (arg=1; arg<argc; arg++) {
438: if (*argv[arg] == '-') {
439:
440: /* -? or -help: show the command line help page */
441: if (!strcmp(argv[arg],"-?") || !strcmp(argv[arg],"-help")) {
442: mr->anchor = (HTParentAnchor *) HTAnchor_findAddress(HELP);
443: keycnt = 1;
444:
445: /* non-interactive */
446: } else if (!strcmp(argv[arg], "-n")) {
447: HTAlert_setInteractive(NO);
448:
449: /* log file */
450: } else if (!strcmp(argv[arg], "-l")) {
451: mr->logfile = (arg+1 < argc && *argv[arg+1] != '-') ?
452: argv[++arg] : DEFAULT_LOG_FILE;
453:
454: /* rule file */
455: } else if (!strcmp(argv[arg], "-r")) {
456: mr->rules = (arg+1 < argc && *argv[arg+1] != '-') ?
457: argv[++arg] : DEFAULT_RULE_FILE;
458:
459: /* output filename */
460: } else if (!strcmp(argv[arg], "-o")) {
461: mr->outputfile = (arg+1 < argc && *argv[arg+1] != '-') ?
462: argv[++arg] : DEFAULT_OUTPUT_FILE;
463:
464: /* timeout -- Change the default request timeout */
465: } else if (!strcmp(argv[arg], "-timeout")) {
466: int timeout = (arg+1 < argc && *argv[arg+1] != '-') ?
467: atoi(argv[++arg]) : DEFAULT_TIMEOUT;
468: if (timeout > 0) mr->tv->tv_sec = timeout;
469:
470: /* preemtive or non-preemtive access */
471: } else if (!strcmp(argv[arg], "-single")) {
472: HTRequest_setPreemtive(mr->request, YES);
1.2 frystyk 473: mr->flags |= MR_PREEMTIVE;
474:
475: /* test inlined images */
476: } else if (!strcmp(argv[arg], "-img")) {
477: mr->flags |= MR_IMG;
478:
479: /* load anchors */
480: } else if (!strcmp(argv[arg], "-link")) {
481: mr->flags |= MR_LINK;
1.6.2.1 frystyk 482: mr->depth = (arg+1 < argc && *argv[arg+1] != '-') ?
483: atoi(argv[++arg]) : DEFAULT_DEPTH;
1.2 frystyk 484:
485: /* preemtive or non-preemtive access */
486: } else if (!strcmp(argv[arg], "-single")) {
487: HTRequest_setPreemtive(mr->request, YES);
488: mr->flags |= MR_PREEMTIVE;
1.1 frystyk 489:
490: /* print version and exit */
491: } else if (!strcmp(argv[arg], "-version")) {
492: VersionInfo();
493: Cleanup(mr, 0);
494:
495: #ifdef WWWTRACE
496: /* trace flags */
497: } else if (!strncmp(argv[arg], "-v", 2)) {
498: char *p = argv[arg]+2;
499: WWWTRACE = 0;
500: for(; *p; p++) {
501: switch (*p) {
502: case 'a': WWWTRACE |= SHOW_ANCHOR_TRACE; break;
503: case 'b': WWWTRACE |= SHOW_BIND_TRACE; break;
504: case 'c': WWWTRACE |= SHOW_CACHE_TRACE; break;
505: case 'g': WWWTRACE |= SHOW_SGML_TRACE; break;
506: case 'p': WWWTRACE |= SHOW_PROTOCOL_TRACE; break;
507: case 's': WWWTRACE |= SHOW_STREAM_TRACE; break;
508: case 't': WWWTRACE |= SHOW_THREAD_TRACE; break;
509: case 'u': WWWTRACE |= SHOW_URI_TRACE; break;
510: default:
511: if (SHOW_MSG)
512: TTYPrint(TDEST,"Bad parameter (%s) in -v option\n",
513: argv[arg]);
514: }
515: }
516: if (!WWWTRACE) WWWTRACE = SHOW_ALL_TRACE;
517: #endif
518:
519: } else {
520: if (SHOW_MSG) TTYPrint(TDEST,"Bad Argument (%s)\n", argv[arg]);
521: }
522: } else { /* If no leading `-' then check for URL or keywords */
523: if (!keycnt) {
524: char * ref = HTParse(argv[arg], mr->cwd, PARSE_ALL);
525: mr->anchor = (HTParentAnchor *) HTAnchor_findAddress(ref);
1.6.2.1 frystyk 526: HyperDoc_new(mr, mr->anchor, 0);
1.1 frystyk 527: keycnt = 1;
528: FREE(ref);
529: } else { /* Check for successive keyword arguments */
530: char *escaped = HTEscape(argv[arg], URL_XALPHAS);
531: if (keycnt++ <= 1)
1.5 frystyk 532: keywords = HTChunk_new(128);
1.1 frystyk 533: else
1.5 frystyk 534: HTChunk_putc(keywords, ' ');
535: HTChunk_puts(keywords, HTStrip(escaped));
1.1 frystyk 536: free(escaped);
537: }
538: }
539: }
540:
541: #ifdef CATCH_SIG
542: SetSignal();
543: #endif
544:
545: if (!keycnt) {
1.2 frystyk 546: if (SHOW_MSG) TTYPrint(TDEST, "Please specify URL to check.\n");
1.1 frystyk 547: Cleanup(mr, -1);
548: }
549:
550: /* Rule file specified? */
551: if (mr->rules) {
552: HTList * list = HTList_new();
553: HTRequest * rr = HTRequest_new();
554: char * rules = HTParse(mr->rules, mr->cwd, PARSE_ALL);
555: HTParentAnchor * ra = (HTParentAnchor *) HTAnchor_findAddress(rules);
556: HTRequest_setPreemtive(rr, YES);
557: HTConversion_add(list, "application/x-www-rules", "*/*", HTRules,
558: 1.0, 0.0, 0.0);
559: HTRequest_setConversion(rr, list, YES);
560: if (HTLoadAnchor((HTAnchor *) ra, rr) != YES)
561: if (SHOW_MSG) TTYPrint(TDEST, "Can't access rules\n");
562: HTConversion_deleteAll(list);
563: HTRequest_delete(rr);
564: FREE(rules);
565: }
566:
567: /* Output file specified? */
568: if (mr->outputfile) {
569: if ((mr->output = fopen(mr->outputfile, "wb")) == NULL) {
570: if (SHOW_MSG) TTYPrint(TDEST, "Can't open `%s'\n", mr->outputfile);
571: mr->output = OUTPUT;
572: }
573: }
574:
575: /* Set up the output */
576: HTRequest_setOutputStream(mr->request, HTFWriter_new(mr->output, YES));
577:
578: /* Log file specifed? */
579: if (mr->logfile) HTLog_open(mr->logfile, YES, YES);
580:
581: /* Register our User Prompts etc in the Alert Manager */
582: if (HTAlert_interactive()) {
583: HTAlert_add(HTError_print, HT_A_MESSAGE);
584: HTAlert_add(HTConfirm, HT_A_CONFIRM);
585: HTAlert_add(HTPrompt, HT_A_PROMPT);
586: HTAlert_add(HTPromptPassword, HT_A_SECRET);
587: HTAlert_add(HTPromptUsernameAndPassword, HT_A_USER_PW);
588: }
589:
590: /* Register a call back function for the Net Manager */
591: HTNetCall_addAfter(terminate_handler, HT_ALL);
592:
593: /* Set timeout on sockets */
1.6.2.2 ! frystyk 594: HTEvent_registerTimeout(mr->tv, mr->timeout, timeout_handler, NO);
1.1 frystyk 595:
596: /* Start the request */
597: if (keywords) /* Search */
1.5 frystyk 598: status = HTSearch(HTChunk_data(keywords), mr->anchor, mr->request);
1.1 frystyk 599: else
600: status = HTLoadAnchor((HTAnchor *) mr->anchor, mr->request);
601:
1.5 frystyk 602: if (keywords) HTChunk_delete(keywords);
1.1 frystyk 603: if (status != YES) {
604: if (SHOW_MSG) TTYPrint(TDEST, "Can't access resource\n");
605: Cleanup(mr, -1);
606: }
607:
608: /* Go into the event loop... */
609: HTEvent_Loop(mr->request);
610:
611: /* Only gets here if event loop fails */
612: Cleanup(mr, 0);
613: return 0;
614: }
Webmaster