pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:17:   #include "dynamic_buffer.h"   #include "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"    - RCSID("$Id: encode.c,v 1.34 1999/09/16 20:30:33 hubbe Exp $"); + RCSID("$Id: encode.c,v 1.35 1999/09/17 23:36:57 hubbe Exp $");      #ifdef _AIX   #include <net/nh.h>   #endif      #ifdef HAVE_NETINET_IN_H   #include <netinet/in.h>   #endif      #include <math.h>
pike.git/src/encode.c:69:    struct object *codec;    struct svalue counter;    struct mapping *encoded;    dynamic_buffer buf;   };      static void encode_value2(struct svalue *val, struct encode_data *data);      #define addstr(s, l) low_my_binary_strcat((s), (l), &(data->buf))   #define addchar(t) low_my_putchar((t),&(data->buf)) +  + /* Code a pike string */ + /* FIXME: Wide strings! */   #define adddata(S) do { \    code_entry(T_STRING, (S)->len, data); \    addstr((char *)((S)->str),(S)->len); \   }while(0)    -  + /* Like adddata, but allows null pointers */ +  + #define adddata3(S) do { \ +  if(S) { \ +  code_entry(T_STRING, (S)->len, data); \ +  addstr((char *)((S)->str),(S)->len); \ +  } else { \ +  code_entry(T_INT, 0, data); \ +  } \ + }while(0) +    #define adddata2(s,l) addstr((char *)(s),(l) * sizeof(s[0]));      /* Current encoding: ┬Âik0 */   #define T_AGAIN 15   #define T_MASK 15   #define T_NEG 16   #define T_SMALL 32   #define SIZE_SHIFT 6   #define MAX_SMALL (1<<(8-SIZE_SHIFT))   #define COUNTER_START -MAX_SMALL
pike.git/src/encode.c:461:    sp[-1].subtype=p->inherits[d].parent_identifier;    sp[-1].type=T_FUNCTION;    }else if(p->inherits[d].prog){    ref_push_program(p->inherits[d].prog);    }else{    push_int(0);    }    encode_value2(sp-1,data);    pop_stack();    -  adddata(p->inherits[d].name); +  adddata3(p->inherits[d].name);    }       for(d=0;d<p->num_identifiers;d++)    {    adddata(p->identifiers[d].name);    encode_type(p->identifiers[d].type->str, data);    code_number(p->identifiers[d].identifier_flags,data);    code_number(p->identifiers[d].run_time_type,data);    code_number(p->identifiers[d].func.offset,data);    }
pike.git/src/encode.c:583:      #define getdata(X) do { \    long length; \    decode_entry(T_STRING, length,data); \    if(data->ptr + length > data->len || length <0) \    error("Failed to decode string. (string range error)\n"); \    X=make_shared_binary_string((char *)(data->data + data->ptr), length); \    data->ptr+=length; \    }while(0)    + #define getdata3(X) do { \ +  long length; \ +  int what, e, num; \ +  DECODE(); \ +  length=num; \ +  switch(what & T_MASK) \ +  { \ +  case T_INT: \ +  X=0; \ +  break; \ +  \ +  case T_STRING: \ +  if(data->ptr + length > data->len || length <0) \ +  error("Failed to decode string. (string range error)\n"); \ +  X=make_shared_binary_string((char *)(data->data + data->ptr), length); \ +  data->ptr+=length; \ +  break; \ +  \ +  default: \ +  error("Failed to decode string, type is wrong: %d\n",what & T_MASK); \ +  } \ + }while(0) +    #define decode_number(X,data) do { \    int what, e, num; \    DECODE(); \    X=(what & T_MASK) | (num<<4); \    }while(0) \         static void low_decode_type(struct decode_data *data)   {    int tmp;
pike.git/src/encode.c:1054:       case T_PROGRAM:    p->inherits[d].parent_identifier=0;    p->inherits[d].prog=sp[-1].u.program;    sp--;    break;    default:    error("Failed to decode inheritance.\n");    }    -  getdata(p->inherits[d].name); +  getdata3(p->inherits[d].name);    }       debug_malloc_touch(dat);       for(d=0;d<p->num_identifiers;d++)    {    getdata(p->identifiers[d].name);    decode_type(p->identifiers[d].type,data);    decode_number(p->identifiers[d].identifier_flags,data);    decode_number(p->identifiers[d].run_time_type,data);