-#define DS_INIT_LENGTH 40
-
-#ifdef WGET_HACKS
-/* Wget uses different naming conventions. */
-# define xmalloc nmalloc
-# define xstrdup nstrdup
-# define xrealloc nrealloc
-
-/* Wget has read_whole_line defined in utils.c */
-# include "utils.h"
-
-/* Temporary dynamic string (dstring.c from libit)-like interface to
- using read_whole_line. */
-#define ds_init(string, size) ((string)->ds_string = NULL)
-#define ds_destroy(string) free ((string)->ds_string)
-
-/* We use read_whole_line to implement ds_fgets. */
-static char *
-ds_fgets (FILE *f, dynamic_string *s)
-{
- free (s->ds_string);
- s->ds_string = read_whole_line (f);
- return s->ds_string;
-}
-#endif /* WGET_HACKS */
-
-#ifdef FETCHMAIL_HACKS
-/* fetchmail, too, is not consistent with the xmalloc functions. */
-# define xrealloc realloc
-# define xstrdup strdup
-#endif
-
-#if defined(STANDALONE) || defined(FETCHMAIL_HACKS)
-/* Bits and pieces of Tom Tromey's dstring.c, taken from libit-0.2. */
-
-/* Initialize dynamic string STRING with space for SIZE characters. */
-
-void
-ds_init (string, size)
- dynamic_string *string;
- int size;
-{
- string->ds_length = size;
- string->ds_string = (char *) xmalloc (size);
-}
-
-/* Expand dynamic string STRING, if necessary, to hold SIZE characters. */
-
-void
-ds_resize (string, size)
- dynamic_string *string;
- int size;
-{
- if (size > string->ds_length)
- {
- string->ds_length = size;
- string->ds_string = (char *) xrealloc ((char *) string->ds_string, size);
- }
-}
-
-/* Delete dynamic string. */
-
-void
-ds_destroy (string)
- dynamic_string *string;
-{
- free (string->ds_string);
- string->ds_string = NULL;
-}
-
-/* Dynamic string S gets a string terminated by the EOS character
- (which is removed) from file F. S will increase
- in size during the function if the string from F is longer than
- the current size of S.
- Return NULL if end of file is detected. Otherwise,
- Return a pointer to the null-terminated string in S. */
-
-char *
-ds_fgetstr (f, s, eos)
- FILE *f;
- dynamic_string *s;
- char eos;
-{
- int insize; /* Amount needed for line. */
- int strsize; /* Amount allocated for S. */
- int next_ch;
-
- /* Initialize. */
- insize = 0;
- strsize = s->ds_length;
-
- /* Read the input string. */
- next_ch = getc (f);
- while (next_ch != eos && next_ch != EOF)
- {
- if (insize >= strsize - 1)
- {
- ds_resize (s, strsize * 2 + 2);
- strsize = s->ds_length;
- }
- s->ds_string[insize++] = next_ch;
- next_ch = getc (f);
- }
- s->ds_string[insize++] = '\0';
-
- if (insize == 1 && next_ch == EOF)
- return NULL;
- else
- return s->ds_string;
-}
-
-char *
-ds_fgets (f, s)
- FILE *f;
- dynamic_string *s;
-{
- return ds_fgetstr (f, s, '\n');
-}
-#endif /* !STANDALONE */
-
-