pike.git
/
src
/
modules
/
_Roxen
/
roxen.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/modules/_Roxen/roxen.c:26:
#include "array.h" #include "builtin_functions.h" #include "module_support.h" #include "backend.h" #include "threads.h" #include "operators.h" /* must be last include! */ #include "module_magic.h"
-
/*
***
CLASS
HeaderParser
*/
+
/*
!
@module
_Roxen
+
*/
-
+
/*! @class HeaderParser
+
*/
+
#define THP ((struct header_buf *)Pike_fp->current_object->storage) struct header_buf { char headers[8192]; char *pnt; ptrdiff_t left; };
-
+
/*! @decl array(string|mapping) feed(string data)
+
*/
static void f_hp_feed( INT32 args ) { struct pike_string *str = Pike_sp[-1].u.string; int tot_slash_n=0, slash_n = 0, spc = 0, cnt, num; char *pp,*ep; struct svalue *tmp; struct mapping *headers; ptrdiff_t os=0, i, j, l; unsigned char *in;
pike.git/src/modules/_Roxen/roxen.c:144:
pop_n_elems(2); if( in[j+1] == '\n' ) j++; os = j+1; i = j; } } push_mapping( headers ); f_aggregate( 3 ); /* data, firstline, headers */ }
+
/*! @decl void create(void)
+
*/
static void f_hp_create( INT32 args ) { THP->pnt = THP->headers; THP->left = 8192;
-
+
pop_n_elems(args);
+
push_int(0);
}
-
/**** END CLASS HeaderParser */
+
-
+
/*! @endclass
+
*/
+
+
/*! @decl string @
+
*! make_http_headers(mapping(string:string|array(string)) headers)
+
*/
static void f_make_http_headers( INT32 args ) { int total_len = 0, e; char *pnt; struct mapping *m; struct keypair *k; struct pike_string *res; if( Pike_sp[-1].type != PIKE_T_MAPPING ) Pike_error("Wrong argument type to make_http_headers(mapping heads)\n");
pike.git/src/modules/_Roxen/roxen.c:221:
} } } *(pnt++) = '\r'; *(pnt++) = '\n'; pop_n_elems( args ); push_string( end_shared_string( res ) ); }
+
/*! @decl string http_decode_string(string encoded)
+
*!
+
*! Decodes an http transport-encoded string.
+
*/
static void f_http_decode_string(INT32 args) { int proc; char *foo,*bar,*end; struct pike_string *newstr; if (!args || Pike_sp[-args].type != PIKE_T_STRING) Pike_error("Invalid argument to http_decode_string(STRING);\n"); foo=bar=Pike_sp[-args].u.string->str;
pike.git/src/modules/_Roxen/roxen.c:256:
((bar[2]<'A')?(bar[2]&15):((bar[2]+9)&15)); else *foo=0; bar+=3; } else { *foo=*(bar++); } pop_n_elems(args); push_string(end_shared_string(newstr)); }
+
/*! @endmodule
+
*/
void pike_module_init() { pike_add_function("make_http_headers", f_make_http_headers, "function(mapping(string:string|array(string)):string)", 0 ); pike_add_function("http_decode_string", f_http_decode_string, "function(string:string)", 0 ); start_new_program(); ADD_STORAGE( struct header_buf ); pike_add_function( "feed", f_hp_feed, "function(string:array(string|mapping))",0 );
-
pike_add_function( "create", f_hp_create, "function(
void
:void)",
0
);
+
pike_add_function( "create", f_hp_create, "function(:void)",
ID_STATIC
);
end_class( "HeaderParser", 0 ); } void pike_module_exit() { }