当前位置: 首页>>代码示例>>C++>>正文


C++ Pike_error函数代码示例

本文整理汇总了C++中Pike_error函数的典型用法代码示例。如果您正苦于以下问题:C++ Pike_error函数的具体用法?C++ Pike_error怎么用?C++ Pike_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Pike_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: f_decode_base64

/*! @decl string decode_base64(string encoded_data)
 *!
 *! This function decodes data encoded using the @tt{[email protected]}
 *! transfer encoding.
 *!
 *! @seealso
 *! @[MIME.encode_base64()], @[MIME.decode()]
 */
static void f_decode_base64( INT32 args )
{
  if(args != 1)
    Pike_error( "Wrong number of arguments to MIME.decode_base64()\n" );
  else if (sp[-1].type != T_STRING)
    Pike_error( "Wrong type of argument to MIME.decode_base64()\n" );
  else if (sp[-1].u.string->size_shift != 0)
    Pike_error( "Char out of range for MIME.decode_base64()\n" );
  else {

    /* Decode the string in sp[-1].u.string.  Any whitespace etc
       must be ignored, so the size of the result can't be exactly
       calculated from the input size.  We'll use a string builder
       instead. */

    struct string_builder buf;
    SIGNED char *src;
    ptrdiff_t cnt;
    INT32 d = 1;
    int pads = 0;

    init_string_builder( &buf, 0 );

    for (src = (SIGNED char *)sp[-1].u.string->str, cnt = sp[-1].u.string->len;
	 cnt--; src++)
      if(*src>=' ' && base64rtab[*src-' ']>=0) {
	/* 6 more bits to put into d */
	if((d=(d<<6)|base64rtab[*src-' '])>=0x1000000) {
	  /* d now contains 24 valid bits.  Put them in the buffer */
	  string_builder_putchar( &buf, (d>>16)&0xff );
	  string_builder_putchar( &buf, (d>>8)&0xff );
	  string_builder_putchar( &buf, d&0xff );
	  d=1;
	}
      } else if (*src=='=') {
开发者ID:ajinkya007,项目名称:pike-1,代码行数:43,代码来源:mime.c

示例2: pipe_read_input_callback

static void pipe_read_input_callback(INT32 args)
{
  struct input *i;
  struct pike_string *s;

  if (args<2 || sp[1-args].type!=T_STRING)
    Pike_error("Illegal argument to pipe->read_input_callback\n");
   
  i=THIS->firstinput;

  if (!i)
    Pike_error("Pipe read callback without any inputs left.\n");

  s=sp[1-args].u.string;

  if(append_buffer(s))
  {
    /* THIS DOES NOT WORK */
    push_int(0);
    push_int(0);
    push_callback(offset_input_close_callback);
    apply_low(i->u.obj,i->set_nonblocking_offset,3);
    pop_stack();
    THIS->sleeping=1;
  }

  low_start();
  pop_n_elems(args-1);
}
开发者ID:ajinkya007,项目名称:pike-1,代码行数:29,代码来源:pipe.c

示例3: pipe_close_input_callback

static void pipe_close_input_callback(INT32 args)
{
   struct input *i;
   i=THIS->firstinput;

   if(!i)
     Pike_error("Input close callback without inputs!\n");

   if(i->type != I_OBJ)
     Pike_error("Premature close callback on pipe!.\n");

   if (i->u.obj->prog)
   {
#ifdef BLOCKING_CLOSE
      apply_low(i->u.obj,i->set_blocking_offset,0);
      pop_stack();
#endif
      apply(i->u.obj,"close",0);
      pop_stack();
   }
   nobjects--;
   free_object(i->u.obj);
   i->type=I_NONE;

   input_finish();
   if(args)
     pop_n_elems(args-1);
}
开发者ID:ajinkya007,项目名称:pike-1,代码行数:28,代码来源:pipe.c

示例4: f_parse_html

static void f_parse_html(INT32 args)
{
  xmlDocPtr   doc = NULL;
  char * encoding = "utf-8";
  struct pike_string *encode_data = NULL;
  
  if ( args == 1 ) {
      if ( ARG(1).type != T_STRING ) 
	  Pike_error("Incorrect type for argument 0: expected string (encoding)\n");
      encode_data = ARG(1).u.string;
      encoding = encode_data->str;
  }
  // do nothing
  if ( THIS->input_data->len == 0 )
    push_int(0);

  switch (THIS->parsing_method) {
      case PARSE_PUSH_PARSER:
        Pike_error("Push parser not implemented yet. Please bug [email protected] to implement it.");
        
      case PARSE_MEMORY_PARSER:
        htmlHandleOmittedElem(1);
	doc=htmlSAXParseDoc(THIS->input_data->str, encoding, THIS->sax, NULL);
        break;

      case PARSE_FILE_PARSER:
        htmlHandleOmittedElem(1);
	doc=htmlSAXParseFile(THIS->input_data->str, "utf-8", THIS->sax, NULL);
	break;
  }
  if ( doc != NULL )
    xmlFreeDoc(doc);
  
  push_int(0);
}
开发者ID:ajinkya007,项目名称:societyserver,代码行数:35,代码来源:xml_sax.c

示例5: f_hash_create

/*
**! file: Mhash/mhash.c
**!  File implementing the Mhash.Hash() class.
**! cvs_version: $Id$
**! class: Mhash.Hash
**!  An instance of a normal Mhash object. This object can be used to
**!  calculate various hashes supported by the Mhash library.
**! see_also: Mhash.HMAC
**! method: void create(int|void type)
**!  Called when instantiating a new object. It takes an optional first
**!  argument with the type of hash to use.
**! arg: int|void type
**!  The hash type to use. Can also be set with set_type();
**! name: create - Create a new hash instance.
*/
void f_hash_create(INT32 args)
{
  if(THIS->type != -1 || THIS->hash || THIS->res) {
    Pike_error("Recursive call to create. Use Mhash.Hash()->reset() or \n"
	  "Mhash.Hash()->set_type() to change the hash type or reset\n"
	  "the object.\n");
  }
  switch(args) {
  default:
    Pike_error("Invalid number of arguments to Mhash.Hash(), expected 0 or 1.\n");
    break;
  case 1:
    if(Pike_sp[-args].type != T_INT) {
      Pike_error("Invalid argument 1. Expected integer.\n");
    }
    THIS->type = Pike_sp[-args].u.integer;
    THIS->hash = mhash_init(THIS->type);
    if(THIS->hash == MHASH_FAILED) {
      THIS->hash = NULL;
      Pike_error("Failed to initialize hash.\n");
    }
    break;
  case 0:
    break;
  }
  
  pop_n_elems(args);
}
开发者ID:Letractively,项目名称:caudium,代码行数:43,代码来源:mhash.c

示例6: image_ttf_faceinstance_set_height

static void image_ttf_faceinstance_set_height(INT32 args)
{
   struct image_ttf_face_struct *face_s;
   struct image_ttf_faceinstance_struct *face_i=THISi;
   int h=0;

   if (!args)
      Pike_error("Image.TTF.FaceInstance->set_height(): missing arguments\n");

   if (sp[-args].type==T_INT)
      h = sp[-args].u.integer*64;
   else if (sp[-args].type==T_FLOAT)
      h = DOUBLE_TO_INT(sp[-args].u.float_number*64);
   else
      Pike_error("Image.TTF.FaceInstance->set_height(): illegal argument 1\n");
   if (h<1) h=1;

   if (!(face_s=(struct image_ttf_face_struct*)
	 get_storage(THISi->faceobj,image_ttf_face_program)))
      Pike_error("Image.TTF.FaceInstance->write(): lost Face\n");

   ttf_instance_setc(face_s,face_i,h,"Image.TTF.FaceInstance->set_height()");

   pop_n_elems(args);
   ref_push_object(THISOBJ);
}
开发者ID:ajinkya007,项目名称:pike-1,代码行数:26,代码来源:image_ttf.c

示例7: ctx_create

/*! @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{[email protected]}
 *!
 *! @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);
}
开发者ID:Letractively,项目名称:caudium,代码行数:63,代码来源:sm_context.c

示例8: f_hash_feed

/*
**! method: Mhash.hash feed(string data)
**!    alt: Mhash.hash update(string data)
**!  Update the current hash context with data.
**!  update() is here for compatibility reasons with Crypto.md5.
**! arg: string data
**!  The data to update the context with.
**! returns:
**!  The current hash object.
**! name: feed - Update the current hash context.
*/
void f_hash_feed(INT32 args) 
{
  if(THIS->hash == NULL) {
    if(THIS->type != -1) {
      free_hash();
      THIS->hash = mhash_init(THIS->type);
      if(THIS->hash == MHASH_FAILED) {
	THIS->hash = NULL;
	Pike_error("Failed to initialize hash.\n");
      }
    } else
      Pike_error("Hash is uninitialized. Use Mhash.Hash()->set_type() to select hash type.\n");
  }
  if(args == 1) {
    if(Pike_sp[-args].type != T_STRING) {
      Pike_error("Invalid argument 1. Expected string.\n");
    }
    mhash(THIS->hash, Pike_sp[-args].u.string->str,
	  Pike_sp[-args].u.string->len << Pike_sp[-args].u.string->size_shift);
  } else {
    Pike_error("Invalid number of arguments to Mhash.Hash->feed(), expected 1.\n");
  }
  pop_n_elems(args);
  push_object(this_object());
}
开发者ID:Letractively,项目名称:caudium,代码行数:36,代码来源:mhash.c

示例9: f_ldap_explode_dn

/*
 **| method: array(string) explode_dn ( string dn );
 **| alt: array(string) explode_dn ( string dn, int notypes );
 **|  Takes a DN and converts it into an array of its components,
 **|  called RDN (Relative Distinguished Name).
 **
 **| arg: string dn
 **|  The DN to explode.
 **
 **| arg: int notypes
 **|  If != 0 then the types of the DN components will be ignored and
 **|  *not present in the output. Defaults to 1.
 **
 **| returns: an array of RDN entries.
 */
static void
f_ldap_explode_dn(INT32 args)
{
    struct pike_string       *dn;
    char                    **edn;
    int                       notypes = 1;    

    switch (args) {
        case 2:
            if (ARG(2).type != T_INT)
                Pike_error("OpenLDAP.Client->explode_dn(): argument 2 must be an integer\n");
            notypes = ARG(2).u.integer;
            /* fall through */
            
        case 1:
            if (ARG(1).type != T_STRING)
                Pike_error("OpenLDAP.Client->explode_dn(): argument 1 must be an integer\n");
            dn = ARG(1).u.string;
            break;
            
        default:
            Pike_error("OpenLDAP.Client->explode_dn(): expects at most 2 and at least 1 argument\n");
            break;
    }

    pop_n_elems(args);
    edn = ldap_explode_dn(dn->str, notypes);
    if (!edn) {
        push_int(0);
        return;
    }

    push_array(make_pike_array(edn));
    ldap_value_free(edn);
}
开发者ID:hww3,项目名称:pexts,代码行数:50,代码来源:ol_ldap.c

示例10: f_create

/*
 **| method: void create ( string uri );
 **
 **|  Create a new OpenLDAP client connection object.
 **
 **| name: create - create the object
 **
 **| arg: string uri
 **|  An URI pointing to the LDAP host to connect to as described in
 **|  RFC 2255. The LDAP URI has the general format:
 **|
 **|   # ldap://hostport/dn[?attrs[?scope[?filter[?exts]]]]
 **|
 **|  where
 **|    hostport is a host name with an optional ":portnumber"
 **|    dn is the search base
 **|    attrs is a comma separated list of attributes to request
 **|    scope is one of these three strings:
 **|    base one sub (default=base)
 **|    filter is filter
 **|    exts are recognized set of LDAP and/or API extensions.
 **|
 **|  Documentation to this function has been written based on the
 **|  OpenLDAP v2 ldap_url_parse(3) manual page.
 **
 **| see_also: ldap_url_parse(3), RFC 2255
 */
static void
f_create(INT32 args)
{
    if (args != 1)
        Pike_error("OpenLDAP.Client->create():: wrong number of arguments\n");

    if (ARG(1).type != T_STRING || ARG(1).u.string->size_shift > 0)
        Pike_error("OpenLDAP.Client->create():: expecting an 8-bit string as the first argument (%u)\n",
                   ARG(1).u.string->size_shift);

    if ((THIS->lerrno = ldap_url_parse(ARG(1).u.string->str, &THIS->server_url)))
        Pike_error("OpenLDAP.Client->create():: badly formed server URL\n");

    if (!THIS)
        Pike_error("Serious problem - no THIS...\n");
    
    THIS->conn = ldap_init(THIS->server_url->lud_host,
                           THIS->server_url->lud_port);

    if (!THIS->conn)
        Pike_error("OpenLDAP.Client->create():: error initializing OpenLDAP: '%s'\n",
                   strerror(errno));

    pop_n_elems(args);
}
开发者ID:hww3,项目名称:pexts,代码行数:52,代码来源:ol_ldap.c

示例11: mcast_join

static void mcast_join(INT32 args)
{
   uint32_t mc_addr;
   struct ip_mreq mreq;
   
   if(args!=1)
      Pike_error("mcast->join(): number of arguments invalid.\n");
   if(Pike_sp[-1].type!=T_STRING)
      Pike_error("mcast->join(): expected string.\n");
   
   /* Verifica el estado del socket */
   if( FD < 0 )
     /* El objeto no está inicializado... */
     Pike_error("mcast->join(): Port not bound! (call \"bind\" first)\n");
   
   
   mc_addr = inet_addr(Pike_sp[-1].u.string->str);
   if(mc_addr == -1)
     Pike_error("mcast->join(): Invalid mcast group\n");
   
   mreq.imr_multiaddr.s_addr = mc_addr;
   mreq.imr_interface.s_addr = THIS->if_addr;
   if ( setsockopt(FD,IPPROTO_IP,IP_ADD_MEMBERSHIP,(char *) &mreq,
		   sizeof(mreq)) == -1 )
   {
      UDP->my_errno = errno;
      Pike_error("mcast->join(): error in joining group (%s)\n",strerror(errno));
   }
   
   pop_n_elems(args);
}
开发者ID:hww3,项目名称:pexts,代码行数:31,代码来源:mcast.c

示例12: f_pcre_match

/* Do a regular expression match */
void f_pcre_match(INT32 args) 
{
  struct pike_string *data; /* Data to match */
  pcre_extra *extra = NULL;   /* result from study, if enabled */
  pcre *re = NULL;            /* compiled regexp */
  char *pp;                 /* Pointer... */
  int opts = 0;             /* Match options */
  int is_match;             /* Did it match? */

  if(THIS->regexp == NULL)
    Pike_error("PCRE.Regexp not initialized.\n");
  switch(args)
  {
   case 2:
    switch(Pike_sp[-1].type) {
     case T_STRING:
      opts = parse_options(Pike_sp[-1].u.string->str, NULL);
      if(opts < 0)
	Pike_error("PCRE.Regexp->match(): Unknown option modifier '%c'.\n", -opts);
      break;
     case T_INT:
      if(Pike_sp[-1].u.integer == 0) {
	break;
      }
      /* Fallthrough */
     default:
      Pike_error("Bad argument 2 to PCRE.Regexp->match() - expected string.\n");
      break;
    }
    /* Fall through */
   case 1:
    if(Pike_sp[-args].type != T_STRING || Pike_sp[-args].u.string->size_shift > 0) {
      Pike_error("PCRE.Regexp->match(): Invalid argument 1. Expected 8-bit string.\n");
    }
    data = Pike_sp[-args].u.string;
    break;
   default:
    Pike_error("PCRE.Regexp->match(): Invalid number of arguments. Expected 1 or 2.\n");
  }
  re = THIS->regexp;
  extra = THIS->extra;

  /* Do the pattern matching */
  is_match = pcre_exec(re, extra, data->str, data->len, 0,
		       opts, NULL, 0);
  pop_n_elems(args);
  switch(is_match) {
  case PCRE_ERROR_NOMATCH:   push_int(0);  break;
  case PCRE_ERROR_NULL:      Pike_error("Invalid argumens passed to pcre_exec.\n");
  case PCRE_ERROR_BADOPTION: Pike_error("Invalid options sent to pcre_exec.\n");
  case PCRE_ERROR_BADMAGIC:  Pike_error("Invalid magic number.\n");
  case PCRE_ERROR_UNKNOWN_NODE: Pike_error("Unknown node encountered. PCRE bug or memory error.\n");
  case PCRE_ERROR_NOMEMORY:  Pike_error("Out of memory during execution.\n");
  default:
    push_int(1); /* A match! */
    break; 
  }
}
开发者ID:hww3,项目名称:pexts,代码行数:59,代码来源:pcre.c

示例13: image_ilbm___decode

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);
}
开发者ID:ajinkya007,项目名称:pike-1,代码行数:55,代码来源:ilbm.c

示例14: convert_stack_top_with_base_to_bignum

PMOD_EXPORT void convert_stack_top_with_base_to_bignum(void)
{
  apply_svalue(&auto_bignum_program, 2);

  if(sp[-1].type != T_OBJECT) {
     if (auto_bignum_program.type!=T_PROGRAM)
	Pike_error("Gmp.mpz conversion failed (Gmp.bignum not loaded).\n");
     else
	Pike_error("Gmp.mpz conversion failed (unknown error).\n");
  }
}
开发者ID:ajinkya007,项目名称:pike-1,代码行数:11,代码来源:bignum.c

示例15: f_next

/* void next(void) */
static void f_next(INT32 args)
{
  int n;

  if (args)
    Pike_error("Too many arguments to Count->next()\n");

  n = avs_countnext(PIKE_COUNT->handle);
  if (n != AVS_OK)
    Pike_error("Count->next(): %s\n", avs_errmsg(n));
}
开发者ID:hww3,项目名称:pexts,代码行数:12,代码来源:count.c


注:本文中的Pike_error函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。