summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/lynx/WWW/Library/Implementation/HTGopher.c
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/usr.bin/lynx/WWW/Library/Implementation/HTGopher.c')
-rw-r--r--gnu/usr.bin/lynx/WWW/Library/Implementation/HTGopher.c1432
1 files changed, 720 insertions, 712 deletions
diff --git a/gnu/usr.bin/lynx/WWW/Library/Implementation/HTGopher.c b/gnu/usr.bin/lynx/WWW/Library/Implementation/HTGopher.c
index f98a0c72977..b9bdeb48c79 100644
--- a/gnu/usr.bin/lynx/WWW/Library/Implementation/HTGopher.c
+++ b/gnu/usr.bin/lynx/WWW/Library/Implementation/HTGopher.c
@@ -1,19 +1,19 @@
/* GOPHER ACCESS HTGopher.c
-** =============
-**
-** History:
-** 26 Sep 90 Adapted from other accesses (News, HTTP) TBL
-** 29 Nov 91 Downgraded to C, for portable implementation.
-** 10 Mar 96 Foteos Macrides (macrides@sci.wfbr.edu). Added a
-** form-based CSO/PH gateway. Can be invoked via a
-** "cso://host[:port]/" or "gopher://host:105/2"
-** URL. If a gopher URL is used with a query token
-** ('?'), the old ISINDEX procedure will be used
-** instead of the form-based gateway.
-** 15 Mar 96 Foteos Macrides (macrides@sci.wfbr.edu). Pass
-** port 79, gtype 0 gopher URLs to the finger
-** gateway.
-*/
+ * =============
+ *
+ * History:
+ * 26 Sep 90 Adapted from other accesses (News, HTTP) TBL
+ * 29 Nov 91 Downgraded to C, for portable implementation.
+ * 10 Mar 96 Foteos Macrides (macrides@sci.wfbr.edu). Added a
+ * form-based CSO/PH gateway. Can be invoked via a
+ * "cso://host[:port]/" or "gopher://host:105/2"
+ * URL. If a gopher URL is used with a query token
+ * ('?'), the old ISINDEX procedure will be used
+ * instead of the form-based gateway.
+ * 15 Mar 96 Foteos Macrides (macrides@sci.wfbr.edu). Pass
+ * port 79, gtype 0 gopher URLs to the finger
+ * gateway.
+ */
#include <HTUtils.h> /* Coding convention macros */
@@ -24,8 +24,8 @@
#include <HTFinger.h>
/*
-** Implements.
-*/
+ * Implements.
+ */
#include <HTGopher.h>
#define GOPHER_PORT 70 /* See protocol spec */
@@ -34,8 +34,8 @@
#define LINE_LENGTH 256 /* Bug */
/*
-** Gopher entity types.
-*/
+ * Gopher entity types.
+ */
#define GOPHER_TEXT '0'
#define GOPHER_MENU '1'
#define GOPHER_CSO '2'
@@ -47,15 +47,15 @@
#define GOPHER_TELNET '8'
#define GOPHER_BINARY '9'
#define GOPHER_GIF 'g'
-#define GOPHER_HTML 'h' /* HTML */
-#define GOPHER_CHTML 'H' /* HTML */
+#define GOPHER_HTML 'h' /* HTML */
+#define GOPHER_CHTML 'H' /* HTML */
#define GOPHER_SOUND 's'
-#define GOPHER_WWW 'w' /* W3 address */
+#define GOPHER_WWW 'w' /* W3 address */
#define GOPHER_IMAGE 'I'
#define GOPHER_TN3270 'T'
#define GOPHER_INFO 'i'
#define GOPHER_DUPLICATE '+'
-#define GOPHER_PLUS_IMAGE ':' /* Addition from Gopher Plus */
+#define GOPHER_PLUS_IMAGE ':' /* Addition from Gopher Plus */
#define GOPHER_PLUS_MOVIE ';'
#define GOPHER_PLUS_SOUND '<'
#define GOPHER_PLUS_PDF 'P'
@@ -63,8 +63,8 @@
#include <HTFormat.h>
/*
-** Hypertext object building machinery.
-*/
+ * Hypertext object building machinery.
+ */
#include <HTML.h>
#include <LYStrings.h>
@@ -77,136 +77,133 @@
#define END(e) (*targetClass.end_element)(target, e, 0)
#define FREE_TARGET (*targetClass._free)(target)
-#define GOPHER_PROGRESS(foo) HTAlert(foo)
-
#define NEXT_CHAR HTGetCharacter()
/*
-** Module-wide variables.
-*/
-PRIVATE int s; /* Socket for gopher or CSO host */
+ * Module-wide variables.
+ */
+static int s; /* Socket for gopher or CSO host */
struct _HTStructured {
- CONST HTStructuredClass * isa; /* For gopher streams */
- /* ... */
+ const HTStructuredClass *isa; /* For gopher streams */
+ /* ... */
};
-PRIVATE HTStructured *target; /* the new gopher hypertext */
-PRIVATE HTStructuredClass targetClass; /* Its action routines */
+static HTStructured *target; /* the new gopher hypertext */
+static HTStructuredClass targetClass; /* Its action routines */
-struct _HTStream
-{
- HTStreamClass * isa; /* For form-based CSO gateway - FM */
+struct _HTStream {
+ HTStreamClass *isa; /* For form-based CSO gateway - FM */
};
-typedef struct _CSOfield_info { /* For form-based CSO gateway - FM */
- struct _CSOfield_info * next;
- char * name;
- char * attributes;
- char * description;
- int id;
- int lookup;
- int indexed;
- int url;
- int max_size;
- int defreturn;
- int explicit_return;
- int reserved;
- int public;
- char name_buf[16]; /* Avoid malloc if we can */
- char desc_buf[32]; /* Avoid malloc if we can */
- char attr_buf[80]; /* Avoid malloc if we can */
+typedef struct _CSOfield_info { /* For form-based CSO gateway - FM */
+ struct _CSOfield_info *next;
+ char *name;
+ char *attributes;
+ char *description;
+ int id;
+ int lookup;
+ int indexed;
+ int url;
+ int max_size;
+ int defreturn;
+ int explicit_return;
+ int reserved;
+ int gpublic;
+ char name_buf[16]; /* Avoid malloc if we can */
+ char desc_buf[32]; /* Avoid malloc if we can */
+ char attr_buf[80]; /* Avoid malloc if we can */
} CSOfield_info;
-PRIVATE CSOfield_info *CSOfields = NULL; /* For form-based CSO gateway - FM */
-
-typedef struct _CSOformgen_context { /* For form-based CSO gateway - FM */
- char * host;
- char * seek;
- CSOfield_info * fld;
- int port;
- int cur_line;
- int cur_off;
- int rep_line;
- int rep_off;
- int public_override;
- int field_select;
+static CSOfield_info *CSOfields = NULL; /* For form-based CSO gateway - FM */
+
+typedef struct _CSOformgen_context { /* For form-based CSO gateway - FM */
+ char *host;
+ char *seek;
+ CSOfield_info *fld;
+ int port;
+ int cur_line;
+ int cur_off;
+ int rep_line;
+ int rep_off;
+ int public_override;
+ int field_select;
} CSOformgen_context;
/* Matrix of allowed characters in filenames
-** =========================================
-*/
-PRIVATE BOOL acceptable[256];
-PRIVATE BOOL acceptable_inited = NO;
+ * =========================================
+ */
+static BOOL acceptable[256];
+static BOOL acceptable_inited = NO;
-PRIVATE void init_acceptable NOARGS
+static void init_acceptable(void)
{
unsigned int i;
- char * good =
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./-_$";
- for(i = 0; i < 256; i++)
+ const char *good =
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./-_$";
+
+ for (i = 0; i < 256; i++)
acceptable[i] = NO;
- for(; *good; good++)
- acceptable[(unsigned int)*good] = YES;
+ for (; *good; good++)
+ acceptable[(unsigned int) *good] = YES;
acceptable_inited = YES;
}
/* Decode one hex character
-** ========================
-*/
-PRIVATE CONST char hex[17] = "0123456789abcdef";
+ * ========================
+ */
+static const char hex[17] = "0123456789abcdef";
-PRIVATE char from_hex ARGS1(char, c)
+static char from_hex(char c)
{
- return (char) ( (c>='0')&&(c<='9') ? c-'0'
- : (c>='A')&&(c<='F') ? c-'A'+10
- : (c>='a')&&(c<='f') ? c-'a'+10
- : 0);
+ return (char) ((c >= '0') && (c <= '9') ? c - '0'
+ : (c >= 'A') && (c <= 'F') ? c - 'A' + 10
+ : (c >= 'a') && (c <= 'f') ? c - 'a' + 10
+ : 0);
}
/* Paste in an Anchor
-** ==================
-**
-** The title of the destination is set, as there is no way
-** of knowing what the title is when we arrive.
-**
-** On entry,
-** HT is in append mode.
-** text points to the text to be put into the file, 0 terminated.
-** addr points to the hypertext refernce address 0 terminated.
-*/
-PUBLIC BOOLEAN HT_Is_Gopher_URL=FALSE;
-
-PRIVATE void write_anchor ARGS2(CONST char *,text, CONST char *,addr)
+ * ==================
+ *
+ * The title of the destination is set, as there is no way
+ * of knowing what the title is when we arrive.
+ *
+ * On entry,
+ * HT is in append mode.
+ * text points to the text to be put into the file, 0 terminated.
+ * addr points to the hypertext refernce address 0 terminated.
+ */
+BOOLEAN HT_Is_Gopher_URL = FALSE;
+
+static void write_anchor(const char *text, const char *addr)
{
BOOL present[HTML_A_ATTRIBUTES];
- CONST char * value[HTML_A_ATTRIBUTES];
+ const char *value[HTML_A_ATTRIBUTES];
int i;
for (i = 0; i < HTML_A_ATTRIBUTES; i++)
present[i] = 0;
present[HTML_A_HREF] = YES;
- ((CONST char **)value)[HTML_A_HREF] = addr;
+ ((const char **) value)[HTML_A_HREF] = addr;
present[HTML_A_TITLE] = YES;
- ((CONST char **)value)[HTML_A_TITLE] = text;
+ ((const char **) value)[HTML_A_TITLE] = text;
- CTRACE((tfp,"HTGopher: adding URL: %s\n",addr));
+ CTRACE((tfp, "HTGopher: adding URL: %s\n", addr));
- HT_Is_Gopher_URL = TRUE; /* tell HTML.c that this is a Gopher URL */
- (*targetClass.start_element)(target, HTML_A, present,
- (CONST char **)value, -1, 0);
+ HT_Is_Gopher_URL = TRUE; /* tell HTML.c that this is a Gopher URL */
+ (*targetClass.start_element) (target, HTML_A, present,
+ (const char **) value, -1, 0);
PUTS(text);
END(HTML_A);
}
/* Parse a Gopher Menu document
-** ============================
-*/
-PRIVATE void parse_menu ARGS2(
- CONST char *, arg GCC_UNUSED,
- HTParentAnchor *, anAnchor)
+ * ============================
+ */
+static void parse_menu(const char *arg GCC_UNUSED,
+ HTParentAnchor *anAnchor)
{
char gtype;
int ich;
@@ -215,7 +212,7 @@ PRIVATE void parse_menu ARGS2(
char *host = NULL;
char *port;
char *p = line;
- CONST char *title;
+ const char *title;
int bytes = 0;
int BytesReported = 0;
char buffer[128];
@@ -223,7 +220,6 @@ PRIVATE void parse_menu ARGS2(
#define TAB '\t'
#define HEX_ESCAPE '%'
-
START(HTML_HTML);
PUTC('\n');
START(HTML_HEAD);
@@ -248,21 +244,22 @@ PRIVATE void parse_menu ARGS2(
END(HTML_H1);
PUTC('\n');
START(HTML_PRE);
- PUTC('\n'); /* newline after HTML_PRE forces split-line */
- while ((ich=NEXT_CHAR) != EOF) {
+ while ((ich = NEXT_CHAR) != EOF) {
if (interrupted_in_htgetcharacter) {
- CTRACE((tfp, "HTGopher: Interrupted in HTGetCharacter, apparently.\n"));
+ CTRACE((tfp,
+ "HTGopher: Interrupted in HTGetCharacter, apparently.\n"));
goto end_html;
}
- if ((char)ich != LF) {
- *p = (char) ich; /* Put character in line */
- if (p< &line[BIG-1]) p++;
+ if ((char) ich != LF) {
+ *p = (char) ich; /* Put character in line */
+ if (p < &line[BIG - 1])
+ p++;
} else {
*p++ = '\0'; /* Terminate line */
- bytes += p-line; /* add size */
+ bytes += p - line; /* add size */
p = line; /* Scan it to parse it */
port = 0; /* Flag "not parsed" */
CTRACE((tfp, "HTGopher: Menu item: %s\n", line));
@@ -275,14 +272,14 @@ PRIVATE void parse_menu ARGS2(
}
/* Break on line with a dot by itself */
- if ((gtype=='.') && ((*p=='\r') || (*p==0)))
+ if ((gtype == '.') && ((*p == '\r') || (*p == 0)))
break;
if (gtype && *p) {
name = p;
selector = strchr(name, TAB);
if (selector) {
- *selector++ = '\0'; /* Terminate name */
+ *selector++ = '\0'; /* Terminate name */
/*
* Gopher+ Type=0+ objects can be binary, and will
* have 9 or 5 beginning their selector. Make sure
@@ -294,23 +291,26 @@ PRIVATE void parse_menu ARGS2(
gtype = *selector;
host = strchr(selector, TAB);
if (host) {
- *host++ = '\0'; /* Terminate selector */
+ *host++ = '\0'; /* Terminate selector */
port = strchr(host, TAB);
if (port) {
char *junk;
+
port[0] = ':'; /* delimit host a la W3 */
junk = strchr(port, TAB);
- if (junk) *junk++ = '\0'; /* Chop port */
- if ((port[1]=='0') && (!port[2]))
- port[0] = '\0'; /* 0 means none */
- } /* no port */
- } /* host ok */
- } /* selector ok */
- } /* gtype and name ok */
-
+ if (junk)
+ *junk++ = '\0'; /* Chop port */
+ if ((port[1] == '0') && (!port[2]))
+ port[0] = '\0'; /* 0 means none */
+ } /* no port */
+ } /* host ok */
+ } /* selector ok */
+ }
+ /* gtype and name ok */
/* Nameless files are a separator line */
if (gtype == GOPHER_TEXT) {
- int i = strlen(name)-1;
+ int i = strlen(name) - 1;
+
while (name[i] == ' ' && i >= 0)
name[i--] = '\0';
if (i < 0)
@@ -322,112 +322,109 @@ PRIVATE void parse_menu ARGS2(
write_anchor(name, selector);
} else if (gtype == GOPHER_INFO) {
- /* Information or separator line */
+ /* Information or separator line */
PUTS(" ");
PUTS(name);
- } else if (port) { /* Other types need port */
+ } else if (port) { /* Other types need port */
char *address = 0;
- char *format = *selector ? "%s//%s@%s/" : "%s//%s/";
+ const char *format = *selector ? "%s//%s@%s/" : "%s//%s/";
if (gtype == GOPHER_TELNET) {
PUTS(" (TEL) ");
HTSprintf0(&address, format, STR_TELNET_URL, selector, host);
- }
- else if (gtype == GOPHER_TN3270)
- {
+ } else if (gtype == GOPHER_TN3270) {
PUTS("(3270) ");
HTSprintf0(&address, format, STR_TN3270_URL, selector, host);
- }
- else { /* If parsed ok */
+ } else { /* If parsed ok */
char *r;
- switch(gtype) {
- case GOPHER_TEXT:
- PUTS("(FILE) ");
- break;
- case GOPHER_MENU:
- PUTS(" (DIR) ");
- break;
- case GOPHER_CSO:
- PUTS(" (CSO) ");
- break;
- case GOPHER_PCBINARY:
- PUTS(" (BIN) ");
- break;
- case GOPHER_UUENCODED:
- PUTS(" (UUE) ");
- break;
- case GOPHER_INDEX:
- PUTS(" (?) ");
- break;
- case GOPHER_BINARY:
- PUTS(" (BIN) ");
- break;
- case GOPHER_GIF:
- case GOPHER_IMAGE:
- case GOPHER_PLUS_IMAGE:
- PUTS(" (IMG) ");
- break;
- case GOPHER_SOUND:
- case GOPHER_PLUS_SOUND:
- PUTS(" (SND) ");
- break;
- case GOPHER_MACBINHEX:
- PUTS(" (HQX) ");
- break;
- case GOPHER_HTML:
- case GOPHER_CHTML:
- PUTS("(HTML) ");
- break;
- case 'm':
- PUTS("(MIME) ");
- break;
- case GOPHER_PLUS_MOVIE:
- PUTS(" (MOV) ");
- break;
- case GOPHER_PLUS_PDF:
- PUTS(" (PDF) ");
- break;
- default:
- PUTS("(UNKN) ");
- break;
+ switch (gtype) {
+ case GOPHER_TEXT:
+ PUTS("(FILE) ");
+ break;
+ case GOPHER_MENU:
+ PUTS(" (DIR) ");
+ break;
+ case GOPHER_CSO:
+ PUTS(" (CSO) ");
+ break;
+ case GOPHER_PCBINARY:
+ PUTS(" (BIN) ");
+ break;
+ case GOPHER_UUENCODED:
+ PUTS(" (UUE) ");
+ break;
+ case GOPHER_INDEX:
+ PUTS(" (?) ");
+ break;
+ case GOPHER_BINARY:
+ PUTS(" (BIN) ");
+ break;
+ case GOPHER_GIF:
+ case GOPHER_IMAGE:
+ case GOPHER_PLUS_IMAGE:
+ PUTS(" (IMG) ");
+ break;
+ case GOPHER_SOUND:
+ case GOPHER_PLUS_SOUND:
+ PUTS(" (SND) ");
+ break;
+ case GOPHER_MACBINHEX:
+ PUTS(" (HQX) ");
+ break;
+ case GOPHER_HTML:
+ case GOPHER_CHTML:
+ PUTS("(HTML) ");
+ break;
+ case 'm':
+ PUTS("(MIME) ");
+ break;
+ case GOPHER_PLUS_MOVIE:
+ PUTS(" (MOV) ");
+ break;
+ case GOPHER_PLUS_PDF:
+ PUTS(" (PDF) ");
+ break;
+ default:
+ PUTS("(UNKN) ");
+ break;
}
HTSprintf0(&address, "//%s/%c", host, gtype);
- for(r = selector; *r; r++) { /* Encode selector string */
+ for (r = selector; *r; r++) { /* Encode selector string */
if (acceptable[UCH(*r)]) {
HTSprintf(&address, "%c", *r);
} else {
HTSprintf(&address, "%c%c%c",
- HEX_ESCAPE, /* Means hex coming */
- hex[(TOASCII(*r)) >> 4],
- hex[(TOASCII(*r)) & 15]);
+ HEX_ESCAPE, /* Means hex coming */
+ hex[(TOASCII(*r)) >> 4],
+ hex[(TOASCII(*r)) & 15]);
}
}
}
/* Error response from Gopher doesn't deserve to
be a hyperlink. */
- if (strcmp (address, "gopher://error.host:1/0"))
+ if (strcmp(address, "gopher://error.host:1/0"))
write_anchor(name, address);
else
PUTS(name);
FREE(address);
- } else { /* parse error */
+ } else { /* parse error */
CTRACE((tfp, "HTGopher: Bad menu item.\n"));
PUTS(line);
- } /* parse error */
+ } /* parse error */
PUTC('\n');
- p = line; /* Start again at beginning of line */
+ p = line; /* Start again at beginning of line */
- } /* if end of line */
+ } /* if end of line */
- } /* Loop over characters */
+ } /* Loop over characters */
-end_html:
+ end_html:
END(HTML_PRE);
PUTC('\n');
END(HTML_BODY);
@@ -440,27 +437,26 @@ end_html:
}
/* Parse a Gopher CSO document from an ISINDEX query.
-** ==================================================
-**
-** Accepts an open socket to a CSO server waiting to send us
-** data and puts it on the screen in a reasonable manner.
-**
-** Perhaps this data can be automatically linked to some
-** other source as well???
-**
-** Taken from hacking by Lou Montulli@ukanaix.cc.ukans.edu
-** on XMosaic-1.1, and put on libwww 2.11 by Arthur Secret,
-** secret@dxcern.cern.ch .
-*/
-PRIVATE void parse_cso ARGS2(
- CONST char *, arg,
- HTParentAnchor *, anAnchor)
+ * ==================================================
+ *
+ * Accepts an open socket to a CSO server waiting to send us
+ * data and puts it on the screen in a reasonable manner.
+ *
+ * Perhaps this data can be automatically linked to some
+ * other source as well???
+ *
+ * Taken from hacking by Lou Montulli@ukanaix.cc.ukans.edu
+ * on XMosaic-1.1, and put on libwww 2.11 by Arthur Secret,
+ * secret@dxcern.cern.ch .
+ */
+static void parse_cso(const char *arg,
+ HTParentAnchor *anAnchor)
{
int ich;
char line[BIG];
char *p = line;
- char *second_colon, last_char='\0';
- CONST char *title;
+ char *first_colon, *second_colon, last_char = '\0';
+ const char *title;
START(HTML_HEAD);
PUTC('\n');
@@ -485,107 +481,103 @@ PRIVATE void parse_cso ARGS2(
START(HTML_PRE);
/*
- ** Start grabbing chars from the network.
- */
- while ((ich=NEXT_CHAR) != EOF)
- {
- if ((char)ich != LF)
- {
- *p = (char) ich; /* Put character in line */
- if (p< &line[BIG-1]) p++;
- }
- else
- {
- *p = '\0'; /* Terminate line */
- p = line; /* Scan it to parse it */
- /*
- ** OK we now have a line in 'p'.
- ** Lets parse it and print it.
- */
+ * Start grabbing chars from the network.
+ */
+ while ((ich = NEXT_CHAR) != EOF) {
+ if ((char) ich != LF) {
+ *p = (char) ich; /* Put character in line */
+ if (p < &line[BIG - 1])
+ p++;
+ } else {
+ *p = '\0'; /* Terminate line */
+ p = line; /* Scan it to parse it */
+ /*
+ * OK we now have a line in 'p'. Lets parse it and print it.
+ */
- /*
- ** Break on line that begins with a 2.
- ** It's the end of data.
- */
- if (*p == '2')
- break;
+ /*
+ * Break on line that begins with a 2. It's the end of data.
+ */
+ if (*p == '2')
+ break;
- /*
- ** Lines beginning with 5 are errors.
- ** Print them and quit.
- */
- if (*p == '5') {
- START(HTML_H2);
- PUTS(p+4);
- END(HTML_H2);
- break;
- }
+ /*
+ * Lines beginning with 5 are errors. Print them and quit.
+ */
+ if (*p == '5') {
+ START(HTML_H2);
+ PUTS(p + 4);
+ END(HTML_H2);
+ break;
+ }
- if (*p == '-') {
- /*
- ** Data lines look like -200:#:
- ** where # is the search result number and can be
- ** multiple digits (infinite?).
- ** Find the second colon and check the digit to the
- ** left of it to see if they are diferent.
- ** If they are then a different person is starting.
- ** Make this line an <h2>.
- */
+ if (*p == '-') {
+ /*
+ * Data lines look like -200:#:
+ * where # is the search result number and can be multiple
+ * digits (infinite?).
+ * Find the second colon and check the digit to the left of it
+ * to see if they are diferent. If they are then a different
+ * person is starting. Make this line an <h2>.
+ */
- /*
- ** Find the second_colon.
- */
- second_colon = strchr( strchr(p,':')+1, ':');
+ /*
+ * Find the second_colon.
+ */
+ second_colon = NULL;
+ first_colon = strchr(p, ':');
+ if (first_colon != NULL) {
+ second_colon = strchr(first_colon + 1, ':');
+ }
- if(second_colon != NULL) { /* error check */
+ if (second_colon != NULL) { /* error check */
- if (*(second_colon-1) != last_char)
- /* print seperator */
- {
- END(HTML_PRE);
- START(HTML_H2);
- }
+ if (*(second_colon - 1) != last_char)
+ /* print seperator */
+ {
+ END(HTML_PRE);
+ START(HTML_H2);
+ }
+ /*
+ * Right now the record appears with the alias (first line)
+ * as the header and the rest as <pre> text.
+ *
+ * It might look better with the name as the header and the
+ * rest as a <ul> with <li> tags. I'm not sure whether the
+ * name field comes in any special order or if its even
+ * required in a record, so for now the first line is the
+ * header no matter what it is (it's almost always the
+ * alias).
+ *
+ * A <dl> with the first line as the <DT> and the rest as
+ * some form of <DD> might good also?
+ */
- /*
- ** Right now the record appears with the alias
- ** (first line) as the header and the rest as
- ** <pre> text.
- ** It might look better with the name as the
- ** header and the rest as a <ul> with <li> tags.
- ** I'm not sure whether the name field comes in
- ** any special order or if its even required in
- ** a record, so for now the first line is the
- ** header no matter what it is (it's almost
- ** always the alias).
- ** A <dl> with the first line as the <DT> and
- ** the rest as some form of <DD> might good also?
- */
-
- /*
- ** Print data.
- */
- PUTS(second_colon+1);
- PUTC('\n');
-
- if (*(second_colon-1) != last_char)
- /* end seperator */
- {
- END(HTML_H2);
- START(HTML_PRE);
- }
+ /*
+ * Print data.
+ */
+ PUTS(second_colon + 1);
+ PUTC('\n');
- /*
- ** Save the char before the second colon
- ** for comparison on the next pass.
- */
- last_char = *(second_colon-1) ;
+ if (*(second_colon - 1) != last_char)
+ /* end seperator */
+ {
+ END(HTML_H2);
+ START(HTML_PRE);
+ }
- } /* end if second_colon */
- } /* end if *p == '-' */
- } /* if end of line */
+ /*
+ * Save the char before the second colon for comparison on
+ * the next pass.
+ */
+ last_char = *(second_colon - 1);
+
+ } /* end if second_colon */
+ } /* end if *p == '-' */
+ } /* if end of line */
- } /* Loop over characters */
+ } /* Loop over characters */
/* end the text block */
PUTC('\n');
@@ -593,17 +585,16 @@ PRIVATE void parse_cso ARGS2(
PUTC('\n');
FREE_TARGET;
- return; /* all done */
-} /* end of procedure */
+ return; /* all done */
+} /* end of procedure */
/* Display a Gopher CSO ISINDEX cover page.
-** ========================================
-*/
-PRIVATE void display_cso ARGS2(
- CONST char *, arg,
- HTParentAnchor *, anAnchor)
+ * ========================================
+ */
+static void display_cso(const char *arg,
+ HTParentAnchor *anAnchor)
{
- CONST char * title;
+ const char *title;
START(HTML_HEAD);
PUTC('\n');
@@ -622,8 +613,8 @@ PRIVATE void display_cso ARGS2(
if ((title = HTAnchor_title(anAnchor)))
PUTS(title);
else {
- PUTS(arg);
- PUTS(INDEX_SEGMENT);
+ PUTS(arg);
+ PUTS(INDEX_SEGMENT);
}
END(HTML_H1);
PUTS(GOPHER_CSO_INDEX_SUBTITLE);
@@ -641,13 +632,12 @@ PRIVATE void display_cso ARGS2(
}
/* Display a Gopher Index document.
-** ================================
-*/
-PRIVATE void display_index ARGS2(
- CONST char *, arg,
- HTParentAnchor *,anAnchor)
+ * ================================
+ */
+static void display_index(const char *arg,
+ HTParentAnchor *anAnchor)
{
- CONST char * title;
+ const char *title;
START(HTML_HEAD);
PUTC('\n');
@@ -667,8 +657,8 @@ PRIVATE void display_index ARGS2(
if ((title = HTAnchor_title(anAnchor)))
PUTS(title);
else {
- PUTS(arg);
- PUTS(INDEX_SEGMENT);
+ PUTS(arg);
+ PUTS(INDEX_SEGMENT);
}
END(HTML_H1);
PUTS(GOPHER_INDEX_SUBTITLE);
@@ -683,38 +673,40 @@ PRIVATE void display_index ARGS2(
}
/* De-escape a selector into a command.
-** ====================================
-**
-** The % hex escapes are converted. Otheriwse, the string is copied.
-*/
-PRIVATE void de_escape ARGS2(char *, command, CONST char *, selector)
+ * ====================================
+ *
+ * The % hex escapes are converted. Otheriwse, the string is copied.
+ */
+static void de_escape(char *command, const char *selector)
{
- CONST char * p = selector;
- char * q = command;
- if (command == NULL)
- outofmem(__FILE__, "HTLoadGopher");
+ const char *p = selector;
+ char *q = command;
+
+ if (command == NULL)
+ outofmem(__FILE__, "HTLoadGopher");
while (*p) { /* Decode hex */
if (*p == HEX_ESCAPE) {
char c;
unsigned int b;
+
p++;
c = *p++;
- b = from_hex(c);
+ b = from_hex(c);
c = *p++;
- if (!c) break; /* Odd number of chars! */
- *q++ = (char) FROMASCII((b<<4) + from_hex(c));
+ if (!c)
+ break; /* Odd number of chars! */
+ *q++ = (char) FROMASCII((b << 4) + from_hex(c));
} else {
*q++ = *p++; /* Record */
}
}
- *q++ = '\0'; /* Terminate command */
+ *q++ = '\0'; /* Terminate command */
}
-
/* Free the CSOfields structures. - FM
-** ===================================
-*/
-PRIVATE void free_CSOfields NOPARAMS
+ * ===================================
+ */
+static void free_CSOfields(void)
{
CSOfield_info *cur = CSOfields;
CSOfield_info *prev;
@@ -735,22 +727,22 @@ PRIVATE void free_CSOfields NOPARAMS
}
/* Interpret CSO/PH form template keys. - FM
-** =========================================
-*/
-PRIVATE void interpret_cso_key ARGS5(
- char *, key,
- char *, buf,
- int *, length,
- CSOformgen_context *, ctx,
- HTStream *, Target)
+ * =========================================
+ */
+static void interpret_cso_key(const char *key,
+ char *buf,
+ int *length,
+ CSOformgen_context * ctx,
+ HTStream *Target)
{
CSOfield_info *fld;
if ((fld = ctx->fld) != 0) {
/*
- ** Most substitutions only recognized inside of loops.
- */
+ * Most substitutions only recognized inside of loops.
+ */
int error = 0;
+
if (0 == strncmp(key, "$(FID)", 6)) {
sprintf(buf, "%d", fld->id);
} else if (0 == strncmp(key, "$(FDESC)", 8)) {
@@ -780,34 +772,34 @@ PRIVATE void interpret_cso_key ARGS5(
else
fld = ctx->fld->next;
switch (ctx->field_select) {
- case 0:
+ case 0:
/*
- ** 'Query' fields, public and lookup attributes.
- */
+ * 'Query' fields, public and lookup attributes.
+ */
for (; fld; fld = fld->next)
- if (fld->public && (fld->lookup==1))
- break;
+ if (fld->gpublic && (fld->lookup == 1))
+ break;
break;
- case 1:
+ case 1:
/*
- ** 'Query' fields, accept lookup attribute.
- */
+ * 'Query' fields, accept lookup attribute.
+ */
for (; fld; fld = fld->next)
if (fld->lookup == 1)
break;
break;
- case 2:
+ case 2:
/*
- ** 'Return' fields, public only.
- */
+ * 'Return' fields, public only.
+ */
for (; fld; fld = fld->next)
- if (fld->public)
+ if (fld->gpublic)
break;
break;
- case 3:
+ case 3:
/*
- ** All fields.
- */
+ * All fields.
+ */
break;
}
if (fld) {
@@ -819,8 +811,8 @@ PRIVATE void interpret_cso_key ARGS5(
} else if ((0 == strncmp(key, "$(QFIELDS)", 10)) ||
(0 == strncmp(key, "$(RFIELDS)", 10))) {
/*
- ** Begin iteration sequence.
- */
+ * Begin iteration sequence.
+ */
ctx->rep_line = ctx->cur_line;
ctx->rep_off = ctx->cur_off;
ctx->fld = (CSOfield_info *) 0;
@@ -831,8 +823,8 @@ PRIVATE void interpret_cso_key ARGS5(
} else if (0 == strncmp(key, "$(NAMEFLD)", 10)) {
/*
- ** Special, locate name field. Flag lookup so QFIELDS will skip it.
- */
+ * Special, locate name field. Flag lookup so QFIELDS will skip it.
+ */
for (fld = CSOfields; fld; fld = fld->next)
if (strcmp(fld->name, "name") == 0 ||
strcmp(fld->name, "Name") == 0) {
@@ -841,20 +833,21 @@ PRIVATE void interpret_cso_key ARGS5(
break;
}
ctx->fld = fld;
- } else if (0 == strncmp (key, "$(HOST)", 7)) {
- strcpy (buf, ctx->host);
- } else if (0 == strncmp (key, "$(PORT)", 7)) {
+ } else if (0 == strncmp(key, "$(HOST)", 7)) {
+ strcpy(buf, ctx->host);
+ } else if (0 == strncmp(key, "$(PORT)", 7)) {
sprintf(buf, "%d", ctx->port);
} else {
/*
- ** No match, dump key to buffer so client sees it for debugging.
- */
+ * No match, dump key to buffer so client sees it for debugging.
+ */
size_t out = 0;
+
while (*key && (*key != ')')) {
buf[out++] = (*key++);
- if (out > sizeof(buf)-2) {
+ if (out > sizeof(buf) - 2) {
buf[out] = '\0';
- (*Target->isa->put_block)(Target, buf, strlen(buf));
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
out = 0;
}
}
@@ -868,23 +861,22 @@ PRIVATE void interpret_cso_key ARGS5(
}
/* Parse the elements in a CSO/PH fields structure. - FM
-** =====================================================
-*/
-PRIVATE int parse_cso_field_info ARGS1(
- CSOfield_info *, blk)
+ * =====================================================
+ */
+static int parse_cso_field_info(CSOfield_info *blk)
{
char *info, *max_spec;
/*
- ** Initialize all fields to default values.
- */
+ * Initialize all fields to default values.
+ */
blk->indexed = blk->lookup = blk->reserved = blk->max_size = blk->url = 0;
- blk->defreturn = blk->explicit_return = blk->public = 0;
+ blk->defreturn = blk->explicit_return = blk->gpublic = 0;
/*
- ** Search for keywords in info string and set values. Attributes
- ** are converted to all lower-case for comparison.
- */
+ * Search for keywords in info string and set values. Attributes are
+ * converted to all lower-case for comparison.
+ */
info = blk->attributes;
LYLowerCase(info);
if (strstr(info, "indexed "))
@@ -892,7 +884,7 @@ PRIVATE int parse_cso_field_info ARGS1(
if (strstr(info, "default "))
blk->defreturn = 1;
if (strstr(info, "public "))
- blk->public = 1;
+ blk->gpublic = 1;
if (strstr(info, "lookup "))
blk->lookup = 1;
if (strstr(info, "url ")) {
@@ -910,37 +902,37 @@ PRIVATE int parse_cso_field_info ARGS1(
}
/* Parse a reply from a CSO/PH fields request. - FM
-** ================================================
-*/
-PRIVATE int parse_cso_fields ARGS2(
- char *, buf,
- int, size)
+ * ================================================
+ */
+static int parse_cso_fields(char *buf,
+ int size)
{
int ich;
char *p = buf;
int i, code = 0, prev_code;
size_t alen;
char *indx, *name;
- CSOfield_info *last, *new;
+ CSOfield_info *last, *newf;
last = CSOfields = (CSOfield_info *) 0;
prev_code = -2555;
buf[0] = '\0';
/*
- ** Start grabbing chars from the network.
- */
+ * Start grabbing chars from the network.
+ */
while ((ich = NEXT_CHAR) != EOF) {
if (interrupted_in_htgetcharacter) {
- CTRACE((tfp, "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n"));
+ CTRACE((tfp,
+ "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n"));
free_CSOfields();
buf[0] = '\0';
return HT_INTERRUPTED;
}
- if ((char)ich != LF) {
- *p = (char) ich; /* Put character in buffer */
- if (p < &buf[size-1]) {
+ if ((char) ich != LF) {
+ *p = (char) ich; /* Put character in buffer */
+ if (p < &buf[size - 1]) {
p++;
}
} else {
@@ -951,48 +943,46 @@ PRIVATE int parse_cso_fields ARGS2(
*/
/*
- ** Break on line that begins with a 2.
- ** It's the end of data.
- */
+ * Break on line that begins with a 2. It's the end of data.
+ */
if (*p == '2')
break;
/*
- ** Lines beginning with 5 are errors.
- ** Print them and quit.
- */
+ * Lines beginning with 5 are errors. Print them and quit.
+ */
if (*p == '5') {
- strcpy (buf, p);
+ strcpy(buf, p);
return 5;
}
if (*p == '-') {
/*
- ** Data lines look like -200:#:
- ** where # is the search result number and can be
- ** multiple digits (infinite?).
- */
+ * Data lines look like -200:#:
+ * where # is the search result number and can be multiple
+ * digits (infinite?).
+ */
/*
- ** Check status, ignore any non-success.
- */
- if (p[1] != '2' )
+ * Check status, ignore any non-success.
+ */
+ if (p[1] != '2')
continue;
/*
- ** Parse fields within returned line into status, ndx, name,
- ** data.
- */
+ * Parse fields within returned line into status, ndx, name,
+ * data.
+ */
indx = NULL;
name = NULL;
for (i = 0; p[i]; i++) {
- if (p[i] == ':' ) {
+ if (p[i] == ':') {
p[i] = '\0';
if (!indx) {
- indx = (char *)&p[i+1];
- code = atoi (indx);
+ indx = (char *) &p[i + 1];
+ code = atoi(indx);
} else if (!name) {
- name = (char *)&p[i+1];
+ name = (char *) &p[i + 1];
} else {
i++;
break;
@@ -1000,121 +990,124 @@ PRIVATE int parse_cso_fields ARGS2(
}
}
/*
- ** Add data to field structure.
- */
+ * Add data to field structure.
+ */
if (name) {
if (code == prev_code) {
/*
- ** Remaining data are description.
- ** Save in current info block.
- */
- alen = strlen((char *)&p[i]) + 1;
+ * Remaining data are description. Save in current
+ * info block.
+ */
+ alen = strlen((char *) &p[i]) + 1;
if (alen > sizeof(last->desc_buf)) {
if (last->description != last->desc_buf)
FREE(last->description);
- if (!(last->description = (char *)malloc(alen))) {
+ if (!(last->description = (char *) malloc(alen))) {
outofmem(__FILE__, "HTLoadCSO");
}
}
- strcpy(last->description, (char *)&p[i]);
+ strcpy(last->description, (char *) &p[i]);
} else {
/*
- ** Initialize new block, append to end of list
- ** to preserve order.
- */
- new = typecalloc(CSOfield_info);
- if (!new) {
+ * Initialize new block, append to end of list to
+ * preserve order.
+ */
+ newf = typecalloc(CSOfield_info);
+
+ if (!newf) {
outofmem(__FILE__, "HTLoadCSO");
}
if (last)
- last->next = new;
+ last->next = newf;
else
- CSOfields = new;
- last = new;
+ CSOfields = newf;
+ last = newf;
- new->next = (CSOfield_info *) 0;
- new->name = new->name_buf;
+ newf->next = (CSOfield_info *) 0;
+ newf->name = newf->name_buf;
alen = strlen(name) + 1;
- if (alen > sizeof(new->name_buf)) {
- if (!(new->name = (char *)malloc(alen))) {
+ if (alen > sizeof(newf->name_buf)) {
+ if (!(newf->name = (char *) malloc(alen))) {
outofmem(__FILE__, "HTLoadCSO");
}
}
- strcpy (new->name, name);
+ strcpy(newf->name, name);
- new->attributes = new->attr_buf;
- alen = strlen((char *)&p[i]) + 2;
- if (alen > sizeof(new->attr_buf)) {
- if (!(new->attributes = (char *)malloc(alen))) {
+ newf->attributes = newf->attr_buf;
+ alen = strlen((char *) &p[i]) + 2;
+ if (alen > sizeof(newf->attr_buf)) {
+ if (!(newf->attributes = (char *) malloc(alen))) {
outofmem(__FILE__, "HTLoadCSO");
}
}
- strcpy(new->attributes, (char *)&p[i]);
- strcpy((char *)&new->attributes[alen-2], " ");
- new->description = new->desc_buf;
- new->desc_buf[0] = '\0';
- new->id = atoi(indx);
+ strcpy(newf->attributes, (char *) &p[i]);
+ strcpy((char *) &newf->attributes[alen - 2], " ");
+ newf->description = newf->desc_buf;
+ newf->desc_buf[0] = '\0';
+ newf->id = atoi(indx);
/*
- ** Scan for keywords.
- */
- parse_cso_field_info(new);
+ * Scan for keywords.
+ */
+ parse_cso_field_info(newf);
}
prev_code = code;
} else
break;
- } /* end if *p == '-' */
- } /* if end of line */
+ } /* end if *p == '-' */
+ } /* if end of line */
- } /* Loop over characters */
+ } /* Loop over characters */
/* end the text block */
if (buf[0] == '\0') {
- return -1; /* no response */
+ return -1; /* no response */
}
buf[0] = '\0';
- return 0; /* all done */
-} /* end of procedure */
+ return 0; /* all done */
+} /* end of procedure */
/* Generate a form for submitting CSO/PH searches. - FM
-** ====================================================
-*/
-PRIVATE int generate_cso_form ARGS4(
- char *, host,
- int, port,
- char *, buf,
- HTStream *, Target)
+ * ====================================================
+ */
+static int generate_cso_form(char *host,
+ int port,
+ char *buf,
+ HTStream *Target)
{
int i, j, length;
size_t out;
int full_flag = 1;
- char *key, *line;
+ const char *key;
+ const char *line;
CSOformgen_context ctx;
- static char *template[] = {
- "<HTML>\n<HEAD>\n<TITLE>CSO/PH Query Form for $(HOST)</TITLE>\n</HEAD>\n<BODY>",
- "<H2><I>CSO/PH Query Form</I> for <EM>$(HOST)</EM></H2>",
- "To search the database for a name, fill in one or more of the fields",
- "in the form below and activate the 'Submit query' button. At least",
- "one of the entered fields must be flagged as indexed.",
- "<HR><FORM method=\"POST\" action=\"cso://$(HOST)/\">",
- "[ <input type=\"submit\" value=\"Submit query\"> | ",
- "<input type=\"reset\" value=\"Clear fields\"> ]",
- "<P><DL>",
- " <DT>Search parameters (* indicates indexed field):",
- " <DD>", "$(NAMEFLD) <DL COMPACT>\n <DT><I>$(FDESC)</I>$(FNDX)",
- " <DD>Last: <input name=\"q_$(FID)\" type=\"text\" size=49$(FSIZE2)>",
- " <DD>First: <input name=\"q_$(FID)\" type=\"text\" size=48$(FSIZE2)>",
- "$(QFIELDS) <DT><I>$(FDESC)</I>$(FNDX)",
- " <DD><input name=\"q_$(FID)\" type=\"text\" $(FSIZE)>\n$(NEXTFLD)",
- " </DL>",
- " </DL>\n<P><DL>",
- " <DT>Output format:",
- " <DD>Returned data option: <select name=\"return\">",
- " <option>default<option selected>all<option>selected</select><BR>",
- "$(RFIELDS) <input type=\"checkbox\" name=\"r_$(FID)\"$(FDEF)> $(FDESC)<BR>",
- "$(NEXTFLD) ",
- " </DL></FORM><HR>\n</BODY>\n</HTML>",
- (char *) 0
+ static const char *ctemplate[] =
+ {
+ "<HTML>\n<HEAD>\n<TITLE>CSO/PH Query Form for $(HOST)</TITLE>\n</HEAD>\n<BODY>",
+ "<H2><I>CSO/PH Query Form</I> for <EM>$(HOST)</EM></H2>",
+ "To search the database for a name, fill in one or more of the fields",
+ "in the form below and activate the 'Submit query' button. At least",
+ "one of the entered fields must be flagged as indexed.",
+ "<HR><FORM method=\"POST\" action=\"cso://$(HOST)/\">",
+ "[ <input type=\"submit\" value=\"Submit query\"> | ",
+ "<input type=\"reset\" value=\"Clear fields\"> ]",
+ "<P><DL>",
+ " <DT>Search parameters (* indicates indexed field):",
+ " <DD>",
+ "$(NAMEFLD) <DL COMPACT>\n <DT><I>$(FDESC)</I>$(FNDX)",
+ " <DD>Last: <input name=\"q_$(FID)\" type=\"text\" size=49$(FSIZE2)>",
+ " <DD>First: <input name=\"q_$(FID)\" type=\"text\" size=48$(FSIZE2)>",
+ "$(QFIELDS) <DT><I>$(FDESC)</I>$(FNDX)",
+ " <DD><input name=\"q_$(FID)\" type=\"text\" $(FSIZE)>\n$(NEXTFLD)",
+ " </DL>",
+ " </DL>\n<P><DL>",
+ " <DT>Output format:",
+ " <DD>Returned data option: <select name=\"return\">",
+ " <option>default<option selected>all<option>selected</select><BR>",
+ "$(RFIELDS) <input type=\"checkbox\" name=\"r_$(FID)\"$(FDEF)> $(FDESC)<BR>",
+ "$(NEXTFLD) ",
+ " </DL></FORM><HR>\n</BODY>\n</HTML>",
+ (char *) 0
};
out = 0;
@@ -1125,53 +1118,55 @@ PRIVATE int generate_cso_form ARGS4(
ctx.fld = (CSOfield_info *) 0;
ctx.public_override = full_flag;
/*
- ** Parse the strings in the template array to produce HTML document
- ** to send to client. First line is skipped for 'full' lists.
- */
+ * Parse the strings in the template array to produce HTML document to send
+ * to client. First line is skipped for 'full' lists.
+ */
out = 0;
buf[out] = '\0';
- for (i = full_flag ? /***1***/ 0 : 0; template[i]; i++) {
+ for (i = full_flag ? /***1***/ 0 : 0;
+ ctemplate[i];
+ i++) {
/*
- ** Search the current string for substitution, flagged by $(
- */
- for (line=template[i], j = 0; line[j]; j++) {
- if ((line[j] == '$') && (line[j+1] == '(')) {
+ * Search the current string for substitution, flagged by $(
+ */
+ for (line = ctemplate[i], j = 0; line[j]; j++) {
+ if ((line[j] == '$') && (line[j + 1] == '(')) {
/*
- ** Command detected, flush output buffer and find closing ')'
- ** that delimits the command.
- */
+ * Command detected, flush output buffer and find closing ')'
+ * that delimits the command.
+ */
buf[out] = '\0';
if (out > 0)
- (*Target->isa->put_block)(Target, buf, strlen(buf));
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
out = 0;
- for (key = &line[j]; line[j+1] && (line[j] != ')'); j++)
- ;
+ for (key = &line[j]; line[j + 1] && (line[j] != ')'); j++) ;
/*
- ** Save context, interpet command and restore updated context.
- */
+ * Save context, interpet command and restore updated context.
+ */
ctx.cur_line = i;
ctx.cur_off = j;
interpret_cso_key(key, buf, &length, &ctx, Target);
i = ctx.cur_line;
j = ctx.cur_off;
- line = template[i];
+ line = ctemplate[i];
out = length;
if (ctx.seek) {
/*
- ** Command wants us to skip (forward) to indicated token.
- ** Start at current position.
- */
+ * Command wants us to skip (forward) to indicated token.
+ * Start at current position.
+ */
int slen = strlen(ctx.seek);
- for (; template[i]; i++) {
- for (line = template[i]; line[j]; j++) {
+
+ for (; ctemplate[i]; i++) {
+ for (line = ctemplate[i]; line[j]; j++) {
if (line[j] == '$')
if (0 == strncmp(ctx.seek, &line[j], slen)) {
if (j == 0)
- j = strlen(template[--i])-1;
+ j = strlen(ctemplate[--i]) - 1;
else
--j;
- line = template[i];
+ line = ctemplate[i];
ctx.seek = (char *) 0;
break;
}
@@ -1182,19 +1177,20 @@ PRIVATE int generate_cso_form ARGS4(
}
if (ctx.seek) {
char *temp = 0;
+
HTSprintf0(&temp, GOPHER_CSO_SEEK_FAILED, ctx.seek);
- (*Target->isa->put_block)(Target, temp, strlen(temp));
+ (*Target->isa->put_block) (Target, temp, strlen(temp));
FREE(temp);
}
}
} else {
/*
- ** Non-command text, add to output buffer.
- */
+ * Non-command text, add to output buffer.
+ */
buf[out++] = line[j];
- if (out > (sizeof(buf)-3)) {
+ if (out > (sizeof(buf) - 3)) {
buf[out] = '\0';
- (*Target->isa->put_block)(Target, buf, strlen(buf));
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
out = 0;
}
}
@@ -1203,16 +1199,15 @@ PRIVATE int generate_cso_form ARGS4(
buf[out] = '\0';
}
if (out > 0)
- (*Target->isa->put_block)(Target, buf, strlen(buf));
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
return 0;
}
/* Generate a results report for CSO/PH form-based searches. - FM
-** ==============================================================
-*/
-PRIVATE int generate_cso_report ARGS1(
- HTStream *, Target)
+ * ==============================================================
+ */
+static int generate_cso_report(HTStream *Target)
{
int ich;
char line[BIG];
@@ -1224,30 +1219,30 @@ PRIVATE int generate_cso_report ARGS1(
BOOL stop = FALSE;
/*
- ** Read lines until non-negative status.
- */
+ * Read lines until non-negative status.
+ */
prev_ndx = -100;
/*
- ** Start grabbing chars from the network.
- */
+ * Start grabbing chars from the network.
+ */
while (!stop && (ich = NEXT_CHAR) != EOF) {
if (interrupted_in_htgetcharacter) {
- CTRACE((tfp, "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n"));
- _HTProgress (CONNECTION_INTERRUPTED);
+ CTRACE((tfp,
+ "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n"));
+ _HTProgress(CONNECTION_INTERRUPTED);
goto end_CSOreport;
}
- if ((char)ich != LF) {
- *p = (char) ich; /* Put character in line */
- if (p < &line[BIG-1]) {
+ if ((char) ich != LF) {
+ *p = (char) ich; /* Put character in line */
+ if (p < &line[BIG - 1]) {
p++;
}
} else {
*p = '\0'; /* Terminate line */
/*
- ** OK we now have a line.
- ** Load it as 'p' and parse it.
- */
+ * OK we now have a line. Load it as 'p' and parse it.
+ */
p = line;
if (p[0] != '-' && p[0] != '1') {
stop = TRUE;
@@ -1259,9 +1254,9 @@ PRIVATE int generate_cso_report ARGS1(
if (p[i] == ':') {
p[i] = '\0';
if (!ndx_str) {
- fname = ndx_str = &p[i+1];
+ fname = ndx_str = &p[i + 1];
} else {
- fname = &p[i+1];
+ fname = &p[i + 1];
break;
}
}
@@ -1271,22 +1266,22 @@ PRIVATE int generate_cso_report ARGS1(
if (prev_ndx != ndx) {
if (prev_ndx != -100) {
HTSprintf0(&buf, "</DL></DL>\n");
- (*Target->isa->put_block)(Target, buf, strlen(buf));
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
}
if (ndx == 0) {
HTSprintf0(&buf,
- "<HR><DL><DT>Information/status<DD><DL><DT>\n");
- (*Target->isa->put_block)(Target, buf, strlen(buf));
+ "<HR><DL><DT>Information/status<DD><DL><DT>\n");
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
} else {
HTSprintf0(&buf,
- "<HR><DL><DT>Entry %d:<DD><DL COMPACT><DT>\n", ndx);
- (*Target->isa->put_block)(Target, buf, strlen(buf));
+ "<HR><DL><DT>Entry %d:<DD><DL COMPACT><DT>\n", ndx);
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
}
prev_ndx = ndx;
}
} else {
HTSprintf0(&buf, "<DD>%s\n", rcode);
- (*Target->isa->put_block)(Target, buf, strlen(buf));
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
continue;
}
if ((*rcode >= '2') && (*rcode <= '5') && (fname != ndx_str)) {
@@ -1298,7 +1293,7 @@ PRIVATE int generate_cso_report ARGS1(
*fvalue++ = '\0';
i = strlen(fname) - 1;
while (i >= 0 && fname[i] == ' ') {
- fname[i--] = '\0'; /* trim trailing */
+ fname[i--] = '\0'; /* trim trailing */
}
break;
}
@@ -1319,12 +1314,12 @@ PRIVATE int generate_cso_report ARGS1(
}
if (fld && fld->url) {
HTSprintf0(&buf,
- "<DT><I>%s</I><DD><A HREF=\"%s\">%s</A>\n",
- fname, fvalue, fvalue);
- (*Target->isa->put_block)(Target, buf, strlen(buf));
+ "<DT><I>%s</I><DD><A HREF=\"%s\">%s</A>\n",
+ fname, fvalue, fvalue);
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
} else {
HTSprintf0(&buf, "<DT><I>%s</I><DD>", fname);
- (*Target->isa->put_block)(Target, buf, strlen(buf));
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
buf[0] = '\0';
l = fvalue;
while (*l) {
@@ -1347,7 +1342,8 @@ PRIVATE int generate_cso_report ARGS1(
strncmp(l, "http://", 7) &&
strncmp(l, "https://", 8) &&
strncmp(l, "wais://", 7) &&
- strncmp(l, STR_MAILTO_URL, LEN_MAILTO_URL) &&
+ strncmp(l, STR_MAILTO_URL,
+ LEN_MAILTO_URL) &&
strncmp(l, "cso://", 6) &&
strncmp(l, "gopher://", 9)) {
HTSprintf(&buf, "%c", *l++);
@@ -1364,11 +1360,11 @@ PRIVATE int generate_cso_report ARGS1(
}
}
StrAllocCat(buf, "\n");
- (*Target->isa->put_block)(Target, buf, strlen(buf));
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
}
} else {
HTSprintf0(&buf, "<DD>");
- (*Target->isa->put_block)(Target, buf, strlen(buf));
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
buf[0] = '\0';
l = fvalue;
while (*l) {
@@ -1408,36 +1404,35 @@ PRIVATE int generate_cso_report ARGS1(
}
}
StrAllocCat(buf, "\n");
- (*Target->isa->put_block)(Target, buf, strlen(buf));
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
}
} else {
- HTSprintf0(&buf, "<DD>%s\n", fname ? fname : rcode );
- (*Target->isa->put_block)(Target, buf, strlen(buf));
+ HTSprintf0(&buf, "<DD>%s\n", fname ? fname : rcode);
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
}
}
}
-end_CSOreport:
+ end_CSOreport:
if (prev_ndx != -100) {
HTSprintf0(&buf, "</DL></DL>\n");
- (*Target->isa->put_block)(Target, buf, strlen(buf));
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
}
FREE(buf);
return 0;
}
/* CSO/PH form-based search gateway - FM HTLoadCSO
-** =====================================
-*/
-PRIVATE int HTLoadCSO ARGS4(
- CONST char *, arg,
- HTParentAnchor *, anAnchor,
- HTFormat, format_out,
- HTStream*, sink)
+ * =====================================
+ */
+static int HTLoadCSO(const char *arg,
+ HTParentAnchor *anAnchor,
+ HTFormat format_out,
+ HTStream *sink)
{
- static CONST char end_form[] = "</BODY>\n</HTML>\n";
+ static const char end_form[] = "</BODY>\n</HTML>\n";
char *host, *cp, *data;
int port = CSO_PORT;
- int status; /* tcp return */
+ int status; /* tcp return */
bstring *command = NULL;
bstring *content = NULL;
int len, i, j, start, finish, flen, ndx;
@@ -1448,29 +1443,30 @@ PRIVATE int HTLoadCSO ARGS4(
HTStream *Target = NULL;
if (!acceptable_inited)
- init_acceptable();
+ init_acceptable();
if (!arg)
- return -3; /* Bad if no name sepcified */
+ return -3; /* Bad if no name sepcified */
if (!*arg)
- return -2; /* Bad if name had zero length */
+ return -2; /* Bad if name had zero length */
CTRACE((tfp, "HTLoadCSO: Looking for %s\n", arg));
/*
- ** Set up a socket to the server for the data.
- */
- status = HTDoConnect (arg, "cso", CSO_PORT, &s);
+ * Set up a socket to the server for the data.
+ */
+ status = HTDoConnect(arg, "cso", CSO_PORT, &s);
if (status == HT_INTERRUPTED) {
/*
- ** Interrupt cleanly.
- */
- CTRACE((tfp, "HTLoadCSO: Interrupted on connect; recovering cleanly.\n"));
- _HTProgress (CONNECTION_INTERRUPTED);
+ * Interrupt cleanly.
+ */
+ CTRACE((tfp,
+ "HTLoadCSO: Interrupted on connect; recovering cleanly.\n"));
+ _HTProgress(CONNECTION_INTERRUPTED);
return HT_NOT_LOADED;
}
if (status < 0) {
CTRACE((tfp, "HTLoadCSO: Unable to connect to remote host for `%s'.\n",
- arg));
+ arg));
return HTInetStatus("connect");
}
@@ -1482,23 +1478,23 @@ PRIVATE int HTLoadCSO ARGS4(
trace_bstring(command);
CTRACE((tfp, "' to socket %d\n", s));
}
- _HTProgress (GOPHER_SENDING_CSO_REQUEST);
+ _HTProgress(GOPHER_SENDING_CSO_REQUEST);
status = NETWRITE(s, BStrData(command), BStrLen(command));
BStrFree(command);
if (status < 0) {
CTRACE((tfp, "HTLoadCSO: Unable to send command.\n"));
return HTInetStatus("send");
}
- _HTProgress (GOPHER_SENT_CSO_REQUEST);
+ _HTProgress(GOPHER_SENT_CSO_REQUEST);
/*
- ** Now read the data from the socket.
- */
+ * Now read the data from the socket.
+ */
status = parse_cso_fields(buf, sizeof(buf));
if (status) {
NETCLOSE(s);
if (status == HT_INTERRUPTED) {
- _HTProgress (CONNECTION_INTERRUPTED);
+ _HTProgress(CONNECTION_INTERRUPTED);
} else if (buf[0] != '\0') {
HTAlert(buf);
} else {
@@ -1511,6 +1507,7 @@ PRIVATE int HTLoadCSO ARGS4(
sink, anAnchor);
if (!Target || Target == NULL) {
char *temp = 0;
+
HTSprintf0(&temp, CANNOT_CONVERT_I_TO_O,
HTAtom_name(format_in), HTAtom_name(format_out));
HTAlert(temp);
@@ -1521,7 +1518,7 @@ PRIVATE int HTLoadCSO ARGS4(
host = HTParse(arg, "", PARSE_HOST);
if ((cp = strchr(host, ':')) != NULL) {
if (cp[1] >= '0' && cp[1] <= '9') {
- port = atoi((cp+1));
+ port = atoi((cp + 1));
if (port == CSO_PORT) {
*cp = '\0';
}
@@ -1530,7 +1527,7 @@ PRIVATE int HTLoadCSO ARGS4(
anAnchor->safe = TRUE;
if (isBEmpty(anAnchor->post_data)) {
generate_cso_form(host, port, buf, Target);
- (*Target->isa->_free)(Target);
+ (*Target->isa->_free) (Target);
FREE(host);
NETCLOSE(s);
free_CSOfields();
@@ -1538,15 +1535,15 @@ PRIVATE int HTLoadCSO ARGS4(
}
HTBprintf(&command,
- "<HTML>\n<HEAD>\n<TITLE>CSO/PH Results on %s</TITLE>\n</HEAD>\n<BODY>\n",
- host);
- (*Target->isa->put_block)(Target, BStrData(command), BStrLen(command));
+ "<HTML>\n<HEAD>\n<TITLE>CSO/PH Results on %s</TITLE>\n</HEAD>\n<BODY>\n",
+ host);
+ (*Target->isa->put_block) (Target, BStrData(command), BStrLen(command));
BStrFree(command);
FREE(host);
BStrCopy(content, anAnchor->post_data);
- if (BStrData(content)[BStrLen(content)-1] != '&')
+ if (BStrData(content)[BStrLen(content) - 1] != '&')
BStrCat0(content, "&");
data = BStrData(content);
@@ -1567,27 +1564,27 @@ PRIVATE int HTLoadCSO ARGS4(
for (i = 0; i < len; i++) {
if (!data[i] || data[i] == '&') {
/*
- ** Value parsed. Unescape characters and look for first '='
- ** to delimit field name from value.
- */
+ * Value parsed. Unescape characters and look for first '=' to
+ * delimit field name from value.
+ */
flen = i - start;
finish = start + flen;
data[finish] = '\0';
for (j = start; j < finish; j++) {
if (data[j] == '=') {
/*
- ** data[start..j-1] is field name,
- ** [j+1..finish-1] is value.
- */
- if ((data[start+1] == '_') &&
+ * data[start..j-1] is field name,
+ * [j+1..finish-1] is value.
+ */
+ if ((data[start + 1] == '_') &&
((data[start] == 'r') || (data[start] == 'q'))) {
/*
- ** Decode fields number and lookup field info.
- */
- sscanf (&data[start+2], "%d=", &ndx);
+ * Decode fields number and lookup field info.
+ */
+ sscanf(&data[start + 2], "%d=", &ndx);
for (fld = CSOfields; fld; fld = fld->next) {
- if (ndx==fld->id) {
- if ((j+1) >= finish)
+ if (ndx == fld->id) {
+ if ((j + 1) >= finish)
break; /* ignore nulls */
if (data[start] == 'q') {
/*
@@ -1602,13 +1599,13 @@ PRIVATE int HTLoadCSO ARGS4(
BStrCat0(command, " ");
}
HTBprintf(&command, "%s=\"%s\"",
- fld->name, &data[j+1]);
+ fld->name, &data[j + 1]);
} else {
strcpy(buf,
- "Warning: non-lookup field ignored<BR>\n");
- (*Target->isa->put_block)(Target,
- buf,
- strlen(buf));
+ "Warning: non-lookup field ignored<BR>\n");
+ (*Target->isa->put_block) (Target,
+ buf,
+ strlen(buf));
}
} else if (data[start] == 'r') {
fld->explicit_return = 1;
@@ -1617,9 +1614,9 @@ PRIVATE int HTLoadCSO ARGS4(
}
}
} else if (!strncmp(&data[start], "return=", 7)) {
- if (!strcmp(&data[start+7], "all")) {
+ if (!strcmp(&data[start + 7], "all")) {
return_type = 1;
- } else if (!strcmp(&data[start+7], "selected")) {
+ } else if (!strcmp(&data[start + 7], "selected")) {
return_type = 2;
}
}
@@ -1632,17 +1629,17 @@ PRIVATE int HTLoadCSO ARGS4(
if (isBEmpty(command) || !has_indexed) {
NETCLOSE(s);
strcpy(buf,
- "<EM>Error:</EM> At least one indexed field value must be specified!\n");
- (*Target->isa->put_block)(Target, buf, strlen(buf));
+ "<EM>Error:</EM> At least one indexed field value must be specified!\n");
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
strcpy(buf, "</BODY>\n</HTML>\n");
- (*Target->isa->put_block)(Target, buf, strlen(buf));
- (*Target->isa->_free)(Target);
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
+ (*Target->isa->_free) (Target);
free_CSOfields();
return HT_LOADED;
}
/*
- ** Append return fields.
- */
+ * Append return fields.
+ */
if (return_type == 1) {
BStrCat0(command, " return all");
} else if (return_type == 2) {
@@ -1655,12 +1652,12 @@ PRIVATE int HTLoadCSO ARGS4(
}
HTBprintf(&command, "%c%c", CR, LF);
strcpy(buf, "<H2>\n<EM>CSO/PH command:</EM> ");
- (*Target->isa->put_block)(Target, buf, strlen(buf));
- (*Target->isa->put_block)(Target, BStrData(command), BStrLen(command));
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
+ (*Target->isa->put_block) (Target, BStrData(command), BStrLen(command));
strcpy(buf, "</H2>\n");
- (*Target->isa->put_block)(Target, buf, strlen(buf));
+ (*Target->isa->put_block) (Target, buf, strlen(buf));
if (TRACE) {
- CTRACE((tfp, "HTLoadCSO: Writing command `"));
+ CTRACE((tfp, "HTLoadCSO: Writing command `"));
trace_bstring(command);
CTRACE((tfp, "' to socket %d\n", s));
}
@@ -1673,49 +1670,48 @@ PRIVATE int HTLoadCSO ARGS4(
}
generate_cso_report(Target);
NETCLOSE(s);
- (*Target->isa->put_block)(Target, end_form, sizeof(end_form)-1);
- (*Target->isa->_free)(Target);
+ (*Target->isa->put_block) (Target, end_form, sizeof(end_form) - 1);
+ (*Target->isa->_free) (Target);
FREE(host);
free_CSOfields();
return HT_LOADED;
}
/* Load by name. HTLoadGopher
-** =============
-**
-** Bug: No decoding of strange data types as yet.
-**
-*/
-PRIVATE int HTLoadGopher ARGS4(
- CONST char *, arg,
- HTParentAnchor *, anAnchor,
- HTFormat, format_out,
- HTStream*, sink)
+ * =============
+ *
+ * Bug: No decoding of strange data types as yet.
+ *
+ */
+static int HTLoadGopher(const char *arg,
+ HTParentAnchor *anAnchor,
+ HTFormat format_out,
+ HTStream *sink)
{
- char *command; /* The whole command */
- int status; /* tcp return */
- char gtype; /* Gopher Node type */
- char * selector; /* Selector string */
+ char *command; /* The whole command */
+ int status; /* tcp return */
+ char gtype; /* Gopher Node type */
+ char *selector; /* Selector string */
if (!acceptable_inited)
- init_acceptable();
+ init_acceptable();
if (!arg)
- return -3; /* Bad if no name sepcified */
+ return -3; /* Bad if no name sepcified */
if (!*arg)
- return -2; /* Bad if name had zero length */
+ return -2; /* Bad if name had zero length */
CTRACE((tfp, "HTGopher: Looking for %s\n", arg));
/*
- ** If it's a port 105 GOPHER_CSO gtype with no ISINDEX token ('?'),
- ** use the form-based CSO gateway (otherwise, return an ISINDEX
- ** cover page or do the ISINDEX search). - FM
- */
+ * If it's a port 105 GOPHER_CSO gtype with no ISINDEX token ('?'), use the
+ * form-based CSO gateway (otherwise, return an ISINDEX cover page or do
+ * the ISINDEX search). - FM
+ */
{
int len;
if ((len = strlen(arg)) > 5) {
- if (0 == strcmp((CONST char *)&arg[len-6], ":105/2")) {
+ if (0 == strcmp((const char *) &arg[len - 6], ":105/2")) {
/* Use CSO gateway. */
CTRACE((tfp, "HTGopher: Passing to CSO/PH gateway.\n"));
return HTLoadCSO(arg, anAnchor, format_out, sink);
@@ -1724,8 +1720,8 @@ PRIVATE int HTLoadGopher ARGS4(
}
/*
- ** If it's a port 79/0[/...] URL, use the finger gateway. - FM
- */
+ * If it's a port 79/0[/...] URL, use the finger gateway. - FM
+ */
if (strstr(arg, ":79/0") != NULL) {
#ifndef DISABLE_FINGER
CTRACE((tfp, "HTGopher: Passing to finger gateway.\n"));
@@ -1737,78 +1733,86 @@ PRIVATE int HTLoadGopher ARGS4(
}
/*
- ** Get entity type, and selector string.
- */
+ * Get entity type, and selector string.
+ */
{
- char * p1 = HTParse(arg, "", PARSE_PATH|PARSE_PUNCTUATION);
+ char *p1 = HTParse(arg, "", PARSE_PATH | PARSE_PUNCTUATION);
+
gtype = '1'; /* Default = menu */
selector = p1;
- if ((*selector++=='/') && (*selector)) { /* Skip first slash */
- gtype = *selector++; /* Pick up gtype */
+ if ((*selector++ == '/') && (*selector)) { /* Skip first slash */
+ gtype = *selector++; /* Pick up gtype */
}
if (gtype == GOPHER_INDEX) {
- char * query;
+ char *query;
+
/*
- ** Search is allowed.
- */
+ * Search is allowed.
+ */
HTAnchor_setIndex(anAnchor, anAnchor->address);
query = strchr(selector, '?'); /* Look for search string */
- if (!query || !query[1]) { /* No search required */
+ if (!query || !query[1]) { /* No search required */
target = HTML_new(anAnchor, format_out, sink);
targetClass = *target->isa;
display_index(arg, anAnchor); /* Display "cover page" */
- return HT_LOADED; /* Local function only */
+ return HT_LOADED; /* Local function only */
}
- *query++ = '\0'; /* Skip '?' */
+ *query++ = '\0'; /* Skip '?' */
command =
- (char *)malloc(strlen(selector)+ 1 + strlen(query)+ 2 + 1);
- if (command == NULL)
- outofmem(__FILE__, "HTLoadGopher");
+ (char *) malloc(strlen(selector) + 1 + strlen(query) + 2 + 1);
+ if (command == NULL)
+ outofmem(__FILE__, "HTLoadGopher");
de_escape(command, selector); /* Bug fix TBL 921208 */
strcat(command, "\t");
- { /* Remove plus signs 921006 */
+ { /* Remove plus signs 921006 */
char *p;
- for (p=query; *p; p++) {
- if (*p == '+') *p = ' ';
+
+ for (p = query; *p; p++) {
+ if (*p == '+')
+ *p = ' ';
}
}
- de_escape(&command[strlen(command)], query);/* bug fix LJM 940415 */
+ de_escape(&command[strlen(command)], query); /* bug fix LJM 940415 */
} else if (gtype == GOPHER_CSO) {
- char * query;
+ char *query;
+
/*
- ** Search is allowed.
- */
+ * Search is allowed.
+ */
query = strchr(selector, '?'); /* Look for search string */
- if (!query || !query[1]) { /* No search required */
+ if (!query || !query[1]) { /* No search required */
target = HTML_new(anAnchor, format_out, sink);
targetClass = *target->isa;
display_cso(arg, anAnchor); /* Display "cover page" */
- return HT_LOADED; /* Local function only */
+ return HT_LOADED; /* Local function only */
}
HTAnchor_setIndex(anAnchor, anAnchor->address);
- *query++ = '\0'; /* Skip '?' */
- command = (char *)malloc(strlen("query")+1 + strlen(query)+2+1);
- if (command == NULL)
- outofmem(__FILE__, "HTLoadGopher");
+ *query++ = '\0'; /* Skip '?' */
+ command = (char *) malloc(strlen("query") + 1 +
+ strlen(query) + 2 + 1);
+ if (command == NULL)
+ outofmem(__FILE__, "HTLoadGopher");
de_escape(command, selector); /* Bug fix TBL 921208 */
strcpy(command, "query ");
- { /* Remove plus signs 921006 */
+ { /* Remove plus signs 921006 */
char *p;
- for (p=query; *p; p++) {
- if (*p == '+') *p = ' ';
+
+ for (p = query; *p; p++) {
+ if (*p == '+')
+ *p = ' ';
}
}
- de_escape(&command[strlen(command)], query);/* bug fix LJM 940415 */
+ de_escape(&command[strlen(command)], query); /* bug fix LJM 940415 */
- } else { /* Not index */
- command = (char *)malloc(strlen(selector)+2+1);
+ } else { /* Not index */
+ command = (char *) malloc(strlen(selector) + 2 + 1);
if (command == NULL)
outofmem(__FILE__, "HTLoadGopher");
de_escape(command, selector);
@@ -1817,28 +1821,29 @@ PRIVATE int HTLoadGopher ARGS4(
}
{
- char * p = command + strlen(command);
+ char *p = command + strlen(command);
+
*p++ = CR; /* Macros to be correct on Mac */
*p++ = LF;
*p++ = '\0';
}
/*
- ** Set up a socket to the server for the data.
- */
- status = HTDoConnect (arg, "gopher", GOPHER_PORT, &s);
+ * Set up a socket to the server for the data.
+ */
+ status = HTDoConnect(arg, "gopher", GOPHER_PORT, &s);
if (status == HT_INTERRUPTED) {
/*
- ** Interrupt cleanly.
- */
+ * Interrupt cleanly.
+ */
CTRACE((tfp, "HTGopher: Interrupted on connect; recovering cleanly.\n"));
- _HTProgress (CONNECTION_INTERRUPTED);
+ _HTProgress(CONNECTION_INTERRUPTED);
FREE(command);
return HT_NOT_LOADED;
}
if (status < 0) {
CTRACE((tfp, "HTGopher: Unable to connect to remote host for `%s'.\n",
- arg));
+ arg));
FREE(command);
return HTInetStatus("connect");
}
@@ -1846,39 +1851,40 @@ PRIVATE int HTLoadGopher ARGS4(
HTInitInput(s); /* Set up input buffering */
CTRACE((tfp, "HTGopher: Connected, writing command `%s' to socket %d\n",
- command, s));
+ command, s));
#ifdef NOT_ASCII
{
- char * p;
+ char *p;
+
for (p = command; *p; p++) {
*p = TOASCII(*p);
}
}
#endif
- _HTProgress (GOPHER_SENDING_REQUEST);
+ _HTProgress(GOPHER_SENDING_REQUEST);
- status = NETWRITE(s, command, (int)strlen(command));
+ status = NETWRITE(s, command, (int) strlen(command));
FREE(command);
if (status < 0) {
CTRACE((tfp, "HTGopher: Unable to send command.\n"));
return HTInetStatus("send");
}
- _HTProgress (GOPHER_SENT_REQUEST);
+ _HTProgress(GOPHER_SENT_REQUEST);
/*
- ** Now read the data from the socket.
- */
+ * Now read the data from the socket.
+ */
switch (gtype) {
- case GOPHER_TEXT :
+ case GOPHER_TEXT:
HTParseSocket(WWW_PLAINTEXT, format_out, anAnchor, s, sink);
break;
- case GOPHER_HTML :
- case GOPHER_CHTML :
+ case GOPHER_HTML:
+ case GOPHER_CHTML:
HTParseSocket(WWW_HTML, format_out, anAnchor, s, sink);
break;
@@ -1886,11 +1892,11 @@ PRIVATE int HTLoadGopher ARGS4(
case GOPHER_IMAGE:
case GOPHER_PLUS_IMAGE:
HTParseSocket(HTAtom_for("image/gif"),
- format_out, anAnchor, s, sink);
+ format_out, anAnchor, s, sink);
break;
- case GOPHER_MENU :
- case GOPHER_INDEX :
+ case GOPHER_MENU:
+ case GOPHER_INDEX:
target = HTML_new(anAnchor, format_out, sink);
targetClass = *target->isa;
parse_menu(arg, anAnchor);
@@ -1902,8 +1908,8 @@ PRIVATE int HTLoadGopher ARGS4(
parse_cso(arg, anAnchor);
break;
- case GOPHER_SOUND :
- case GOPHER_PLUS_SOUND :
+ case GOPHER_SOUND:
+ case GOPHER_PLUS_SOUND:
HTParseSocket(WWW_AUDIO, format_out, anAnchor, s, sink);
break;
@@ -1913,7 +1919,7 @@ PRIVATE int HTLoadGopher ARGS4(
case GOPHER_PLUS_PDF:
HTParseSocket(HTAtom_for("application/pdf"), format_out, anAnchor,
- s, sink);
+ s, sink);
break;
case GOPHER_MACBINHEX:
@@ -1922,12 +1928,12 @@ PRIVATE int HTLoadGopher ARGS4(
case GOPHER_BINARY:
default:
/*
- ** Specifying WWW_UNKNOWN forces dump to local disk.
- */
- HTParseSocket (WWW_UNKNOWN, format_out, anAnchor, s, sink);
+ * Specifying WWW_UNKNOWN forces dump to local disk.
+ */
+ HTParseSocket(WWW_UNKNOWN, format_out, anAnchor, s, sink);
break;
- } /* switch(gtype) */
+ } /* switch(gtype) */
NETCLOSE(s);
return HT_LOADED;
@@ -1935,12 +1941,14 @@ PRIVATE int HTLoadGopher ARGS4(
#ifdef GLOBALDEF_IS_MACRO
#define _HTGOPHER_C_1_INIT { "gopher", HTLoadGopher, NULL }
-GLOBALDEF (HTProtocol, HTGopher, _HTGOPHER_C_1_INIT);
+GLOBALDEF(HTProtocol, HTGopher, _HTGOPHER_C_1_INIT);
#define _HTCSO_C_1_INIT { "cso", HTLoadCSO, NULL }
-GLOBALDEF (HTProtocol, HTCSO, _HTCSO_C_1_INIT);
+GLOBALDEF(HTProtocol, HTCSO, _HTCSO_C_1_INIT);
#else
-GLOBALDEF PUBLIC HTProtocol HTGopher = { "gopher", HTLoadGopher, NULL };
-GLOBALDEF PUBLIC HTProtocol HTCSO = { "cso", HTLoadCSO, NULL };
+GLOBALDEF HTProtocol HTGopher =
+{"gopher", HTLoadGopher, NULL};
+GLOBALDEF HTProtocol HTCSO =
+{"cso", HTLoadCSO, NULL};
#endif /* GLOBALDEF_IS_MACRO */
#endif /* not DISABLE_GOPHER */