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


C++ SLang_verror函数代码示例

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


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

示例1: _SLns_set_namespace_name

int _SLns_set_namespace_name (SLang_NameSpace_Type *t, char *name)
{
   SLang_NameSpace_Type *t1;
   
   t1 = _SLns_find_namespace (name);
   if (t == t1)
     return 0;			       /* already has this name */

   if (t1 == NULL)
     t1 = t;
   
   if ((t != t1) || (*name == 0))
     {
	SLang_verror (SL_INTRINSIC_ERROR, "Namespace \"%s\" already exists",
		      name);
	return -1;
     }

   if (t->namespace_name != NULL)
     {
	SLang_verror (SL_INTRINSIC_ERROR, "An attempt was made to redefine namespace from \"%s\" to \"%s\"\n",
		      t->namespace_name, name);
	return -1;
     }

   if (NULL == (name = SLang_create_slstring (name)))
     return -1;

   SLang_free_slstring (t->namespace_name);   /* NULL ok */
   t->namespace_name = name;
   
   return 0;
}
开发者ID:GalaxyTab4,项目名称:workbench,代码行数:33,代码来源:slnspace.c

示例2: bind_af_unix

static int bind_af_unix (Socket_Type *s, int nargs)
{
   struct sockaddr_un addr;
   char *file;

   if (nargs != 1)
     {
	SLang_verror (SL_NumArgs_Error, "This socket expects a filename");
	return -1;
     }
   if (-1 == SLang_pop_slstring (&file))
     return -1;

   if (strlen (file) >= sizeof(addr.sun_path))
     {
	SLang_verror (SL_InvalidParm_Error, "filename too long for PF_UNIX socket");
	SLang_free_slstring (file);
	return -1;
     }

   memset ((char *)&addr, 0, sizeof (struct sockaddr_un));
   addr.sun_family = AF_UNIX;
   strcpy (addr.sun_path, file);       /* \0 terminated */

   (void) unlink (file);
   s->socket_data = (VOID_STAR) file;
   return perform_bind (s->fd, (struct sockaddr *)&addr, sizeof (addr));
}
开发者ID:hankem,项目名称:S-Lang,代码行数:28,代码来源:socket-module.c

示例3: fread

static Png_Type *open_png_file (char *file)
{
   png_byte header[8];
   Png_Type *p;

   if (NULL == (p = alloc_png_type ('r')))
     return NULL;

   if ((NULL == (p->fp = fopen (file, "rb")))
       || (8 != fread (header, 1, 8, p->fp))
       || (0 != png_sig_cmp(header, 0, 8)))
     {
	SLang_verror (SL_Open_Error, "Unable to open %s as a png file", file);
	free_png_type (p);
	return NULL;
     }

   if (NULL == (p->png = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL)))
     {
	SLang_verror (SL_Open_Error, "Unable to read png structure from %s", file);
	free_png_type (p);
	return NULL;
     }

   if (NULL == (p->info = png_create_info_struct (p->png)))
     {
	SLang_verror (SL_Read_Error, "Unable to create info struct for %s", file);
	free_png_type (p);
	return NULL;
     }

   return p;
}
开发者ID:Distrotech,项目名称:slang,代码行数:33,代码来源:png-module.c

示例4: accept_intrin

static void accept_intrin (void)
{
   SLFile_FD_Type *f;
   Socket_Type *s, *s1;
   Domain_Methods_Type *methods;
   int nargs = SLang_Num_Function_Args;
   SLang_Ref_Type *refs[MAX_ACCEPT_REF_ARGS];
   int i;

   if (nargs <= 0)
     {
	SLang_verror (SL_Usage_Error, "s1 = accept (s [,&v...])");
	return;
     }

   if (-1 == SLroll_stack (-nargs))
     return;

   if (NULL == (s = pop_socket (&f)))
     return;
   nargs--;

   if (nargs > MAX_ACCEPT_REF_ARGS)
     {
	SLang_verror (SL_NumArgs_Error, "accept: too many reference args");
	SLfile_free_fd (f);
     }
   memset ((char *)refs, 0, sizeof (refs));

   i = nargs;
   while (i != 0)
     {
	i--;
	if (-1 == SLang_pop_ref (refs+i))
	  goto free_return;
     }

   methods = s->methods;
   if (NULL != (s1 = (*methods->accept)(s, nargs, refs)))
     (void) push_socket (s1);	       /* frees it upon error */

   /* drop */

free_return:
   for (i = 0; i < nargs; i++)
     {
	if (refs[i] != NULL)
	  SLang_free_ref (refs[i]);
     }
   SLfile_free_fd (f);
}
开发者ID:hankem,项目名称:S-Lang,代码行数:51,代码来源:socket-module.c

示例5: run_hooks_cmd

static void run_hooks_cmd (void)
{
   unsigned int n;
   SLang_Array_Type *at;
   int method;
   char *hook;

   n = (unsigned int) SLang_Num_Function_Args;

   at = NULL;
   hook = NULL;
   switch (n)
     {
      case 3:
	if (-1 == SLang_pop_array_of_type (&at, SLANG_STRING_TYPE))
	  return;
	/* drop */
      case 2:
	if (-1 == SLang_pop_integer (&method))
	  goto the_return;
	if (-1 == SLang_pop_slstring (&hook))
	  goto the_return;
	break;

      default:
	SLang_verror (SL_USAGE_ERROR, "usage: expecting 2 or 3 arguments");
	return;
     }

   switch (method)
     {
      case JED_HOOKS_RUN_ALL:
      case JED_HOOKS_RUN_UNTIL_0:
      case JED_HOOKS_RUN_UNTIL_NON_0:
	break;

      default:
	SLang_verror (SL_INVALID_PARM, "run method %d is not supported", method);
	goto the_return;
     }

   if (at == NULL)
     (void) jed_run_hooks (hook, method, 0, NULL);
   else
     (void) jed_run_hooks (hook, method, at->num_elements, (char **) at->data);

   the_return:
   SLang_free_slstring (hook);
   SLang_free_array (at);
}
开发者ID:hankem,项目名称:jed,代码行数:50,代码来源:hooks.c

示例6: connect_af_inet

static int connect_af_inet (Socket_Type *s, int nargs)
{
   struct sockaddr_in s_in;
   int port;
   char *host;
   Host_Addr_Info_Type *hinfo;
   unsigned int i;

   if (-1 == pop_host_port ("connect", nargs, &host, &port))
     return -1;

   if (NULL == (hinfo = get_host_addr_info (host)))
     {
	SLang_free_slstring (host);
	return -1;
     }

   if (hinfo->h_addrtype != AF_INET)
     {
# ifdef AF_INET6
	if (hinfo->h_addrtype == AF_INET6)
	  SLang_verror (SL_NOT_IMPLEMENTED, "AF_INET6 not implemented");
	else
# endif
	  SLang_verror (SocketError, "Unknown socket family for host %s", host);
	SLang_free_slstring (host);
	free_host_addr_info (hinfo);
	return -1;
     }

   memset ((char *) &s_in, 0, sizeof(s_in));
   s_in.sin_family = hinfo->h_addrtype;
   s_in.sin_port = htons((unsigned short) port);

   for (i = 0; i < hinfo->num; i++)
     {
	memcpy ((char *) &s_in.sin_addr, hinfo->h_addr_list[i], hinfo->h_length);
	if (-1 == perform_connect (s->fd, (struct sockaddr *)&s_in, sizeof (s_in), 0))
	  continue;

	free_host_addr_info (hinfo);
	SLang_free_slstring (host);
	return 0;
     }
   throw_errno_error ("connect", errno);
   free_host_addr_info (hinfo);
   SLang_free_slstring (host);
   return -1;
}
开发者ID:hankem,项目名称:S-Lang,代码行数:49,代码来源:socket-module.c

示例7: user_create_ray

int user_create_ray (double *delta_t, double *energy,
		     double *cosx, double *cosy, double *cosz)
{
   if (Num_Rays == 0)
     {
	if (-1 == SLexecute_function (Create_Ray))
	  {
	     SLang_verror (0, "Encountered an error processing %s\n", "user_create_ray");
	     return -1;
	  }
	
	if (SLang_peek_at_stack () == SLANG_NULL_TYPE)
	  return -1;		       /* done */

	if ((-1 == pop_array (&CosZ_Array))
	    || (-1 == pop_array (&CosY_Array))
	    || (-1 == pop_array (&CosX_Array))
	    || (-1 == pop_array (&Energy_Array))
	    || (-1 == pop_array (&dT_Array)))
	  {
	     SLang_verror (0, "Encountered an error processing %s\n", "user_create_ray");
	     return -1;
	  }
	
	if (Num_Rays == 0)
	  return -1;
	
	if (CosX_Array.num_elements < Num_Rays)
	  CosX_Array.di = 0;
	if (CosY_Array.num_elements < Num_Rays)
	  CosY_Array.di = 0;
	if (CosZ_Array.num_elements < Num_Rays)
	  CosZ_Array.di = 0;
	if (dT_Array.num_elements < Num_Rays)
	  dT_Array.di = 0;
	if (Energy_Array.num_elements < Num_Rays)
	  Energy_Array.di = 0;
     }

   *cosx = next_element (&CosX_Array);
   *cosy = next_element (&CosY_Array);
   *cosz = next_element (&CosZ_Array);
   *delta_t = next_element (&dT_Array);
   *energy = next_element (&Energy_Array);
   
   Num_Rays--;
   return 0;
}
开发者ID:Chandra-MARX,项目名称:marx,代码行数:48,代码来源:slang.c

示例8: test_type_sput

static int test_type_sput (SLtype type, SLFUTURE_CONST char *name)
{
   Test_Type *t;
   int status;

   (void) type;
   if (-1 == pop_test_type (&t))
     return -1;

   status = -1;
   if (0 == strcmp (name, "field1"))
     status = SLang_pop_int (&t->field1);
   else if (0 == strcmp (name, "field2"))
     status = SLang_pop_int (&t->field2);
   else if (0 == strcmp (name, "any"))
     {
	SLang_Any_Type *any;
	if (0 == (status = SLang_pop_anytype (&any)))
	  {
	     SLang_free_anytype (t->any);
	     t->any = any;
	  }
     }
   else
     SLang_verror (SL_INVALID_PARM,
		   "Test_Type.%s is invalid", name);

   free_test_type (t);
   return status;
}
开发者ID:parke,项目名称:slang,代码行数:30,代码来源:sltest.c

示例9: _iconv_open

static void _iconv_open(char *tocode, char *fromcode)
{
   iconv_t cd;
   SLang_MMT_Type *mmt;

   cd = iconv_open(tocode, fromcode);
   if (cd == (iconv_t)(-1))
     {
	SLang_verror (SL_INTRINSIC_ERROR, "Error preparing iconv to convert from '%s' to '%s'.", fromcode, tocode);
	return;
     }

   if (NULL == (mmt = allocate_iconv_type (cd)))
     {
	iconv_close(cd);
	return;
     }

   if (-1 == SLang_push_mmt (mmt))
     {
	SLang_free_mmt (mmt);
	return;
     }
   return;
}
开发者ID:parke,项目名称:slang,代码行数:25,代码来源:iconv-module.c

示例10: handle_signal

/* This function is reentrant */
static int handle_signal (Signal_Type *s)
{
   int status = 0;
   int was_blocked;

   (void) block_signal (s->sig, &was_blocked);

   /* At this point, sig is blocked and the handler is about to be called.
    * The pending flag can be safely set to 0 here.
    */
   s->pending = 0;

   if (s->handler != NULL)
     {
	int depth = SLstack_depth ();

	if ((-1 == SLang_start_arg_list ())
	    || (-1 == SLang_push_integer (s->sig))
	    || (-1 == SLang_end_arg_list ())
	    || (-1 == SLexecute_function (s->handler)))
	  status = -1;

	if ((status == 0)
	    && (depth != SLstack_depth ()))
	  {
	     SLang_verror (SL_Application_Error, "The signal handler %s corrupted the stack", s->handler->name);
	     status = -1;
	  }
     }

   if (was_blocked == 0)
     (void) unblock_signal (s->sig);

   return status;
}
开发者ID:Distrotech,项目名称:slang,代码行数:36,代码来源:slsig.c

示例11: do_onig_search_internal

static int do_onig_search_internal (Onig_Type *o, OnigOptionType option, UChar *str, UChar *str_end, int start_pos, int end_pos)
{
   UChar *start, *range;
   int status;

   onig_region_clear (o->region);

   start = str + start_pos;
   range = str + end_pos;
   /* fwd search: (start <= search string < range)
    * bkw search: (range <= search string <= start)
    */
   if ((start < str) || (start > str_end)
       || (range < str) || (range > str_end))
     {
	SLang_verror (SL_InvalidParm_Error, "Invalid string offsets");
	return -1;
     }
   status = onig_search (o->re, str, str_end, start, range, o->region, option);

   if (status >= 0)
     return status;

   if (status == ONIG_MISMATCH)
     return -1;

   throw_onig_error (status, NULL);
   return -2;
}
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:29,代码来源:onig-module.c

示例12: SLang_verror

/* Here nx corresponds to the fastest varying dimension and ny the slowest */
static SLang_Array_Type *pop_2d_float_array (float **data, unsigned int *ny, unsigned int *nx)
{
   SLang_Array_Type *at;

   *data = NULL;
   *nx = *ny = 0;

   if (-1 == SLclass_typecast (SLANG_FLOAT_TYPE, 1, 1))
     return NULL;

   if (-1 == SLang_pop_array (&at, 1))
     return NULL;

   if (at->num_dims > 2)
     {
        SLang_verror (SL_TYPE_MISMATCH,
                      "A 2d numeric array is expected");
        SLang_free_array (at);
        return NULL;
     }

   *data = (float *)at->data;
   *ny = at->dims[0];
   if (at->num_dims == 1)
     *nx = 1;
   else
     *nx = at->dims[1];

   return at;
}
开发者ID:hankem,项目名称:ISIS,代码行数:31,代码来源:pgplot-module.c

示例13: sl_ssl_read

static void sl_ssl_read(void){
  SLssl_Type *ssl;
  SLang_MMT_Type *sslmmt;
  SLang_Ref_Type *buff;
  void *ibuff;
  SLang_BString_Type *data;
  int r, rlen;
  
  if (SLang_pop_integer(&rlen)==-1 ||
      SLang_pop_ref(&buff)==-1 ||
      NULL==(sslmmt=SLang_pop_mmt(SLssl_Type_Id)))
    return;

  ssl=(SLssl_Type *)SLang_object_from_mmt(sslmmt);

  ibuff=(void *)malloc(rlen);

  r=SSL_read((SSL *)ssl->ssl,ibuff,rlen);

  data=SLbstring_create((unsigned char *)ibuff,r);

  SLang_assign_to_ref(buff, SLANG_BSTRING_TYPE, (VOID_STAR)&data);

  if (r>=0)
    SLang_push_integer(r);
  else
    SLang_verror(r,"SSL read returned error code %d",
		 SSL_get_error((SSL *)ssl->ssl,r));

  SLang_free_ref(buff);
}
开发者ID:amitschang,项目名称:slcrypto,代码行数:31,代码来源:crypto-module.c

示例14: setup_onig

static int setup_onig (void)
{
   static int inited = 0;

   if (inited)
     return 0;

   if ((-1 == slOnig_Error)
       && (-1 == (slOnig_Error = SLerr_new_exception (SL_RunTime_Error, "OnigError", "Onig Error"))))
     return -1;

   if (-1 == onig_init ())
     {
	SLang_verror (slOnig_Error, "onig_init failed");
	return -1;
     }

   onig_set_warn_func (&warn_func);
   onig_set_verb_warn_func (&verb_warn_func);
   onig_set_default_syntax (ONIG_SYNTAX_PERL);

   inited = 1;

   return 0;
}
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:25,代码来源:onig-module.c

示例15: throw_onig_error

static void throw_onig_error (int err_code, OnigErrorInfo *einfo)
{
   UChar err_buf[ONIG_MAX_ERROR_MESSAGE_LEN];

   (void) onig_error_code_to_str (err_buf, err_code, einfo);
   SLang_verror (slOnig_Error, "%s", err_buf);
}
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:7,代码来源:onig-module.c


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