pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:29:   #include "time_stuff.h"   #include "version.h"   #include "encode.h"   #include <math.h>   #include <ctype.h>   #include "module_support.h"   #include "module.h"   #include "opcodes.h"   #include "cyclic.h"   #include "signal_handler.h" - #include "pike_security.h" +    #include "builtin_functions.h"   #include "bignum.h"   #include "peep.h"   #include "docode.h"   #include "lex.h"   #include "pike_float.h"   #include "pike_compiler.h"      #include <errno.h>   
pike.git/src/builtin_functions.c:1509:    *!    *! Calling @[add_constant()] without a value will remove that name from    *! the list of constants. As with replacing, this will not affect already    *! compiled programs.    *!    *! @seealso    *! @[all_constants()]    */   PMOD_EXPORT void f_add_constant(INT32 args)   { -  ASSERT_SECURITY_ROOT("add_constant"); -  +     if(args<1)    SIMPLE_TOO_FEW_ARGS_ERROR("add_constant", 1);       if(TYPEOF(Pike_sp[-args]) != T_STRING)    SIMPLE_BAD_ARG_ERROR("add_constant", 1, "string");       if(args>1)    {    dmalloc_touch_svalue(Pike_sp-args+1);    low_add_efun(Pike_sp[-args].u.string, Pike_sp-args+1);
pike.git/src/builtin_functions.c:3006:    *!    *! The arguments after the @[returncode] will be used for a call to    *! @[werror] to output a message on stderr.    *!    *! @seealso    *! @[_exit()]    */   PMOD_EXPORT void f_exit(INT32 args)   {    static int in_exit=0; -  ASSERT_SECURITY_ROOT("exit"); -  +     if(args < 1)    SIMPLE_TOO_FEW_ARGS_ERROR("exit", 1);       if(TYPEOF(Pike_sp[-args]) != T_INT)    SIMPLE_BAD_ARG_ERROR("exit", 1, "int");       if(in_exit) Pike_error("exit already called!\n");    in_exit=1;       if(args>1 && TYPEOF(Pike_sp[1-args]) == T_STRING) {
pike.git/src/builtin_functions.c:3055:    *! released, and databases might not be closed properly.    *!    *! Use with extreme caution.    *!    *! @seealso    *! @[exit()]    */   void f__exit(INT32 args)   {    int code; -  ASSERT_SECURITY_ROOT("_exit"); -  +     get_all_args("_exit", args, "%d", &code);      #ifdef PIKE_DEBUG    {    /* This will allow -p to work with _exit -Hubbe */    exit_opcodes();    }   #endif       /* FIXME: Shouldn't _exit(2) be called here? */
pike.git/src/builtin_functions.c:3240:    if(!Pike_fp) {    PIKE_ERROR("destruct",    "Destruct called without argument from callback function.\n",    Pike_sp, args);    }    o=Pike_fp->current_object;    }    if (o->prog && o->prog->flags & PROGRAM_NO_EXPLICIT_DESTRUCT)    PIKE_ERROR("destruct", "Object can't be destructed explicitly.\n",    Pike_sp, args); - #ifdef PIKE_SECURITY -  if(!CHECK_DATA_SECURITY(o, SECURITY_BIT_DESTRUCT)) -  Pike_error("Destruct permission denied.\n"); - #endif +     debug_malloc_touch(o);    destruct_object (o, DESTRUCT_EXPLICIT);    pop_n_elems(args);    destruct_objects_to_destruct();   }      /*! @decl array indices(string|array|mapping|multiset|object x)    *!    *! Return an array of all valid indices for the value @[x].    *!
pike.git/src/builtin_functions.c:3742:    *! @note    *! This function is not recomended to use.    *!    *! @seealso    *! @[destruct()]    */   PMOD_EXPORT void f_next_object(INT32 args)   {    struct object *o;    -  ASSERT_SECURITY_ROOT("next_object"); -  +     if(args < 1)    {    o = first_object;    }else{    if(TYPEOF(Pike_sp[-args]) != T_OBJECT)    SIMPLE_BAD_ARG_ERROR("next_object", 1, "object");    o = Pike_sp[-args].u.object->next;    }    while(o && !o->prog) o=o->next;    pop_n_elems(args);
pike.git/src/builtin_functions.c:5320:    *! @returns    *! The total number of objects    *!    *! @seealso    *! @[next_object()]    */   static void f_map_all_objects( INT32 UNUSED(args) )   {    struct object *o = first_object;    INT32 total = 0; -  ASSERT_SECURITY_ROOT("_map_all_objects"); +     while( o )    {    struct object *next = o->next;    if( o->prog )    {    ref_push_object( o );    safe_apply_svalue( Pike_sp-2, 1, 1 );    pop_stack();    }    total++;
pike.git/src/builtin_functions.c:5353:    *! generates a fatal error if one of them is found to be out of order.    *! It is only used for debugging.    *!    *! @note    *! This function does a more thorough check if the Pike runtime has    *! been compiled with RTL debug.    */   PMOD_EXPORT void f__verify_internals(INT32 args)   {    INT32 tmp=d_flag; -  ASSERT_SECURITY_ROOT("_verify_internals"); -  +     /* Keep below calls to low_thorough_check_short_svalue, or else we    * get O(n!) or so, where n is the number of allocated things. */    d_flag = 49;      #ifdef PIKE_DEBUG    do_debug(); /* Calls do_gc() since d_flag > 3. */   #else    do_gc(NULL, 1);   #endif    d_flag=tmp;
pike.git/src/builtin_functions.c:5386: Inside #if defined(PIKE_DEBUG)
   *! The old debug level will be returned.    *!    *! @note    *! This function is only available if the Pike runtime has been compiled    *! with RTL debug.    */   PMOD_EXPORT void f__debug(INT32 args)   {    INT_TYPE d;    -  ASSERT_SECURITY_ROOT("_debug"); -  +     get_all_args("_debug", args, "%+", &d);    pop_n_elems(args);    push_int(d_flag);    d_flag = d;   }      /*! @decl int(0..) optimizer_debug(int(0..) level)    *! @belongs Debug    *!    *! Set the optimizer debug level.
pike.git/src/builtin_functions.c:5409: Inside #if defined(PIKE_DEBUG)
   *! @returns    *! The old optimizer debug level will be returned.    *!    *! @note    *! This function is only available if the Pike runtime has been compiled    *! with RTL debug.    */   PMOD_EXPORT void f__optimizer_debug(INT32 args)   {    INT_TYPE l; -  -  ASSERT_SECURITY_ROOT("_optimizer_debug"); -  +     get_all_args("_optimizer_debug", args, "%+", &l);    pop_n_elems(args);    push_int(l_flag);    l_flag = l;   }         /*! @decl int(0..) assembler_debug(int(0..) level)    *! @belongs Debug    *!
pike.git/src/builtin_functions.c:5434: Inside #if defined(PIKE_DEBUG)
   *! @returns    *! The old assembler debug level will be returned.    *!    *! @note    *! This function is only available if the Pike runtime has been compiled    *! with RTL debug.    */   PMOD_EXPORT void f__assembler_debug(INT32 args)   {    INT_TYPE l; -  -  ASSERT_SECURITY_ROOT("_assembler_debug"); -  +     get_all_args("_assembler_debug", args, "%+", &l);    pop_n_elems(args);    push_int(a_flag);    a_flag = l;   }      /*! @decl void dump_program_tables(program p, int(0..)|void indent)    *! @belongs Debug    *!    *! Dumps the internal tables for the program @[p] on stderr.
pike.git/src/builtin_functions.c:5461: Inside #if defined(PIKE_DEBUG)
   *! @param indent    *! Number of spaces to indent the output.    *!    *! @note    *! In Pike 7.8.308 and earlier @[indent] wasn't supported.    */   void f__dump_program_tables(INT32 args)   {    struct program *p;    INT_TYPE indent = 0; -  -  ASSERT_SECURITY_ROOT("_dump_program_tables"); /* FIXME: Might want lower. */ +     get_all_args("_dump_program_tables", args, "%p.%+", &p, &indent);       dump_program_tables(p, indent);    pop_n_elems(args);   }      #ifdef YYDEBUG      /*! @decl int(0..) compiler_trace(int(0..) level)    *! @belongs Debug
pike.git/src/builtin_functions.c:5487: Inside #if defined(PIKE_DEBUG) and #if defined(YYDEBUG)
   *! The old compiler trace level will be returned.    *!    *! @note    *! This function is only available if the Pike runtime has been compiled    *! with RTL debug.    */   PMOD_EXPORT void f__compiler_trace(INT32 args)   {    extern int yydebug;    INT_TYPE yyd; -  ASSERT_SECURITY_ROOT("_compiler_trace"); -  +     get_all_args("_compiler_trace", args, "%i", &yyd);    pop_n_elems(args);    push_int(yydebug);    yydebug = yyd;   }      #endif /* YYDEBUG */   #endif      static void encode_struct_tm(struct tm *tm)
pike.git/src/builtin_functions.c:7720:    *! item on the corresponding list. It is mainly meant for debugging    *! the Pike runtime, but can also be used to control memory usage.    *!    *! @seealso    *! @[next_object()], @[_prev()]    */   PMOD_EXPORT void f__next(INT32 args)   {    struct svalue tmp;    -  ASSERT_SECURITY_ROOT("_next"); -  +     if(!args)    SIMPLE_TOO_FEW_ARGS_ERROR("_next", 1);       pop_n_elems(args-1);    args = 1;    tmp=Pike_sp[-1];    switch(TYPEOF(tmp))    {    case T_OBJECT: tmp.u.object=tmp.u.object->next; break;    case T_ARRAY: tmp.u.array=tmp.u.array->next; break;
pike.git/src/builtin_functions.c:7768:    *! @note    *! Unlike @[_next()] this function does not work on strings.    *!    *! @seealso    *! @[next_object()], @[_next()]    */   PMOD_EXPORT void f__prev(INT32 args)   {    struct svalue tmp;    -  ASSERT_SECURITY_ROOT("_prev"); -  +     if(!args)    SIMPLE_TOO_FEW_ARGS_ERROR("_prev", 1);       pop_n_elems(args-1);    args = 1;    tmp=Pike_sp[-1];    switch(TYPEOF(tmp))    {    case T_OBJECT: tmp.u.object=tmp.u.object->prev; break;    case T_ARRAY: tmp.u.array=tmp.u.array->prev; break;
pike.git/src/builtin_functions.c:7886:    *! only re-define certain functions.    *!    *! FIXME: Tell how to inherit the master.    *!    *! @seealso    *! @[master()]    */   PMOD_EXPORT void f_replace_master(INT32 args)   {    struct object *new_master; -  ASSERT_SECURITY_ROOT("replace_master"); +        if(!args)    SIMPLE_TOO_FEW_ARGS_ERROR("replace_master", 1);    if(TYPEOF(Pike_sp[-args]) != T_OBJECT)    SIMPLE_BAD_ARG_ERROR("replace_master", 1, "object");    new_master = Pike_sp[-args].u.object;    if(!new_master->prog)    bad_arg_error("replace_master", Pike_sp-args, args, 1, "object", Pike_sp-args,    "Called with destructed object.\n");   
pike.git/src/builtin_functions.c:8407: Inside #if defined(DEBUG_MALLOC)
     #ifdef DEBUG_MALLOC   /*! @decl void reset_dmalloc()    *! @belongs Debug    *!    *! @note    *! Only available when compiled with dmalloc.    */   PMOD_EXPORT void f__reset_dmalloc(INT32 args)   { -  ASSERT_SECURITY_ROOT("_reset_dmalloc"); +     pop_n_elems(args);    reset_debug_malloc();   }      /*! @decl void dmalloc_set_name(string filename, int(1..) linenumber)    *! @belongs Debug    *!    *! @note    *! Only available when compiled with dmalloc.    */
pike.git/src/builtin_functions.c:8457: Inside #if defined(DEBUG_MALLOC)
  /*! @decl void dump_dmalloc_locations(string|array|mapping| @    *! multiset|function|object| @    *! program|type o)    *! @belongs Debug    *!    *! @note    *! Only available when compiled with dmalloc.    */   PMOD_EXPORT void f__dump_dmalloc_locations(INT32 args)   { -  ASSERT_SECURITY_ROOT("_dump_dmalloc_locations"); +     if(args)    debug_malloc_dump_references (Pike_sp[-args].u.refs, 2, 1, 0);    pop_n_elems(args-1);   }   #endif      #ifdef PIKE_DEBUG   /*! @decl void locate_references(string|array|mapping| @    *! multiset|function|object| @    *! program|type o)
pike.git/src/builtin_functions.c:8481: Inside #if defined(PIKE_DEBUG)
   *! all data structures in Pike looking for @[o] and print the    *! locations on stderr. @[o] can be anything but @expr{int@} or    *! @expr{float@}.    *!    *! @note    *! This function only exists if the Pike runtime has been compiled    *! with RTL debug.    */   PMOD_EXPORT void f__locate_references(INT32 args)   { -  ASSERT_SECURITY_ROOT("_locate_references"); +     if(args)    locate_references(Pike_sp[-args].u.refs);    pop_n_elems(args-1);   }      /*! @decl mixed describe(mixed x)    *! @belongs Debug    *!    *! Prints out a description of the thing @[x] to standard error.    *! The description contains various internal info associated with    *! @[x].    *!    *! @note    *! This function only exists if the Pike runtime has been compiled    *! with RTL debug.    */   PMOD_EXPORT void f__describe(INT32 args)   {    struct svalue *s; -  ASSERT_SECURITY_ROOT("_describe"); +     get_all_args("_describe", args, "%*", &s);    debug_describe_svalue(debug_malloc_pass(s));    pop_n_elems(args-1);   }      /*! @decl void gc_set_watch(array|multiset|mapping|object|function|program|string x)    *! @belongs Debug    *!    *! Sets a watch on the given thing, so that the gc will print a    *! message whenever it's encountered. Intended to be used together    *! with breakpoints to debug the garbage collector.    *!    *! @note    *! This function only exists if the Pike runtime has been compiled    *! with RTL debug.    */   PMOD_EXPORT void f__gc_set_watch(INT32 args)   { -  ASSERT_SECURITY_ROOT("_gc_set_watch"); -  +     if (args < 1)    SIMPLE_TOO_FEW_ARGS_ERROR("_gc_set_watch", 1);    if (!REFCOUNTED_TYPE(TYPEOF(Pike_sp[-args])))    SIMPLE_BAD_ARG_ERROR("_gc_set_watch", 1, "reference type");    gc_watch(Pike_sp[-args].u.refs);    pop_n_elems(args);   }      /*! @decl void dump_backlog()    *! @belongs Debug
pike.git/src/builtin_functions.c:8544: Inside #if defined(PIKE_DEBUG)
   *! code lines, to standard error. The backlog is only collected on    *! debug level 1 or higher, set with @[_debug] or with the @tt{-d@}    *! argument on the command line.    *!    *! @note    *! This function only exists if the Pike runtime has been compiled    *! with RTL debug.    */   PMOD_EXPORT void f__dump_backlog(INT32 args)   { -  ASSERT_SECURITY_ROOT("_dump_backlog"); +     pop_n_elems(args);    dump_backlog();   }      #endif      /*! @decl mixed map(mixed arr, void|mixed fun, mixed ... extra)    *!    *! Applies @[fun] to the elements in @[arr] and collects the results.    *!