summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/lynx/WWW/Library/Implementation/HTFWriter.c
diff options
context:
space:
mode:
authoravsm <avsm@openbsd.org>2009-05-31 09:16:50 +0000
committeravsm <avsm@openbsd.org>2009-05-31 09:16:50 +0000
commit71d8b9891a55151b80e6b37e0fd1a8e75fa529d1 (patch)
treec255d1b19a357b3e9230c4aba23ed40fc48a798e /gnu/usr.bin/lynx/WWW/Library/Implementation/HTFWriter.c
parentindent (diff)
downloadwireguard-openbsd-71d8b9891a55151b80e6b37e0fd1a8e75fa529d1.tar.xz
wireguard-openbsd-71d8b9891a55151b80e6b37e0fd1a8e75fa529d1.zip
Update to lynx-2.8.6.rel5, with our local patches maintained where relevant.
tests from miod@ sthen@ jmc@ jsing@ two additional fixes from miod: - fix uninitialized stack variable use, leading to occasional crash. - modify the socklen_t test to include <sys/types.h>, fixes gcc2 build failures
Diffstat (limited to 'gnu/usr.bin/lynx/WWW/Library/Implementation/HTFWriter.c')
-rw-r--r--gnu/usr.bin/lynx/WWW/Library/Implementation/HTFWriter.c292
1 files changed, 142 insertions, 150 deletions
diff --git a/gnu/usr.bin/lynx/WWW/Library/Implementation/HTFWriter.c b/gnu/usr.bin/lynx/WWW/Library/Implementation/HTFWriter.c
index b7b8ac17b14..889deedbc13 100644
--- a/gnu/usr.bin/lynx/WWW/Library/Implementation/HTFWriter.c
+++ b/gnu/usr.bin/lynx/WWW/Library/Implementation/HTFWriter.c
@@ -1,12 +1,12 @@
/* FILE WRITER HTFWrite.h
-** ===========
-**
-** This version of the stream object just writes to a C file.
-** The file is assumed open and left open.
-**
-** Bugs:
-** strings written must be less than buffer size.
-*/
+ * ===========
+ *
+ * This version of the stream object just writes to a C file.
+ * The file is assumed open and left open.
+ *
+ * Bugs:
+ * strings written must be less than buffer size.
+ */
#include <HTUtils.h>
@@ -20,119 +20,115 @@
#include <LYLeaks.h>
/* Stream Object
-** ------------
-*/
+ * ------------
+ */
struct _HTStream {
- CONST HTStreamClass * isa;
+ const HTStreamClass *isa;
- FILE * fp;
- char * end_command;
- char * remove_command;
- BOOL announce;
+ FILE *fp;
+ char *end_command;
+ char *remove_command;
+ BOOL announce;
};
-
/*_________________________________________________________________________
-**
-** B L A C K H O L E C L A S S
-**
-** There is only one black hole instance shared by anyone
-** who wanst a black hole. These black holes don't radiate,
-** they just absorb data.
-*/
-PRIVATE void HTBlackHole_put_character ARGS2(HTStream *, me, char, c)
-{}
-PRIVATE void HTBlackHole_put_string ARGS2(HTStream *, me, CONST char*, s)
-{}
-PRIVATE void HTBlackHole_write ARGS3(HTStream *, me, CONST char*, s, int, l)
-{}
-PRIVATE void HTBlackHole_free ARGS1(HTStream *, me)
-{}
-PRIVATE void HTBlackHole_abort ARGS2(HTStream *, me, HTError, e)
-{}
-
+ *
+ * B L A C K H O L E C L A S S
+ *
+ * There is only one black hole instance shared by anyone
+ * who wanst a black hole. These black holes don't radiate,
+ * they just absorb data.
+ */
+static void HTBlackHole_put_character(HTStream *me, char c)
+{
+}
+static void HTBlackHole_put_string(HTStream *me, const char *s)
+{
+}
+static void HTBlackHole_write(HTStream *me, const char *s, int l)
+{
+}
+static void HTBlackHole_free(HTStream *me)
+{
+}
+static void HTBlackHole_abort(HTStream *me, HTError e)
+{
+}
/* Black Hole stream
-** -----------------
-*/
-PRIVATE CONST HTStreamClass HTBlackHoleClass =
+ * -----------------
+ */
+static const HTStreamClass HTBlackHoleClass =
{
- "BlackHole",
- HTBlackHole_free,
- HTBlackHole_abort,
- HTBlackHole_put_character, HTBlackHole_put_string,
- HTBlackHole_write
+ "BlackHole",
+ HTBlackHole_free,
+ HTBlackHole_abort,
+ HTBlackHole_put_character, HTBlackHole_put_string,
+ HTBlackHole_write
};
-PRIVATE HTStream HTBlackHoleInstance =
+static HTStream HTBlackHoleInstance =
{
- &HTBlackHoleClass,
- NULL,
- NULL,
- NULL,
- NO
+ &HTBlackHoleClass,
+ NULL,
+ NULL,
+ NULL,
+ NO
};
/* Black hole craetion
*/
-PUBLIC HTStream * HTBlackHole NOARGS
+HTStream *HTBlackHole(void)
{
return &HTBlackHoleInstance;
}
-
/*_________________________________________________________________________
-**
-** F I L E A C T I O N R O U T I N E S
-** Bug:
-** All errors are ignored.
-*/
+ *
+ * F I L E A C T I O N R O U T I N E S
+ * Bug:
+ * All errors are ignored.
+ */
/* Character handling
-** ------------------
-*/
+ * ------------------
+ */
-PRIVATE void HTFWriter_put_character ARGS2(HTStream *, me, char, c)
+static void HTFWriter_put_character(HTStream *me, char c)
{
putc(c, me->fp);
}
-
-
/* String handling
-** ---------------
-**
-** Strings must be smaller than this buffer size.
-*/
-PRIVATE void HTFWriter_put_string ARGS2(HTStream *, me, CONST char*, s)
+ * ---------------
+ *
+ * Strings must be smaller than this buffer size.
+ */
+static void HTFWriter_put_string(HTStream *me, const char *s)
{
fputs(s, me->fp);
}
-
/* Buffer write. Buffers can (and should!) be big.
-** ------------
-*/
-PRIVATE void HTFWriter_write ARGS3(HTStream *, me, CONST char*, s, int, l)
+ * ------------
+ */
+static void HTFWriter_write(HTStream *me, const char *s, int l)
{
fwrite(s, 1, l, me->fp);
}
-
-
-
/* Free an HTML object
-** -------------------
-**
-** Note that the SGML parsing context is freed, but the created
-** object is not,
-** as it takes on an existence of its own unless explicitly freed.
-*/
-PRIVATE void HTFWriter_free ARGS1(HTStream *, me)
+ * -------------------
+ *
+ * Note that the SGML parsing context is freed, but the created
+ * object is not,
+ * as it takes on an existence of its own unless explicitly freed.
+ */
+static void HTFWriter_free(HTStream *me)
{
fclose(me->fp);
- if (me->end_command) { /* Temp file */
+ if (me->end_command) { /* Temp file */
_HTProgress(me->end_command); /* Tell user what's happening */
system(me->end_command);
FREE(me->end_command);
@@ -148,10 +144,10 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me)
/* End writing
*/
-PRIVATE void HTFWriter_abort ARGS2(HTStream *, me, HTError, e)
+static void HTFWriter_abort(HTStream *me, HTError e)
{
fclose(me->fp);
- if (me->end_command) { /* Temp file */
+ if (me->end_command) { /* Temp file */
CTRACE((tfp, "HTFWriter: Aborting: file not executed.\n"));
FREE(me->end_command);
if (me->remove_command) {
@@ -163,33 +159,32 @@ PRIVATE void HTFWriter_abort ARGS2(HTStream *, me, HTError, e)
FREE(me);
}
-
-
/* Structured Object Class
-** -----------------------
-*/
-PRIVATE CONST HTStreamClass HTFWriter = /* As opposed to print etc */
+ * -----------------------
+ */
+static const HTStreamClass HTFWriter = /* As opposed to print etc */
{
- "FileWriter",
- HTFWriter_free,
- HTFWriter_abort,
- HTFWriter_put_character, HTFWriter_put_string,
- HTFWriter_write
+ "FileWriter",
+ HTFWriter_free,
+ HTFWriter_abort,
+ HTFWriter_put_character, HTFWriter_put_string,
+ HTFWriter_write
};
-
/* Subclass-specific Methods
-** -------------------------
-*/
+ * -------------------------
+ */
-PUBLIC HTStream* HTFWriter_new ARGS1(FILE *, fp)
+HTStream *HTFWriter_new(FILE *fp)
{
- HTStream* me;
+ HTStream *me;
- if (!fp) return NULL;
+ if (!fp)
+ return NULL;
- me = (HTStream*)malloc(sizeof(*me));
- if (me == NULL) outofmem(__FILE__, "HTML_new");
+ me = (HTStream *) malloc(sizeof(*me));
+ if (me == NULL)
+ outofmem(__FILE__, "HTML_new");
me->isa = &HTFWriter;
me->fp = fp;
@@ -201,27 +196,24 @@ PUBLIC HTStream* HTFWriter_new ARGS1(FILE *, fp)
}
/* Make system command from template
-** ---------------------------------
-**
-** See mailcap spec for description of template.
-*/
+ * ---------------------------------
+ *
+ * See mailcap spec for description of template.
+ */
/* @@ to be written. sprintfs will do for now. */
-
-
/* Take action using a system command
-** ----------------------------------
-**
-** originally from Ghostview handling by Marc Andreseen.
-** Creates temporary file, writes to it, executes system command
-** on end-document. The suffix of the temp file can be given
-** in case the application is fussy, or so that a generic opener can
-** be used.
-*/
-PUBLIC HTStream* HTSaveAndExecute ARGS3(
- HTPresentation *, pres,
- HTParentAnchor *, anchor, /* Not used */
- HTStream *, sink) /* Not used */
+ * ----------------------------------
+ *
+ * originally from Ghostview handling by Marc Andreseen.
+ * Creates temporary file, writes to it, executes system command
+ * on end-document. The suffix of the temp file can be given
+ * in case the application is fussy, or so that a generic opener can
+ * be used.
+ */
+HTStream *HTSaveAndExecute(HTPresentation *pres,
+ HTParentAnchor *anchor, /* Not used */
+ HTStream *sink) /* Not used */
#ifdef UNIX
#define REMOVE_COMMAND "/bin/rm -f %s\n"
@@ -233,30 +225,31 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3(
#ifdef REMOVE_COMMAND
{
char *fnam;
- CONST char * suffix;
+ const char *suffix;
- HTStream* me;
+ HTStream *me;
if (HTClientHost) {
HTAlert(CANNOT_SAVE_REMOTE);
return HTBlackHole();
}
- me = (HTStream*)malloc(sizeof(*me));
- if (me == NULL) outofmem(__FILE__, "Save and execute");
+ me = (HTStream *) malloc(sizeof(*me));
+ if (me == NULL)
+ outofmem(__FILE__, "Save and execute");
me->isa = &HTFWriter;
/* Save the file under a suitably suffixed name */
suffix = HTFileSuffix(pres->rep, anchor->content_encoding);
- fnam = (char *)malloc (L_tmpnam + 16 + strlen(suffix));
+ fnam = (char *) malloc(L_tmpnam + 16 + strlen(suffix));
if (fnam == NULL)
outofmem(__FILE__, "HTSaveAndExecute");
- tmpnam (fnam);
+ tmpnam(fnam);
strcat(fnam, suffix);
- me->fp = fopen (fnam, BIN_W);
+ me->fp = fopen(fnam, BIN_W);
if (!me->fp) {
HTAlert(CANNOT_OPEN_TEMP);
FREE(fnam);
@@ -282,37 +275,38 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3(
return me;
}
-#else /* can do remove */
-{ return NULL; }
+#else /* can do remove */
+{
+ return NULL;
+}
#endif
-
/* Save Locally
-** ------------
-**
-** Bugs:
-** GUI Apps should open local Save panel here really.
-**
-*/
-PUBLIC HTStream* HTSaveLocally ARGS3(
- HTPresentation *, pres,
- HTParentAnchor *, anchor, /* Not used */
- HTStream *, sink) /* Not used */
+ * ------------
+ *
+ * Bugs:
+ * GUI Apps should open local Save panel here really.
+ *
+ */
+HTStream *HTSaveLocally(HTPresentation *pres,
+ HTParentAnchor *anchor, /* Not used */
+ HTStream *sink) /* Not used */
{
char *fnam;
char *answer;
- CONST char * suffix;
+ const char *suffix;
- HTStream* me;
+ HTStream *me;
if (HTClientHost) {
HTAlert(CANNOT_SAVE_REMOTE);
return HTBlackHole();
}
- me = (HTStream*)malloc(sizeof(*me));
- if (me == NULL) outofmem(__FILE__, "SaveLocally");
+ me = (HTStream *) malloc(sizeof(*me));
+ if (me == NULL)
+ outofmem(__FILE__, "SaveLocally");
me->isa = &HTFWriter;
me->end_command = NULL;
me->remove_command = NULL; /* If needed, put into end_command */
@@ -322,18 +316,18 @@ PUBLIC HTStream* HTSaveLocally ARGS3(
suffix = HTFileSuffix(pres->rep, anchor->content_encoding);
- fnam = (char *)malloc (L_tmpnam + 16 + strlen(suffix));
+ fnam = (char *) malloc(L_tmpnam + 16 + strlen(suffix));
if (fnam == NULL)
outofmem(__FILE__, "HTSaveLocally");
- tmpnam (fnam);
+ tmpnam(fnam);
strcat(fnam, suffix);
- /* Save Panel */
+ /* Save Panel */
answer = HTPrompt(GIVE_FILENAME, fnam);
FREE(fnam);
- me->fp = fopen (answer, BIN_W);
+ me->fp = fopen(answer, BIN_W);
if (!me->fp) {
HTAlert(CANNOT_OPEN_OUTPUT);
FREE(answer);
@@ -345,8 +339,6 @@ PUBLIC HTStream* HTSaveLocally ARGS3(
return me;
}
-
-
/* Format Converter using system command
-** -------------------------------------
-*/
+ * -------------------------------------
+ */