pike.git / src / modules / _Stdio / stat.c

version» Context lines:

pike.git/src/modules/_Stdio/stat.c:8:   #include "fdlib.h"   #include "interpret.h"   #include "svalue.h"   #include "bignum.h"   #include "mapping.h"   #include "object.h"   #include "builtin_functions.h"   #include "operators.h"   #include "program_id.h"   #include "file_machine.h" + #include "pike_types.h"      #include <sys/stat.h>   #ifdef HAVE_SYS_PARAM_H   #include <sys/param.h>   #endif /* HAVE_SYS_PARAM_H */      #define sp Pike_sp   #define fp Pike_fp      /*! @module Stdio
pike.git/src/modules/_Stdio/stat.c:783:       stack_swap();    pop_stack();   }      static void stat_indices(INT32 args);   static void stat_values(INT32 args);      static void stat_cast(INT32 args)   { -  if (!args) -  SIMPLE_TOO_FEW_ARGS_ERROR("Stat cast",1); -  if (TYPEOF(sp[-args]) == T_STRING && !sp[-args].u.string->size_shift) +  struct pike_string *type = Pike_sp[-args].u.string; +  pop_stack(); /* type have at least one more reference. */ +  +  if (type == literal_array_string)    { -  /* NB: We only look at the prefix, and let the main cast function -  * handle any subtypes. -  */ -  if (!strncmp(sp[-args].u.string->str, "array", 5)) -  { -  pop_n_elems(args); +     push_int(0);    push_int(6);    stat_index(2); -  return; +     } -  if (!strncmp(sp[-args].u.string->str, "mapping", 7)) +  else if (type == literal_mapping_string)    {    stat_indices(0);    stat_values(0);    push_mapping(mkmapping(Pike_sp[-2].u.array, Pike_sp[-1].u.array));    stack_pop_n_elems_keep_top(2); -  return; +     } -  +  else +  push_undefined();   } -  SIMPLE_BAD_ARG_ERROR("Stat cast",1, -  "string(\"array\"|\"mapping\")"); - } +       static void stat__sprintf(INT32 args)   {    int x;       if (args<1)    SIMPLE_TOO_FEW_ARGS_ERROR("_sprintf",2);       if (TYPEOF(sp[-args]) != T_INT)    SIMPLE_BAD_ARG_ERROR("_sprintf",0,"integer");
pike.git/src/modules/_Stdio/stat.c:947:   }         /*! @endclass    */   /*! @endmodule    */      /* ---------------------------------------------------------------- */    - void init_stdio_stat() + void init_stdio_stat(void)   {    unsigned int n=0;       static const struct {    const char *name;    const INT_TYPE id;    } __indices[] = {    {"dev",STAT_DEV},    {"ino",STAT_INO},    {"mode",STAT_MODE},
pike.git/src/modules/_Stdio/stat.c:1029:    tOr(tFunc(tOr(tStr,tInt06),tOr3(tStr,tInt,tFunction)),    tFunc(tInt tInt,tArr(tInt))),0);       ADD_FUNCTION ("`[]=", stat_index_set,    tOr(tFunc(tInt06 tSetvar(0,tInt),tVar(0)),    tFunc(tString tSetvar(1,tOr(tInt,tString)),tVar(1))), 0);    ADD_FUNCTION ("`->=", stat_index_set,    tOr(tFunc(tInt06 tSetvar(0,tInt),tVar(0)),    tFunc(tString tSetvar(1,tOr(tInt,tString)),tVar(1))), 0);    -  ADD_FUNCTION("cast",stat_cast,tFunc(tStr,tArray),0); +  ADD_FUNCTION("cast",stat_cast,tFunc(tStr,tArray),ID_PRIVATE);    ADD_FUNCTION("_sprintf",stat__sprintf,    tFunc(tInt tOr(tVoid,tMapping),tString),0);    ADD_FUNCTION("_indices",stat_indices,    tFunc(tNone,tArr(tOr(tString,tInt))),0);    ADD_FUNCTION("_values",stat_values,    tFunc(tNone,tArr(tOr(tString,tInt))),0);       set_init_callback (stat_init);       stat_program=end_program();    add_program_constant("Stat",stat_program,0);   }    - void exit_stdio_stat() + void exit_stdio_stat(void)   {    size_t i;       free_program(stat_program);    free_mapping(stat_map);       for (i = 1; i < STAT_ENUM_END; i++)    free_string (stat_index_strs[i]);       free_string (str_type_reg);    free_string (str_type_dir);    free_string (str_type_lnk);    free_string (str_type_chr);    free_string (str_type_blk);    free_string (str_type_fifo);    free_string (str_type_sock);    free_string (str_type_unknown);   }