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.552 2004/05/13 00:06:31 nilsson Exp $ + || $Id: builtin_functions.c,v 1.553 2004/05/13 16:31:06 nilsson Exp $   */      #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.552 2004/05/13 00:06:31 nilsson Exp $"); + RCSID("$Id: builtin_functions.c,v 1.553 2004/05/13 16:31:06 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:2177:    *! 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)   { +  int code;    ASSERT_SECURITY_ROOT("_exit");    -  if(args < 1) -  SIMPLE_TOO_FEW_ARGS_ERROR("_exit", 1); +  get_all_args("_exit", args, "%i", &code);    -  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 */    exit_opcodes();    }   #endif    -  exit(Pike_sp[-args].u.integer); +  exit(code);   }      /*! @decl int time();    *! @decl int time(int(1..1) one)    *! @decl float time(int(2..) t)    *!    *! This function returns the number of seconds since 00:00:00 UTC, 1 Jan 1970.    *!    *! The second syntax does not query the system for the current    *! time. Instead the latest done by the pike process is returned
pike.git/src/builtin_functions.c:2250:    *!    *! This function crypts and verifies a short string (only the first    *! 8 characters are significant).    *!    *! The first syntax crypts the string @[password] into something that    *! is hopefully hard to decrypt.    *!    *! The second syntax is used to verify @[typed_password] against    *! @[crypted_password], and returns @expr{1@} if they match, and    *! @expr{0@} (zero) otherwise. +  *! +  *! @note +  *! Note that strings containing null characters will only be +  *! processed up until the null character.    */   PMOD_EXPORT void f_crypt(INT32 args)   {    char salt[2]; -  char *ret, *saltp; +  char *ret, *pwd, *saltp;    char *choise =    "cbhisjKlm4k65p7qrJfLMNQOPxwzyAaBDFgnoWXYCZ0123tvdHueEGISRTUV89./";    -  if(args < 1) -  SIMPLE_TOO_FEW_ARGS_ERROR("crypt", 1); +  get_all_args("crypt", args, "%s.%s", &pwd, &saltp);    -  if(Pike_sp[-args].type != T_STRING) -  SIMPLE_BAD_ARG_ERROR("crypt", 1, "string"); -  -  +     if(args>1)    { -  if(Pike_sp[1-args].type != T_STRING || -  Pike_sp[1-args].u.string->len < 2) +  if( Pike_sp[1-args].u.string->len < 2 )    {    pop_n_elems(args);    push_int(0);    return;    } -  -  saltp=Pike_sp[1-args].u.string->str; +     } else {    unsigned int foo; /* Sun CC want's this :( */    foo=my_rand();    salt[0] = choise[foo % (size_t) strlen(choise)];    foo=my_rand();    salt[1] = choise[foo % (size_t) strlen(choise)];    saltp=salt;    }   #ifdef HAVE_CRYPT -  ret = (char *)crypt(Pike_sp[-args].u.string->str, saltp); +  ret = (char *)crypt(pwd, saltp);   #else   #ifdef HAVE__CRYPT -  ret = (char *)_crypt(Pike_sp[-args].u.string->str, saltp); +  ret = (char *)_crypt(pwd, saltp);   #else -  ret = Pike_sp[-args].u.string->str; +  ret = pwd;   #endif   #endif    if(args < 2)    {    pop_n_elems(args);    push_text(ret);    }else{    int i; -  i=!strcmp(ret,Pike_sp[1-args].u.string->str); +  i=!strcmp(ret,saltp);    pop_n_elems(args);    push_int(i);    }   }      /*! @decl void destruct(void|object o)    *!    *! Mark an object as destructed.    *!    *! Calls @expr{o->destroy()@}, and then clears all variables in the
pike.git/src/builtin_functions.c:2355:    debug_malloc_touch(o);    destruct(o);    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].    *! -  *! For strings and arrays this is simply an array of ascending numbers. +  *! For strings and arrays this is simply an array of ascending +  *! numbers.    *!    *! For mappings and multisets, the array may contain any value.    *! -  *! For objects which define @[lfun::_indices()] that return value will be used. +  *! For objects which define @[lfun::_indices()] that return value +  *! will be used.    *! -  *! For other objects an array with all non-static symbols will be returned. +  *! For other objects an array with all non-static symbols will be +  *! returned.    *!    *! @seealso    *! @[values()]    */   PMOD_EXPORT void f_indices(INT32 args)   {    ptrdiff_t size;    struct array *a = NULL;       if(args < 1)
pike.git/src/builtin_functions.c:2645:    free_type(types[1]);    }    if (types[0]) {    free_type(types[0]);    }    return NULL;   }      /*! @decl array values(string|array|mapping|multiset|object x)    *! -  *! Return an array of all possible values from indexing the value @[x]. +  *! Return an array of all possible values from indexing the value +  *! @[x].    *! -  *! For strings an array of int with the ISO10646 codes of the characters in -  *! the string is returned. +  *! For strings an array of int with the ISO10646 codes of the +  *! characters in the string is returned.    *! -  *! For a multiset an array filled with ones (@expr{1@}) is returned. +  *! For a multiset an array filled with ones (@expr{1@}) is +  *! returned.    *!    *! For arrays a single-level copy of @[x] is returned.    *!    *! For mappings the array may contain any value.    *! -  *! For objects which define @[lfun::_values()] that return value will be used. +  *! For objects which define @[lfun::_values()] that return value +  *! will be used.    *! -  *! For other objects an array with the values of all non-static symbols -  *! will be returned. +  *! For other objects an array with the values of all non-static +  *! symbols will be returned.    *!    *! @seealso    *! @[indices()]    */   PMOD_EXPORT void f_values(INT32 args)   {    ptrdiff_t size;    struct array *a = NULL;    if(args < 1)    SIMPLE_TOO_FEW_ARGS_ERROR("values", 1);