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

 

http_escape_size

#include "sflhttp.h"
size_t
http_escape_size (
    const char *string)

Synopsis

Returns the size of a string after HTTP escaping. See the http escape() function for details of the escaping algorithm. Includes the null terminator in the returned size.

Source Code - (sflhttp.c)

{
    size_t
        result_size = 1;                /*  Allow for null terminator        */

    ASSERT (string);
    while (*string)
      {
        if (isalnum (*string))          /*  Don't escape letters or digits   */
            result_size++;
        else
        if (*string == '\n' || *string == '\r')
          {
            if ((string [1] == '\n' || string [1] == '\r')
            &&  (string [1] != *string))
                string++;
            result_size += 6;           /*  Line ending becomes %0D%0A       */
          }
        else
            result_size += 3;           /*  Some other escaped character     */

        string++;
      }
    return (result_size);
}

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