pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: builtin_functions.c,v 1.508 2003/09/05 15:50:22 grubba Exp $ + || $Id: builtin_functions.c,v 1.509 2003/09/06 23:08:59 nilsson Exp $   */      #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.508 2003/09/05 15:50:22 grubba Exp $"); + RCSID("$Id: builtin_functions.c,v 1.509 2003/09/06 23:08:59 nilsson Exp $");   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"   #include "pike_error.h"   #include "constants.h"   #include "mapping.h"   #include "stralloc.h"
pike.git/src/builtin_functions.c:1183:    *!    *! 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)   { -  CHECK_SECURITY_OR_ERROR(SECURITY_BIT_SECURITY, ("add_constant: permission denied.\n")); +  ASSERT_SECURITY_ROOT("add_constant"); +     if(args<1)    SIMPLE_TOO_FEW_ARGS_ERROR("add_constant", 1);       if(Pike_sp[-args].type!=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:2100:    *! Using @[exit()] with any other value than @expr{0@} (zero) indicates    *! that something went wrong during execution. See your system manuals    *! for more information about return codes.    *!    *! @seealso    *! @[_exit()]    */   PMOD_EXPORT void f_exit(INT32 args)   {    static int in_exit=0; -  CHECK_SECURITY_OR_ERROR(SECURITY_BIT_SECURITY, ("exit: permission denied.\n")); +  ASSERT_SECURITY_ROOT("exit"); +     if(args < 1)    SIMPLE_TOO_FEW_ARGS_ERROR("exit", 1);       if(Pike_sp[-args].type != T_INT)    SIMPLE_BAD_ARG_ERROR("exit", 1, "int");       if(in_exit) Pike_error("exit already called!\n");    in_exit=1;       assign_svalue(&throw_value, Pike_sp-args);
pike.git/src/builtin_functions.c:2129:    *! will be called, caches will not be flushed, file locks might not be    *! released, and databases might not be closed properly.    *!    *! Use with extreme caution.    *!    *! @seealso    *! @[exit()]    */   void f__exit(INT32 args)   { -  CHECK_SECURITY_OR_ERROR(SECURITY_BIT_SECURITY, ("_exit: permission denied.\n")); +  ASSERT_SECURITY_ROOT("_exit"); +     if(args < 1)    SIMPLE_TOO_FEW_ARGS_ERROR("_exit", 1);       if(Pike_sp[-args].type != T_INT)    SIMPLE_BAD_ARG_ERROR("_exit", 1, "int");      #ifdef PIKE_DEBUG    {    /* This will allow -p to work with _exit -Hubbe */    extern void exit_lex(void);
pike.git/src/builtin_functions.c:2710:    *! @note    *! This function is not recomended to use.    *!    *! @seealso    *! @[destruct()]    */   PMOD_EXPORT void f_next_object(INT32 args)   {    struct object *o;    -  CHECK_SECURITY_OR_ERROR(SECURITY_BIT_SECURITY, ("next_object: permission denied.\n")); +  ASSERT_SECURITY_ROOT("next_object");       if(args < 1)    {    o = first_object;    }else{    if(Pike_sp[-args].type != T_OBJECT)    SIMPLE_BAD_ARG_ERROR("next_object", 1, "object");    o = Pike_sp[-args].u.object->next;    }    while(o && !o->prog) o=o->next;
pike.git/src/builtin_functions.c:4029:    *! 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; -  CHECK_SECURITY_OR_ERROR(SECURITY_BIT_SECURITY, -  ("_verify_internals: permission denied.\n")); +  ASSERT_SECURITY_ROOT("_verify_internals"); +     d_flag=0x7fffffff;   #ifdef PIKE_DEBUG    do_debug(); /* Calls do_gc() since d_flag > 3. */   #else    do_gc(NULL, 1);   #endif    d_flag=tmp;    pop_n_elems(args);   }   
pike.git/src/builtin_functions.c:4059: 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;    -  CHECK_SECURITY_OR_ERROR(SECURITY_BIT_SECURITY, -  ("_debug: permission denied.\n")); +  ASSERT_SECURITY_ROOT("_debug");       get_all_args("_debug", args, "%i", &d);    pop_n_elems(args);    push_int(d_flag);    d_flag = d;   }      /*! @decl int optimizer_debug(int(0..) level)    *! @belongs Debug    *!
pike.git/src/builtin_functions.c:4084: Inside #if defined(PIKE_DEBUG)
   *! 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;    -  CHECK_SECURITY_OR_ERROR(SECURITY_BIT_SECURITY, -  ("_optimizer_debug: permission denied.\n")); +  ASSERT_SECURITY_ROOT("_optimizer_debug");       get_all_args("_optimizer_debug", args, "%i", &l);    pop_n_elems(args);    push_int(l_flag);    l_flag = l;   }         /*! @decl int assembler_debug(int(0..) level)    *! @belongs Debug
pike.git/src/builtin_functions.c:4110: Inside #if defined(PIKE_DEBUG)
   *! 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;    -  CHECK_SECURITY_OR_ERROR(SECURITY_BIT_SECURITY, -  ("_assembler_debug: permission denied.\n")); +  ASSERT_SECURITY_ROOT("_assembler_debug");       get_all_args("_assembler_debug", args, "%i", &l);    pop_n_elems(args);    push_int(a_flag);    a_flag = l;   }         #ifdef YYDEBUG   
pike.git/src/builtin_functions.c:4138: 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; -  CHECK_SECURITY_OR_ERROR(SECURITY_BIT_SECURITY, -  ("_compiler_trace: permission denied.\n")); +  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      #if defined(HAVE_LOCALTIME) || defined(HAVE_GMTIME)
pike.git/src/builtin_functions.c:5993:    *! 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;    -  CHECK_SECURITY_OR_ERROR(SECURITY_BIT_SECURITY, ("_next: permission denied.\n")); +  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(tmp.type)    {    case T_OBJECT: tmp.u.object=tmp.u.object->next; break;
pike.git/src/builtin_functions.c:6041:    *! @note    *! Unlike @[_next()] this function does not work on strings.    *!    *! @seealso    *! @[next_object()], @[_next()]    */   PMOD_EXPORT void f__prev(INT32 args)   {    struct svalue tmp;    -  CHECK_SECURITY_OR_ERROR(SECURITY_BIT_SECURITY, ("_prev: permission denied.\n")); +  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(tmp.type)    {    case T_OBJECT: tmp.u.object=tmp.u.object->prev; break;
pike.git/src/builtin_functions.c:6157:    *! usually a good idea to have your master inherit the original master and    *! only re-define certain functions.    *!    *! FIXME: Tell how to inherit the master.    *!    *! @seealso    *! @[master()]    */   PMOD_EXPORT void f_replace_master(INT32 args)   { -  CHECK_SECURITY_OR_ERROR(SECURITY_BIT_SECURITY, -  ("replace_master: permission denied.\n")); +  ASSERT_SECURITY_ROOT("replace_master");       if(!args)    SIMPLE_TOO_FEW_ARGS_ERROR("replace_master", 1);    if(Pike_sp[-args].type != T_OBJECT)    SIMPLE_BAD_ARG_ERROR("replace_master", 1, "object");    if(!Pike_sp[-args].u.object->prog)    bad_arg_error("replace_master", Pike_sp-args, args, 1, "object", Pike_sp-args,    "Called with destructed object.\n");       free_object(master_object);
pike.git/src/builtin_functions.c:6643: 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)   { -  CHECK_SECURITY_OR_ERROR(SECURITY_BIT_SECURITY, -  ("_reset_dmalloc: permission denied.\n")); +  ASSERT_SECURITY_ROOT("_reset_dmalloc");    pop_n_elems(args);    reset_debug_malloc();   }      /*! @decl void dmalloc_set_name(string filename, int linenumber)    *! @belongs Debug    *!    *! @note    *! Only available when compiled with dmalloc.    */
pike.git/src/builtin_functions.c:6702: 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)   { -  CHECK_SECURITY_OR_ERROR(SECURITY_BIT_SECURITY, -  ("_locate_references: permission denied.\n")); +  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; -  -  CHECK_SECURITY_OR_ERROR(SECURITY_BIT_SECURITY, -  ("_describe: permission denied.\n")); +  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)   { -  CHECK_SECURITY_OR_ERROR(SECURITY_BIT_SECURITY, -  ("_gc_set_watch: permission denied.\n")); +  ASSERT_SECURITY_ROOT("_gc_set_watch"); +     if (args < 1)    SIMPLE_TOO_FEW_ARGS_ERROR("_gc_set_watch", 1);    if (Pike_sp[-args].type > MAX_REF_TYPE)    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:6768: 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)   { -  CHECK_SECURITY_OR_ERROR(SECURITY_BIT_SECURITY, -  ("_dump_backlog: permission denied.\n")); +  ASSERT_SECURITY_ROOT("_dump_backlog");    pop_n_elems(args);    dump_backlog();   }      #endif      /*! @decl array map_array(array arr, function fun, mixed ... args)    *! @decl array map_array(array(object) arr, string fun, mixed ... args)    *! @decl array map_array(array(function) arr, int(-1..-1) minus_one, @    *! mixed ... args)