pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:18:   #include "pike_error.h"   #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"    - RCSID("$Id: encode.c,v 1.80 2001/01/25 11:34:18 hubbe Exp $"); + RCSID("$Id: encode.c,v 1.81 2001/02/01 15:54:08 grubba Exp $");      /* #define ENCODE_DEBUG */      #ifdef ENCODE_DEBUG   #define EDB(X) X   #else   #define EDB(X)   #endif      /* The sp macro conflicts with Solaris 2.5.1's <sys/conf.h>. */
pike.git/src/encode.c:712:    }    }   }      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) +  *! +  *! 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. +  *! +  *! To encode objects, programs and functions a codec object must be provided. +  *! +  *! @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, 0);       initialize_buf(&data->buf);    data->canonic = 0;
pike.git/src/encode.c:743:    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) +  *! +  *! 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 +  *! Note that this function is more restrictive than @[encode_value()] with +  *! respect to the types of values it can encode. It will throw an error +  *! if it can't encode to a canonical form. +  *! +  *! @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, 0);       initialize_buf(&data->buf);    data->canonic = 1;
pike.git/src/encode.c:1780:    (*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) +  *! +  *! 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 +  *! @[encode_value()], @[encode_value_canonic()] +  */   void f_decode_value(INT32 args)   {    struct pike_string *s;    struct object *codec;       check_all_args("decode_value", args,    BIT_STRING, BIT_VOID | BIT_OBJECT | BIT_INT, 0);       s = Pike_sp[-args].u.string;    if(args<2)