示例#1
0
/*! @decl void create(void|int version, void|int stacksize)
 *!
 *! Creates an instance of the Context class.
 *!
 *! @param version
 *!  This context will be initially made compatible with the specified
 *!  JavaScript version. The following constants are accepted as the value
 *!  of this parameter:
 *!
 *!   @dl
 *!    @item JSVERSION_1_0
 *!     JavaScript v1.0
 *!    @item JSVERSION_1_1
 *!     JavaScript v1.1
 *!    @item JSVERSION_1_2
 *!     JavaScript v1.2
 *!    @item JSVERSION_1_3
 *!     JavaScript v1.3 (ECMA)
 *!    @item JSVERSION_1_4
 *!     JavaScript v1.4 (ECMA)
 *!    @item JSVERSION_1_5
 *!     JavaScript v1.5 (ECMA)
 *!   @enddl
 *!
 *!  The default value is @b{JSVERSION_1_5@}
 *!
 *! @param stacksize
 *!  Sets the size of the private stack for this context. Value given in
 *!  bytes. Defaults to 8192.
 */
static void ctx_create(INT32 args)
{
  INT32      version = JSVERSION_1_5;
  INT32      stacksize = 8192;

  switch(args) {
      case 2:
        get_all_args("create", args, "%i%i", &version, &stacksize);
        break;

      case 1:
        get_all_args("create", args, "%i", &version);
        break;
  }

  THIS->ctx = JS_NewContext(smrt, stacksize);
  if (!THIS->ctx)
    Pike_error("Could not create a new context\n");
    
  if (!init_globals(THIS->ctx))
    Pike_error("Could not initialize the new context.\n");

  if (!JS_DefineFunctions(THIS->ctx, global, output_functions))
    Pike_error("Could not populate the global object with output functions\n");
    
  JS_SetVersion(THIS->ctx, version);

  /* create some privacy for us */
  if (!JS_SetPrivate(THIS->ctx, global, THIS))
    Pike_error("Could not set the private storage for the global object\n");
    
  pop_n_elems(args);
}
示例#2
0
void f_aap_add_filesystem( INT32 args )
{
    INT_TYPE nosyms = 0;
    struct pike_string *basedir, *mountpoint;
    struct array *noparse;

    if(args == 4)
        get_all_args( "add_filesystem", args,
                      "%s%s%a%i", &basedir, &mountpoint, &noparse, &nosyms );
    else
        get_all_args( "add_filesystem", args,
                      "%s%s%a", &basedir, &mountpoint, &noparse );
}
示例#3
0
文件: socket.c 项目: pikelang/Pike
/*! @decl int listen_fd(int fd, void|function accept_callback)
 *!
 *! This function does the same as @[bind], except that instead of
 *! creating a new socket and bind it to a port, it expects the file
 *! descriptor @[fd] to be an already open port.
 *!
 *! @note
 *!  This function is only for the advanced user, and is generally used
 *!  when sockets are passed to Pike at exec time.
 *!
 *! @seealso
 *!   @[bind], @[accept]
 */
static void port_listen_fd(INT32 args)
{
  struct port *p = THIS;
  struct svalue *cb = NULL;
  int fd;
  do_close(p);

  get_all_args(NULL, args, "%d.%*", &fd, &cb);

  if(fd<0)
  {
    errno = p->my_errno=EBADF;
    pop_n_elems(args);
    push_int(0);
    return;
  }

  if(fd_listen(fd, 16384) < 0)
  {
    p->my_errno=errno;
    pop_n_elems(args);
    push_int(0);
    return;
  }

  change_fd_for_box (&p->box, fd);
  if(cb) assign_accept_cb (p, cb);
  p->my_errno=0;
  pop_n_elems(args);
  push_int(1);
}
示例#4
0
文件: hrz.c 项目: pikelang/Pike
void image_hrz_f_encode(INT32 args )
{
  struct object *io;
  struct image *i;
  struct pike_string *s;
  int x,y;
  get_all_args( NULL, args, "%o", &io);

  if(!(i = get_storage( io, image_program)))
    Pike_error("Wrong argument 1 to Image.HRZ.encode\n");

  s = begin_shared_string( 256*240*3 );

  memset(s->str, 0, s->len );
  for(y=0; y<240; y++)
    if(y < i->ysize)
      for(x=0; x<256; x++)
        if(x < i->xsize)
        {
          int in = (x + y*256)*3;
          rgb_group pix = i->img[y*i->xsize+x];
          s->str[in+0] = pix.r >> 2;
          s->str[in+1] = pix.g >> 2;
          s->str[in+2] = pix.b >> 2;
        }
示例#5
0
文件: glue.c 项目: ajinkya007/pike-1
/*! @decl array(string) split(string s)
 *! Works as @[match], but returns an array of the strings that
 *! matched the subregexps. Subregexps are those contained in "( )" in
 *! the regexp. Subregexps that were not matched will contain zero.
 *! If the total regexp didn't match, zero is returned.
 *!
 *! @bugs
 *!   You can currently only have 39 subregexps.
 *!
 *! @bugs
 *!   The current implementation doesn't support searching
 *!   in strings containing the NUL character or any
 *!   wide character.
 *!
 *! @seealso
 *!   @[match]
 */
static void regexp_split(INT32 args)
{
  struct pike_string *s;
  struct regexp *r;

  get_all_args("Regexp.SimpleRegexp->split", args, "%S", &s);

  if(pike_regexec(r=THIS->regexp, s->str))
  {
    int i,j;
    add_ref(s);
    pop_n_elems(args);
    for(j=i=1;i<NSUBEXP;i++)
    {
      if(!r->startp[i] || !r->endp[i])
      {
	push_int(0);
      }else{
	push_string(make_shared_binary_string(r->startp[i],
					      r->endp[i]-r->startp[i]));
	j=i;
      }
    }
    if(j<i-1) pop_n_elems(i-j-1);
    push_array(aggregate_array(j));
    free_string(s);
  }else{
    pop_n_elems(args);
    push_int(0);
  }
}
示例#6
0
static void f_parse_headers( INT32 args )
{
  struct mapping *headermap;
  struct pike_string *headers;
  unsigned char *ptr;
  int len = 0, parsed = 0;
  get_all_args("Caudium.parse_headers", args, "%S", &headers);
  headermap = allocate_mapping(1);
  ptr = (unsigned char *)headers->str;
  len = headers->len;
  /*
   * FIXME:
   * What do we do if memory allocation fails halfway through
   * allocating a new mapping? Should we return that half-finished
   * mapping or rather return NULL? For now it's the former case.
   * /Grendel
   *
   * If memory allocation fails, just bail out with error()
   */
  while(len > 0 &&
        (parsed = get_next_header(ptr, len, headermap)) >= 0 ) {
    ptr += parsed;
    len -= parsed;
  }
  if(parsed == -1) {
    Pike_error("Caudium.parse_headers(): Out of memory while parsing.\n");
  }
  pop_n_elems(args);
  push_mapping(headermap);
}
示例#7
0
文件: ol_ldap.c 项目: hww3/pexts
/*
 **| method: string dn2ufn ( string dn );
 **|  Convert the given DN to an user friendly form thereof. This will
 **|  strip the type names from the passed dn. See RFC 1781 for more
 **|  details. 
 **
 **| arg: string dn
 **|  an UTF-8 string with the dn to convert.
 **
 **| returns: the user friendly form of the DN.
 */
static void
f_ldap_dn2ufn(INT32 args)
{
    struct pike_string   *dn = NULL;
    char                 *ufn;
    
    if (args != 1)
        Pike_error("OpenLDAP.Client->dn2ufn(): requires exactly one 8-bit string argument\n");

    get_all_args("OpenLDAP.Client->dn2ufn()", args, "%S", &dn);
    
    pop_n_elems(args);
    
    if (!dn) {
        push_int(0);
        return;
    }

    ufn = ldap_dn2ufn(dn->str);
    if (!ufn) {
        push_int(0);
    } else {
        push_string(make_shared_string(ufn));
        ldap_memfree(ufn);
    }
}
示例#8
0
文件: _xpm.c 项目: ajinkya007/pike-1
/*! @decl array(string) _xpm_trim_rows(array(string) rows)
 */
void f__xpm_trim_rows( INT32 args )
{
  struct array *a;
  int i,j=0;
  get_all_args("_xpm_trim_rows", args, "%a", &a );
  for(i=0; i<a->size; i++)
  {
    int len,start;
    struct pike_string *s = a->item[i].u.string;
    if(a->item[i].type != T_STRING)
      Pike_error("Array must be array(string).\n");
    if(s->len > 4)
    {
      for(start=0; start<s->len; start++)
        if(s->str[start] == '/' || s->str[start] == '"')
          break;
      if(s->str[start] == '/')
        continue;
      for(len=start+1; len<s->len; len++)
        if(s->str[len] == '"')
          break;
      if(len>=s->len || s->str[len] != '"')
        continue;
      free_string(a->item[j].u.string);
      a->item[j++].u.string=make_shared_binary_string(s->str+start+1,len-start-1);
    }
  }
  pop_n_elems(args-1);
}
示例#9
0
文件: gettext.c 项目: pikelang/Pike
/*! @decl string bindtextdomain(string|void domainname, string|void dirname)
 *!
 *! Binds the path predicate for a message @[domainname] domainname to
 *! the directory name specified by @[dirname].
 *!
 *! If @[domainname] is a non-empty string and has not been bound
 *! previously, bindtextdomain() binds @[domainname] with @[dirname].
 *!
 *! If @[domainname] is a non-empty string and has been bound previously,
 *! bindtextdomain() replaces the old binding with @[dirname].
 *!
 *! The @[dirname] argument can be an absolute or relative pathname
 *! being resolved when @[gettext()], @[dgettext()] or @[dcgettext()]
 *! are called.
 *!
 *! If @[domainname] is zero or an empty string, @[bindtextdomain()]
 *! returns 0.
 *!
 *! User defined domain names cannot begin with the string @expr{"SYS_"@}.
 *! Domain names beginning with this string are reserved for system use.
 *!
 *! @returns
 *!   The return value from @[bindtextdomain()] is a string containing
 *!   @[dirname] or the directory binding associated with @[domainname] if
 *!   @[dirname] is unspecified. If no binding is found, the default locale
 *!   path is returned. If @[domainname] is unspecified or is an empty string,
 *!   @[bindtextdomain()] takes no action and returns a 0.
 *!
 *! @seealso
 *!   @[textdomain], @[gettext], @[setlocale], @[localeconv]
 */
void f_bindtextdomain(INT32 args)
{
  char *returnstring;
  const char *domain = NULL, *dirname = NULL;
  get_all_args (NULL, args, ".%C%C", &domain, &dirname);

  if (!domain || !*domain)
    returnstring = NULL;
  else {
#ifdef BINDTEXTDOMAIN_HANDLES_NULL
    returnstring = bindtextdomain (domain, dirname);
#else
    if (dirname)
      returnstring = bindtextdomain (domain, dirname);
    else
      /* Awkward, but not much we can do. Still better than a
       * coredump.. */
      Pike_error ("Pike has been compiled with a version of libintl "
		  "that doesn't support NULL as directory name.\n");
#endif
  }

  pop_n_elems(args);
  if(returnstring == NULL)
    push_int(0);
  else
    push_text(returnstring);
}
示例#10
0
/*! @decl void `+=(int step)
 *! Move @tt{step@} steps forward in the path.
 */
static void f_path_iterator_add_self(INT32 args)
{
  int i;
  get_all_args("`+=", args, "%d", &i);
  THIS->idx += i;
  pop_n_elems(args);
  ref_push_object(Pike_fp->current_object);
}
示例#11
0
文件: gettext.c 项目: pikelang/Pike
/*! @decl string textdomain(void|string domain)
 *!
 *! The textdomain() function sets or queries the name of the
 *! current domain of the active @[LC_MESSAGES] locale category. The
 *! @[domain] argument is a string that can contain only the
 *! characters allowed in legal filenames.
 *!
 *! The domain argument is the unique name of a domain on the
 *! system. If there are multiple versions of the same domain on
 *! one system, namespace collisions can be avoided by using
 *! @[bindtextdomain()]. If textdomain() is not called, a default
 *! domain is selected. The setting of domain made by the last
 *! valid call to textdomain() remains valid across subsequent
 *! calls to @[setlocale()], and @[gettext()].
 *!
 *! @returns
 *!   The normal return value from textdomain() is a string
 *!   containing the current setting of the domain. If domainname is
 *!   void, textdomain() returns a string containing the current
 *!   domain. If textdomain() was not previously called and
 *!   domainname is void, the name of the default domain is
 *!   returned.
 *!
 *! @seealso
 *!   @[bindtextdomain], @[gettext], @[setlocale], @[localeconv]
 */
void f_textdomain(INT32 args)
{
  const char *domain = NULL;
  char *returnstring;
  get_all_args (NULL, args, ".%C", &domain);
  returnstring = textdomain(domain);
  pop_n_elems(args);
  push_text(returnstring);
}
示例#12
0
文件: ol_ldap.c 项目: hww3/pexts
/*
 * Takes an array of mappings, similar to modify above, with the
 * exception that the 'op' field is ignored and not used at all.
 */
static void
f_ldap_add(INT32 args)
{
    struct pike_string     *dn;
    struct array           *arr;
    struct mapping         *m;
    struct svalue          *val;
    LDAPMod               **mods;
    int                     i, ret;

    if (!THIS->bound)
        Pike_error("OpenLDAP.Client: attempting operation on an unbound connection\n");
    
    get_all_args("OpenLDAP.Client->add()", args, "%S%a", &dn, &arr);
    mods = (LDAPMod**)calloc((arr->size + 1), sizeof(LDAPMod*));
    if (!mods)
        Pike_error("OpenLDAP.Client: OUT OF MEMORY!\n");

    for (i = 0; i < arr->size; i++) {
        mods[i] = (LDAPMod*)calloc(1, sizeof(LDAPMod));
        if (!mods[i])
            Pike_error("OpenLDAP.Client: OUT OF MEMORY!\n");
        mods[i]->mod_op = LDAP_MOD_BVALUES;

        if (arr->item[i].type != T_MAPPING)
            Pike_error("OpenLDAP.Client->add(): array member is not a mapping.\n");
        m = arr->item[i].u.mapping;
        
        val = low_mapping_string_lookup(m, modify_type);
        if (!val)
            Pike_error("OpenLDAP.Client->add(): invalid modification mapping. "
                       "Missing the '%s' field\n", "type");
        if (val->type != T_STRING || val->u.string->size_shift > 0)
            Pike_error("OpenLDAP.Client->add(): invalid modification mapping. "
                       "The '%s' field is not an 8-bit string\n", "type");
        mods[i]->mod_type = val->u.string->str;

        val = low_mapping_string_lookup(m, modify_values);
        if (!val)
            Pike_error("OpenLDAP.Client->add(): invalid modification mapping. "
                       "Missing the '%s' field\n", "values");
        if (val->type != T_ARRAY)
            Pike_error("OpenLDAP.Client->add(): invalid modification mapping. "
                       "The '%s' field is not an array\n", "values");
        
        mods[i]->mod_bvalues = make_berval_array(val);
    }
    
    ret = ldap_add_s(THIS->conn, dn->str, mods);
    if (ret != LDAP_SUCCESS)
        Pike_error("OpenLDAP.Client->add(): %s\n",
                   ldap_err2string(ret));
    
    free_mods(mods);
    
    pop_n_elems(args);
}
示例#13
0
文件: gettext.c 项目: pikelang/Pike
/*! @decl string dgettext(string domain, string msg)
 *!
 *! Return a translated version of @[msg] within the context
 *! of the specified @[domain] and current locale. If there is
 *! no translation available, @[msg] is returned.
 *!
 *! @note
 *!   Obsoleted by @[gettext()] in Pike 7.3.
 *!
 *! @seealso
 *!   @[bindtextdomain], @[textdomain], @[gettext], @[setlocale], @[localeconv]
*/
void f_dgettext(INT32 args)
{
  const char *domain, *msg;
  get_all_args(NULL, args, "%c%c", &domain, &msg);

  push_text(dgettext(domain, msg));

  stack_pop_n_elems_keep_top(args);
}
示例#14
0
文件: xbm.c 项目: ajinkya007/pike-1
/*
**! method object decode(string data)
**! 	Decodes a XBM image. 
**!
**! note
**!	Throws upon error in data.
*/
static void image_xbm_decode( INT32 args )
{
  struct pike_string *data;
  struct object *o;
  get_all_args( "Image.XBM.decode", args, "%S", &data );
  o = load_xbm( data );
  pop_n_elems(args);
  push_object( o );
}
示例#15
0
static void ctx_compile(INT32 args)
{
  JSScript           *compiled;
  struct pike_string *script;
  jsval               rval;
  INT32               version = -1, oldversion = -1;

  if (!THIS->ctx) {
    pop_n_elems(args);
    push_int(0);
    return;
  }
    
  switch(args) {
      case 2:
        get_all_args("compile", args, "%S%i", &script, &version);
        break;

      case 1:
        get_all_args("compile", args, "%S", &script);
        break;

      default:
        Pike_error("Not enough arguments\n");
  }

  if (version != -1)
    oldversion = JS_SetVersion(THIS->ctx, version);
    
  /* TODO: filename should indicate the actual location of the script */
  compiled = JS_CompileScript(THIS->ctx, global,
                               script->str, script->len,
                              "Caudium/js", &rval);

  if (oldversion != -1)
    JS_SetVersion(THIS->ctx, oldversion);
    
  pop_n_elems(args);
    
  if (!compiled) {
    push_int(-1);
    return;
  }
}
示例#16
0
文件: ol_ldap.c 项目: hww3/pexts
/*
 **| method: void set_scope ( int scope );
 **|  Set the operation scope for this connection.
 **
 **| arg: int scope
 **|  One of the following scopes: OpenLDAP.LDAP_SCOPE_BASE (search
 **|  the selected object itself only), OpenLDAP.LDAP_SCOPE_ONELEVEL
 **|  (search the object's immediate children),
 **|  OpenLDAP.LDAP_SCOPE_SUBTREE (search object and all its
 **|  descendants). The 'object' here is the base DN you set with the
 **|  set_base_dn function.
 */ 
static void
f_set_scope(INT32 args)
{
    int    scope;

    get_all_args("OpenLDAP.Client->set_scope()", args, "%i", &scope);
    pop_n_elems(args);

    THIS->scope = scope;
}
示例#17
0
文件: ilbm.c 项目: ajinkya007/pike-1
static void image_ilbm___decode(INT32 args)
{
   unsigned char *s;
   ptrdiff_t len;
   struct pike_string *str;
   struct mapping *m;
   int n;
   extern void parse_iff(char *, unsigned char *, ptrdiff_t,
			 struct mapping *, char *);

   get_all_args("__decode", args, "%S", &str);

   s = (unsigned char *)str->str;
   len = str->len;
   pop_n_elems(args-1);

   for(n=0; n<5; n++)
     push_int(0);
   push_mapping(m = allocate_mapping(4));

   parse_iff("ILBM", s, len, m, "BODY");

   mapping_index_no_free(sp-5, m, &string_[string_BMHD]);
   mapping_index_no_free(sp-4, m, &string_[string_CMAP]);
   mapping_index_no_free(sp-3, m, &string_[string_CAMG]);
   mapping_index_no_free(sp-2, m, &string_[string_BODY]);

   map_delete(m, &string_[string_BMHD]);
   map_delete(m, &string_[string_CMAP]);
   map_delete(m, &string_[string_CAMG]);
   map_delete(m, &string_[string_BODY]);

   if(sp[-5].type != T_STRING)
     Pike_error("Missing BMHD chunk\n");
   if(sp[-2].type != T_STRING)
     Pike_error("Missing BODY chunk\n");

   /* Extract image size from BMHD */
   s = (unsigned char *)STR0(sp[-5].u.string);
   len = sp[-5].u.string->len;

   if(len<20)
     Pike_error("Short BMHD chunk\n");

   free_svalue(sp-7);

   sp[-7].u.integer = (s[0]<<8)|s[1];
   sp[-7].type = T_INT;
   sp[-7].subtype = NUMBER_NUMBER;
   sp[-6].u.integer = (s[2]<<8)|s[3];
   sp[-6].type = T_INT;
   sp[-6].subtype = NUMBER_NUMBER;

   f_aggregate(7);
}
示例#18
0
文件: glue.c 项目: ajinkya007/pike-1
/*! @decl void create(string re)
 *!
 *! When create is called, the current regexp bound to this object is
 *! cleared. If a string is sent to create(), this string will be compiled
 *! to an internal representation of the regexp and bound to this object
 *! for laters calls to e.g. @[match] or @[split]. Calling create() without
 *! an argument can be used to free up a little memory after the regexp has
 *! been used.
 */
static void regexp_create(INT32 args)
{
  const char *str;

  do_free();
  if(args)
  {
    get_all_args("Regexp.SimpleRegexp->create", args, "%s", &str);
    THIS->regexp=pike_regcomp(Pike_sp[-args].u.string->str, 0);
  }
}
示例#19
0
文件: gettext.c 项目: pikelang/Pike
/*! @decl string dcgettext(string domain, string msg, int category)
 *!
 *! Return a translated version of @[msg] within the context of the
 *! specified @[domain] and current locale for the specified
 *! @[category]. Calling dcgettext with category @[Locale.Gettext.LC_MESSAGES]
 *! gives the same result as dgettext.
 *!
 *! If there is no translation available, @[msg] is returned.
 *!
 *! @note
 *!   Obsoleted by @[gettext()] in Pike 7.3.
 *!
 *! @seealso
 *!   @[bindtextdomain], @[textdomain], @[gettext], @[setlocale], @[localeconv]
 */
void f_dcgettext(INT32 args)
{
  const char *domain, *msg;
  int category;

  get_all_args(NULL, args, "%c%c%d", &domain, &msg, &category);

  push_text(dcgettext(domain, msg, category));

  stack_pop_n_elems_keep_top(args);
}
示例#20
0
void f_reset_flag(INT32 args) {
	int idx;
	HEADER *header=0;
	int flag;
	
	get_all_args("reset_flag",args,"%i%i",&idx,&flag);
	
	header=THIS->ctx->hdrs[idx];
	mutt_set_flag(THIS->ctx, header, flag,0);
	pop_n_elems(args);
}
示例#21
0
文件: pike.c 项目: ajinkya007/pike-1
/*! @decl array(array(string)|string) tokenize(string code)
 *!
 *!   Tokenize a string of Pike tokens.
 *!
 *! @returns
 *!   Returns an array with Pike-level tokens and the remainder (a
 *!   partial token), if any.
 */
static void f_tokenize( INT32 args )
{
  struct array *res;
  struct pike_string *left_s = NULL; /* Make gcc happy. */
  struct pike_string *data;
  int left;
  ONERROR tmp;

  get_all_args("tokenize", args, "%W", &data);

  if(!data->len)
  {
    pop_n_elems(args);
    push_empty_array();
    push_empty_string();
    f_aggregate(2);
    return;
  }

  res = allocate_array_no_init( 0, 128 );
  SET_ONERROR(tmp, do_free_arrayptr, &res);
  
  switch(data->size_shift)
  {
    case 0:
      left = tokenize0(&res, STR0(data), data->len);
      left_s = make_shared_binary_string0(STR0(data)+left, data->len-left);
      break;
    case 1:
      left = tokenize1(&res, STR1(data), data->len);
      left_s = make_shared_binary_string1(STR1(data)+left, data->len-left);
      break;
    case 2:
      left = tokenize2(&res,STR2(data), data->len);
      left_s = make_shared_binary_string2(STR2(data)+left, data->len-left);
      break;
#ifdef PIKE_DEBUG
    default:
      Pike_error("Unknown shift size %d.\n", data->size_shift);
#endif
  }

  UNSET_ONERROR(tmp);
  pop_n_elems(args);
  if (!res->size) {
    free_array(res);
    push_empty_array();
  }
  else
    push_array(res);
  push_string( left_s );
  f_aggregate( 2 );
}
示例#22
0
文件: ol_ldap.c 项目: hww3/pexts
/*
 **| method: void set_cache_options ( int opts );
 **|  Set the cache options. The manual page defines two options:
 **|  LDAP_CACHE_OPT_CACHENOERRS and LDAP_CACHE_OPT_CACHEALLERRS, but
 **|  those constants are not defined in the ldap include file,
 **|  therefore they are not currently present in the OpenLDAP module.
 **
 **| arg: int opts
 **|  options to set on the cache.
 */
static void
f_ldap_set_cache_options(INT32 args)
{
    int   opts = 0; /* LDAP_CACHE_OPT_CACHENOERRS; */

    if (!THIS->bound)
        Pike_error("OpenLDAP.Client: attempting operation on an unbound connection\n");
    
    get_all_args("OpenLDAP.Client->set_cache_options", args, "%i", &opts);

    pop_n_elems(args);
    ldap_set_cache_options(THIS->conn, opts);
}
示例#23
0
文件: yp.c 项目: pikelang/Pike
/*! @decl string server(string map)
 *!
 *! Returns the hostname of the server serving the map @[map]. @[map]
 *! is the YP-map to search in. This must be the full map name.
 *! eg @tt{passwd.byname@} instead of just @tt{passwd@}.
 */
static void f_server(INT32 args)
{
  int err;
  char *ret, *map;

  get_all_args(NULL, args, "%s", &map);
  err = yp_master(this->domain, map, &ret);

  YPERROR( err );

  pop_n_elems( args );
  push_text( ret );
}
示例#24
0
文件: search.c 项目: hww3/pexts
/* void get_result(int result) */
static void f_get_result(INT32 args)
{
  int n, result;
  GET_PIKE_SEARCH();
  get_all_args("Search->get_result()", args, "%i", &result);

  THREADS_ALLOW();
  n = avs_getsearchresults(search->handle, result);
  THREADS_DISALLOW();
  if (n != AVS_OK)
    Pike_error("Search->get_result(): %s\n", avs_errmsg(n));

  pop_n_elems(args);
}
示例#25
0
文件: gettext.c 项目: pikelang/Pike
/*! @decl int setlocale(int category, string locale)
 *!
 *! The setlocale() function is used to set the program's
 *! current locale. If @[locale] is "C" or "POSIX", the current
 *! locale is set to the portable locale.
 *!
 *! If @[locale] is "", the locale is set to the default locale which
 *! is selected from the environment variable LANG.
 *!
 *! The argument @[category] determines which functions are
 *! influenced by the new locale are @[LC_ALL], @[LC_COLLATE], @[LC_CTYPE],
 *! @[LC_MONETARY], @[LC_NUMERIC] and @[LC_TIME].
 *!
 *! @returns
 *!   Returns 1 if the locale setting successed, 0 for failure
 *!
 *! @seealso
 *!   @[bindtextdomain], @[textdomain], @[gettext], @[dgettext], @[dcgettext], @[localeconv]
 */
void f_setlocale(INT32 args)
{
  char *returnstring;
  const char *locale;
  int category;
  get_all_args(NULL, args, "%d%c", &category, &locale);

  returnstring = setlocale(category, locale);
  pop_n_elems(args);
  if(returnstring == NULL)
    push_int(0);
  else
    push_int(1);
}
示例#26
0
/*! @decl string _sprintf()
 */
static void f_path_element_sprintf(INT32 args)
{
  INT_TYPE mode;
  struct mapping *opts;
  cairo_path_data_t* data = THIS->element;

  get_all_args("_sprintf", args, "%i%m", &mode, &opts);
  pop_n_elems (args);
  if (mode == 'O')
    {
      switch (data->header.type)
        {
        case CAIRO_PATH_MOVE_TO:
          push_constant_text ("%O(CAIRO_PATH_MOVE_TO(%f,%f))");
          ref_push_object(Pike_fp->current_object);
          f_object_program (1);
          push_float(data[1].point.x); push_float(data[1].point.y);
          f_sprintf(4);
          break;
        case CAIRO_PATH_LINE_TO:
          push_constant_text ("%O(CAIRO_PATH_LINE_TO(%f,%f))");
          ref_push_object(Pike_fp->current_object);
          f_object_program (1);
          push_float(data[1].point.x); push_float(data[1].point.y);
          f_sprintf(4);
          break;
        case CAIRO_PATH_CURVE_TO:
          push_constant_text ("%O(CAIRO_PATH_CURVE_TO(%f,%f,%f,%f,%f))");
          ref_push_object(Pike_fp->current_object);
          f_object_program (1);
          push_float(data[1].point.x); push_float(data[1].point.y);
          push_float(data[2].point.x); push_float(data[2].point.y);
          push_float(data[3].point.x); push_float(data[3].point.y);
          f_sprintf(8);
          break;
        case CAIRO_PATH_CLOSE_PATH:
          push_constant_text ("%O(CAIRO_PATH_CLOSE_PATH()");
          ref_push_object(Pike_fp->current_object);
          f_object_program (1);
          f_sprintf(2);
          break;
        default:
          push_undefined();
          return;
        }
    }
  else
    push_undefined();
}
示例#27
0
文件: pvr.c 项目: ajinkya007/pike-1
void image_pvr_f_encode(INT32 args)
{
  struct object *imgo;
  struct mapping *optm = NULL;
  struct image *alpha = NULL, *img;
  INT32 gbix=0, sz, attr=0;
  int has_gbix=0, twiddle=0, compress = 0;
  struct pike_string *res;
  unsigned char *dst;
  struct gla_state *gla_st = NULL;

  get_all_args("Image.PVR.encode", args, (args>1 && !UNSAFE_IS_ZERO(&sp[1-args])?
					  "%o%m":"%o"), &imgo, &optm);

  if((img=(struct image*)get_storage(imgo, image_program))==NULL)
    Pike_error("Image.PVR.encode: illegal argument 1\n");

  if(optm != NULL) {
    struct svalue *s;
    if((s = simple_mapping_string_lookup(optm, "alpha"))!=NULL && !UNSAFE_IS_ZERO(s))
      if(s->type != T_OBJECT ||
	 (alpha=(struct image*)get_storage(s->u.object, image_program))==NULL)
	Pike_error("Image.PVR.encode: option (arg 2) \"alpha\" has illegal type\n");
    if((s = simple_mapping_string_lookup(optm, "global_index"))!=NULL &&
       !IS_UNDEFINED(s)) {
      if(s->type == T_INT) {
	gbix = s->u.integer;
	has_gbix=1;
      }
      else
	Pike_error("Image.PVR.encode: option (arg 2) \"global_index\" has illegal type\n");
    }
    if((s = simple_mapping_string_lookup(optm, "vq"))!=NULL &&
       !UNSAFE_IS_ZERO(s))
      compress = 1;
  }

  if (!img->img)
    Pike_error("Image.PVR.encode: no image\n");
  if (alpha && !alpha->img)
    Pike_error("Image.PVR.encode: no alpha image\n");

  if (alpha && (alpha->xsize != img->xsize || alpha->ysize != img->ysize))
    Pike_error("Image.PVR.encode: alpha and image size differ\n");

  if(compress)
    sz=8+256*4*2+(img->xsize>>1)*(img->ysize>>1);
  else
示例#28
0
文件: ol_ldap.c 项目: hww3/pexts
/*
 **| method: string err2string ( int lerrno );
 **|  Converts the specified error code into the corresponding
 **|  message.
 **
 **| arg: int lerrno
 **|  LDAP error code.
 */
static void
f_ldap_err2string(INT32 args)
{
    int    err;
    char  *str;
    
    if (args != 1)
        Pike_error("OpenLDAP.Client->err2string() requires a single integer argument\n");

    get_all_args("OpenLDAP.Client->err2string()", args, "%i", &err);

    pop_n_elems(args);
    
    str = ldap_err2string(err);
    push_string(make_shared_string(str));
}
示例#29
0
/*! @decl mapping(string:float) get_point(int point)
 */
static void f_path_element_get_point(INT32 args)
{
  int i;
  get_all_args("get_point", args, "%d", &i);
  i++; // index includes header
  if (i > 0 && i < THIS->element->header.length)
    {
      push_text( "x" );
      push_float(THIS->element[i].point.x);
      push_text( "y" );
      push_float(THIS->element[i].point.y);
      f_aggregate_mapping(4);
    }
  else
    push_undefined();
}
示例#30
0
void f_get_header(INT32 args) {
	int idx;
	HEADER *header=0;
	
	get_all_args("get_header",args,"%i",&idx);
	pop_n_elems(args);
	
	if( idx >= THIS->ctx->msgcount || idx < 0 ) {
		Pike_error("get_header: header index '%d' not present!\n",idx);
	}
		
	header=THIS->ctx->hdrs[idx];
	if( !header ) {
		Pike_error("get_header: header pointer is NULL for index '%d'\n",idx);
	}
	push_headers(header);
}