pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:19:   #include "operators.h"   #include "builtin_functions.h"   #include "module_support.h"   #include "fsort.h"   #include "threads.h"   #include "stuff.h"   #include "version.h"   #include "bignum.h"   #include "pikecode.h"    - RCSID("$Id: encode.c,v 1.139 2002/04/07 19:30:08 mast Exp $"); + RCSID("$Id: encode.c,v 1.140 2002/05/02 14:48:10 mast Exp $");      /* #define ENCODE_DEBUG */      #ifdef ENCODE_DEBUG   /* Pass a nonzero integer as the third arg to encode_value,    * encode_value_canonic and decode_value to activate this debug. */   #define EDB(N,X) do { debug_malloc_touch(data); if (data->debug>=N) {X;} } while (0)   #else   #define EDB(N,X) do { debug_malloc_touch(data); } while (0)   #endif
pike.git/src/encode.c:1159:    data->depth -= 2;   #endif   }      static void free_encode_data(struct encode_data *data)   {    toss_buffer(& data->buf);    free_mapping(data->encoded);   }    - /*! @decl string encode_value(mixed value, object|void codec, int|void trace) + /*! @decl string encode_value(mixed value, object|void codec)    *!    *! Code a value into a string.    *!    *! This function takes a value, and converts it to a string. This string    *! can then be saved, sent to another Pike process, packed or used in    *! any way you like. When you want your value back you simply send this    *! string to @[decode_value()] and it will return the value you encoded.    *!    *! Almost any value can be coded, mappings, floats, arrays, circular    *! structures etc.
pike.git/src/encode.c:1196:    *! @seealso    *! @[decode_value()], @[sprintf()], @[encode_value_canonic()]    */   void f_encode_value(INT32 args)   {    ONERROR tmp;    struct encode_data d, *data;    data=&d;       check_all_args("encode_value", args, BIT_MIXED, BIT_VOID | BIT_OBJECT, -  BIT_VOID | BIT_INT, 0); + #ifdef ENCODE_DEBUG +  /* This argument is only an internal debug helper. +  * It's intentionally not part of the function +  * prototype, to keep the argument position free for +  * other uses in the future. */ +  BIT_VOID | BIT_INT, + #endif +  0);       initialize_buf(&data->buf);    data->canonic = 0;    data->encoded=allocate_mapping(128);    data->counter.type=T_INT;    data->counter.u.integer=COUNTER_START;    if(args > 1)    {    data->codec=Pike_sp[1-args].u.object;    }else{
pike.git/src/encode.c:1225:    addstr("\266ke0", 4);    encode_value2(Pike_sp-args, data);    UNSET_ONERROR(tmp);       free_mapping(data->encoded);       pop_n_elems(args);    push_string(low_free_buf(&data->buf));   }    - /*! @decl string encode_value_canonic(mixed value, object|void codec, @ -  *! int|void trace) + /*! @decl string encode_value_canonic(mixed value, object|void codec)    *!    *! Code a value into a string on canonical form.    *!    *! Takes a value and converts it to a string on canonical form, much like    *! @[encode_value()]. The canonical form means that if an identical value is    *! encoded, it will produce exactly the same string again, even if it's    *! done at a later time and/or in another Pike process. The produced    *! string is compatible with @[decode_value()].    *!    *! @note
pike.git/src/encode.c:1251:    *! @seealso    *! @[encode_value()], @[decode_value()]    */   void f_encode_value_canonic(INT32 args)   {    ONERROR tmp;    struct encode_data d, *data;    data=&d;       check_all_args("encode_value_canonic", args, BIT_MIXED, BIT_VOID | BIT_OBJECT, -  BIT_VOID | BIT_INT, 0); + #ifdef ENCODE_DEBUG +  /* This argument is only an internal debug helper. +  * It's intentionally not part of the function +  * prototype, to keep the argument position free for +  * other uses in the future. */ +  BIT_VOID | BIT_INT, + #endif +  0);       initialize_buf(&data->buf);    data->canonic = 1;    data->encoded=allocate_mapping(128);    data->counter.type=T_INT;    data->counter.u.integer=COUNTER_START;    if(args > 1)    {    data->codec=Pike_sp[1-args].u.object;    }else{
pike.git/src/encode.c:3038:    (*l) -= t; (*v) += t;    APPLY_MASTER("programof", 1);    return;       default:    Pike_error("Format error: Unknown type tag %ld:%ld\n",    PTRDIFF_T_TO_LONG(i), PTRDIFF_T_TO_LONG(t));    }   }    - /*! @decl mixed decode_value(string coded_value, object|void codec, @ -  *! int|void trace) + /*! @decl mixed decode_value(string coded_value, object|void codec)    *!    *! Decode a value from a string.    *!    *! This function takes a string created with @[encode_value()] or    *! @[encode_value_canonic()] and converts it back to the value that was    *! coded.    *!    *! If no codec is specified, the current master object will be used as codec.    *!    *! @seealso
pike.git/src/encode.c:3063:   {    struct pike_string *s;    struct object *codec;      #ifdef ENCODE_DEBUG    int debug;   #endif /* ENCODE_DEBUG */       check_all_args("decode_value", args,    BIT_STRING, BIT_VOID | BIT_OBJECT | BIT_INT, -  BIT_VOID | BIT_INT, 0); + #ifdef ENCODE_DEBUG +  /* This argument is only an internal debug helper. +  * It's intentionally not part of the function +  * prototype, to keep the argument position free for +  * other uses in the future. */ +  BIT_VOID | BIT_INT, + #endif +  0);      #ifdef ENCODE_DEBUG    debug = args > 2 ? Pike_sp[2-args].u.integer : 0;   #endif /* ENCODE_DEBUG */       s = Pike_sp[-args].u.string;    if(args<2)    {    codec=get_master();    }