| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

http_encode_meta

#include "sflhttp.h"
size_t
http_encode_meta (
    char    *output,
    char    **input,
    size_t  outmax,
    Bool    html)

Synopsis

Translates special characters into HTML/SGML metacharacters. The input buffer is not modified; you supply an output buffer and specify the maximum size of this buffer. The input buffer must end in a null. Aftern calling, the input pointer is set to the character after the last encoded character. Returns the final size of the translated data excluding the final null byte. If the resulting output data would be too long, translations stops. If html is TRUE then the metacharacters amp, lt, gt and quot are not translated - this allows you to encode markup characters within HTML; otherwise they are translated and the output doesn't look like HTML.

Source Code - (sflhttp.c)

{
    size_t
        space_left,                     /*  Space left in destination        */
        length;
    char
        *dest;                          /*  Pointer to result string         */

    ASSERT (input);
    ASSERT (*input);
    ASSERT (output);

    if (outmax == 0)                    /*  Special case for zero space      */
        return (0);

    space_left = outmax - 1;            /*  Allow for final null byte        */
    dest = output;
    while (**input && space_left > 0)
      {
        length = encode meta char (dest, **input, space_left, html);
        if (length)
          {
            space_left -= length;
            dest += length;
            (*input) ++;
          }
        else
            break;
      }
    *dest = '\0';
    return ((size_t) (dest - output));
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation