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


C++ CHECK_STRING函数代码示例

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


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

示例1: __fxstatat

/* Get information about the file NAME relative to FD in ST.  */
int
__fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
{
      int result;

      if (__builtin_expect (vers == _STAT_VER, 1))
	{
	  struct stat16 buf16;
	  result =
	    INLINE_SYSCALL (fstatat, 4, fd, CHECK_STRING (file),
			    __ptrvalue (&buf16), flag);
	  if (result == 0)
	    stat16_to_stat (&buf16, st);
	}
      else if (__builtin_expect (vers == _STAT_VER_stat, 1))
	{
	  result =
	    INLINE_SYSCALL (fstatat, 4, fd, CHECK_STRING (file),
			    CHECK_1 ((struct stat16 *) st), flag);
	}
      else
	{
	  __set_errno (EINVAL);
	  return -1;
	}
	return result;
}
开发者ID:xieyh11,项目名称:raytracing,代码行数:28,代码来源:fxstatat.c

示例2: __lchown

int
__lchown (const char *file, uid_t owner, gid_t group)
{
# if __ASSUME_32BITUIDS > 0
  return INLINE_SYSCALL (lchown32, 3, CHECK_STRING (file), owner, group);
# else
#  ifdef __NR_lchown32
  if (__libc_missing_32bit_uids <= 0)
    {
      int result;
      int saved_errno = errno;

      result = INLINE_SYSCALL (lchown32, 3, CHECK_STRING (file), owner, group);
      if (result == 0 || errno != ENOSYS)
	return result;

      __set_errno (saved_errno);
      __libc_missing_32bit_uids = 1;
    }
#  endif /* __NR_lchown32 */

  if (((owner + 1) > (uid_t) ((__kernel_uid_t) -1U))
      || ((group + 1) > (gid_t) ((__kernel_gid_t) -1U)))
    {
      __set_errno (EINVAL);
      return -1;
    }

  return INLINE_SYSCALL (lchown, 3, CHECK_STRING (file), owner, group);
# endif
}
开发者ID:mbref,项目名称:glibc-236-microblaze,代码行数:31,代码来源:lchown.c

示例3: nbt_register_own

/*
  test that a server responds correctly to attempted registrations of its name
*/
static bool nbt_register_own(struct torture_context *tctx)
{
	struct nbt_name_register io;
	NTSTATUS status;
	struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL);
	struct socket_address *socket_address;
	struct nbt_name name;
	const char *address;
	const char *myaddress;

	if (!torture_nbt_get_name(tctx, &name, &address))
		return false;

	myaddress = iface_best_ip(address);

	socket_address = socket_address_from_strings(tctx, nbtsock->sock->backend_name,
						     myaddress, 0);
	torture_assert(tctx, socket_address != NULL, "Unable to get address");

	status = socket_listen(nbtsock->sock, socket_address, 0, 0);
	torture_assert_ntstatus_ok(tctx, status, 
				"socket_listen for nbt_register_own failed");

	torture_comment(tctx, "Testing name defense to name registration\n");

	io.in.name = name;
	io.in.dest_addr = address;
	io.in.address = myaddress;
	io.in.nb_flags = NBT_NODE_B | NBT_NM_ACTIVE;
	io.in.register_demand = False;
	io.in.broadcast = True;
	io.in.multi_homed = False;
	io.in.ttl = 1234;
	io.in.timeout = 3;
	io.in.retries = 0;
	
	status = nbt_name_register(nbtsock, tctx, &io);
	torture_assert_ntstatus_ok(tctx, status, 
				talloc_asprintf(tctx, "Bad response from %s for name register",
		       address));
	
	CHECK_STRING(tctx, io.out.name.name, name.name);
	CHECK_VALUE(tctx, io.out.name.type, name.type);
	CHECK_VALUE(tctx, io.out.rcode, NBT_RCODE_ACT);

	/* check a register demand */
	io.in.address = myaddress;
	io.in.register_demand = True;

	status = nbt_name_register(nbtsock, tctx, &io);

	torture_assert_ntstatus_ok(tctx, status, 
				talloc_asprintf(tctx, "Bad response from %s for name register demand", address));
	
	CHECK_STRING(tctx, io.out.name.name, name.name);
	CHECK_VALUE(tctx, io.out.name.type, name.type);
	CHECK_VALUE(tctx, io.out.rcode, NBT_RCODE_ACT);

	return true;
}
开发者ID:Marvin-Lee,项目名称:libwmiclient,代码行数:63,代码来源:register.c

示例4: StringEqual

static int StringEqual(LispObject str1, LispObject str2)
{
    int r;
    
    CHECK_STRING(str1);
    CHECK_STRING(str2);
    r = StrEqual(LSTRING(str1)->str, LSTRING(str2)->str);
    return r;
}
开发者ID:f3yagi,项目名称:mysrc,代码行数:9,代码来源:alloc.cpp

示例5: x264_opencl_cache_load

/* Try to load the cached compiled program binary, verify the device context is
 * still valid before reuse */
static cl_program x264_opencl_cache_load( x264_t *h, const char *dev_name, const char *dev_vendor, const char *driver_version )
{
    /* try to load cached program binary */
    FILE *fp = x264_fopen( h->param.psz_clbin_file, "rb" );
    x264_opencl_function_t *ocl;
    cl_program program;
    uint8_t *binary;
    size_t size;
    const uint8_t *ptr;
    cl_int status;

	if( !fp )
        return NULL;

    ocl = h->opencl.ocl;
    program = NULL;
    binary = NULL;

    fseek( fp, 0, SEEK_END );
    size = ftell( fp );
    rewind( fp );
    CHECKED_MALLOC( binary, size );

    if ( fread( binary, 1, size, fp ) != size )
        goto fail;
    ptr = (const uint8_t*)binary;

#define CHECK_STRING( STR )\
    do {\
        size_t len = strlen( STR );\
        if( size <= len || strncmp( (char*)ptr, STR, len ) )\
            goto fail;\
        else {\
            size -= (len+1); ptr += (len+1);\
        }\
    } while( 0 )

    CHECK_STRING( dev_name );
    CHECK_STRING( dev_vendor );
    CHECK_STRING( driver_version );
    CHECK_STRING( x264_opencl_source_hash );
#undef CHECK_STRING

    program = ocl->clCreateProgramWithBinary( h->opencl.context, 1, &h->opencl.device, &size, &ptr, NULL, &status );
    if( status != CL_SUCCESS )
        program = NULL;

fail:
    fclose( fp );
    x264_free( binary );
    return program;
}
开发者ID:markjreed,项目名称:vice-emu,代码行数:54,代码来源:opencl.c

示例6: anoubisd_msg_eventask_size

static int
anoubisd_msg_eventask_size(const char *buf, int buflen)
{
	struct anoubisd_msg_eventask	*msg;
	struct buf_offset		 offs[5];
	int				 i, j, total = 0;
	DECLARE_SIZE();

	CAST(msg, buf, buflen);

	/* Detect offset overlaps */
	ADDOFFSET(0, csum);
	ADDOFFSET(1, path);
	ADDOFFSET(2, ctxcsum);
	ADDOFFSET(3, ctxpath);
	ADDOFFSET(4, ev);

	for (i=0; i<5; ++i) {
		int	s1, e1;
		if (offs[i].len == 0)
			continue;
		s1 = offs[i].off;
		e1 = s1 + offs[i].len;
		if (e1 > total)
			total = e1;
		for (j=0; j<i; ++j) {
			int	s2, e2;
			if (offs[j].len == 0)
				continue;
			s2 = offs[j].off;
			e2 = s2 + offs[j].len;
			if (s2 < e1 && s1 < e2)
				return -1;
		}
	}

	SHIFT_FIELD(msg, payload, buf, buflen);
	if (total > buflen)
		return -1;
	ADD_SIZE(total);
	if (msg->pathlen)
		CHECK_STRING(buf+msg->pathoff, msg->pathlen);
	if (msg->ctxpathlen)
		CHECK_STRING(buf+msg->ctxpathoff, msg->ctxpathlen);
	if (msg->evlen) {
		int	size = eventdev_hdr_size(buf+msg->evoff, msg->evlen);
		CHECK_SIZE(size);
	}
	RETURN_SIZE();
}
开发者ID:genua,项目名称:anoubis,代码行数:50,代码来源:amsg_verify.c

示例7: Lisp_MakeStringInputStream

LispObj *
Lisp_MakeStringInputStream(LispBuiltin *builtin)
/*
 make-string-input-stream string &optional start end
 */
{
    char *string;
    long start, end, length;

    LispObj *ostring, *ostart, *oend, *result;

    oend = ARGUMENT(2);
    ostart = ARGUMENT(1);
    ostring = ARGUMENT(0);

    start = end = 0;
    CHECK_STRING(ostring);
    LispCheckSequenceStartEnd(builtin, ostring, ostart, oend,
			      &start, &end, &length);
    string = THESTR(ostring);

    if (end - start != length)
	length = end - start;
    result = LSTRINGSTREAM(string + start, STREAM_READ, length);

    return (result);
}
开发者ID:shanelle794,项目名称:theqvd,代码行数:27,代码来源:stream.c

示例8: Lisp_Load

/*
 * Implementation
 */
LispObj *
Lisp_Load(LispBuiltin *builtin)
/*
 load filename &key verbose print if-does-not-exist
 */
{
    LispObj *filename, *verbose, *print, *if_does_not_exist;

    if_does_not_exist = ARGUMENT(3);
    print = ARGUMENT(2);
    verbose = ARGUMENT(1);
    filename = ARGUMENT(0);

    if (PATHNAMEP(filename))
	filename = CAR(filename->data.pathname);
    else {
	CHECK_STRING(filename);
    }

    return (LispLoadFile(filename,
			 verbose != UNSPEC && verbose != NIL,
			 print != UNSPEC && print != NIL,
			 if_does_not_exist != UNSPEC &&
			 if_does_not_exist != NIL));
}
开发者ID:8l,项目名称:xedit,代码行数:28,代码来源:require.c

示例9: check_string_without_embedded_nulls

static void
check_string_without_embedded_nulls (Lisp_Object object)
{
  CHECK_STRING (object);
  CHECK_TYPE (memchr (SDATA (object), '\0', SBYTES (object)) == NULL,
              Qstring_without_embedded_nulls_p, object);
}
开发者ID:davidswelt,项目名称:aquamacs-emacs,代码行数:7,代码来源:json.c

示例10: Lisp_PQfnumber

LispObj *
Lisp_PQfnumber(LispBuiltin *builtin)
/*
 pq-fnumber result field-name
 */
{
    int number;
    int field;
    PGresult *res;

    LispObj *result, *field_name;

    field_name = ARGUMENT(1);
    result = ARGUMENT(0);

    if (!CHECKO(result, PGresult_t))
	LispDestroy("%s: cannot convert %s to PGresult*",
		    STRFUN(builtin), STROBJ(result));
    res = (PGresult*)(result->data.opaque.data);

    CHECK_STRING(field_name);
    number = PQfnumber(res, THESTR(field_name));

    return (INTEGER(number));
}
开发者ID:aosm,项目名称:X11,代码行数:25,代码来源:psql.c

示例11: module_copy_string_contents

static bool
module_copy_string_contents (emacs_env *env, emacs_value value, char *buffer,
			     ptrdiff_t *length)
{
  MODULE_FUNCTION_BEGIN (false);
  Lisp_Object lisp_str = value_to_lisp (value);
  CHECK_STRING (lisp_str);

  Lisp_Object lisp_str_utf8 = ENCODE_UTF_8 (lisp_str);
  ptrdiff_t raw_size = SBYTES (lisp_str_utf8);
  ptrdiff_t required_buf_size = raw_size + 1;

  eassert (length != NULL);

  if (buffer == NULL)
    {
      *length = required_buf_size;
      return true;
    }

  eassert (*length >= 0);

  if (*length < required_buf_size)
    {
      *length = required_buf_size;
      xsignal0 (Qargs_out_of_range);
    }

  *length = required_buf_size;
  memcpy (buffer, SDATA (lisp_str_utf8), raw_size + 1);

  return true;
}
开发者ID:QingweiPeterLan,项目名称:cs188-emacs,代码行数:33,代码来源:emacs-module.c

示例12: Lisp_XawTextSearch

LispObj *
Lisp_XawTextSearch(LispBuiltin *builtin)
/*
 xaw-text-search widget direction text
 */
{
    Widget widget;
    XawTextScanDirection direction;
    XawTextBlock block;

    LispObj *owidget, *odirection, *otext;

    otext = ARGUMENT(2);
    odirection = ARGUMENT(1);
    owidget = ARGUMENT(0);

    if (!CHECKO(owidget, xawWidget_t))
	LispDestroy("%s: cannot convert %s to Widget",
		    STRFUN(builtin), STROBJ(owidget));
    widget = (Widget)(owidget->data.opaque.data);

    CHECK_INDEX(odirection);
    direction = (XawTextPosition)FIXNUM_VALUE(odirection);
    if (direction != XawsdLeft && direction != XawsdRight)
	LispDestroy("%s: %d does not fit in XawTextScanDirection",
		    STRFUN(builtin), direction);

    CHECK_STRING(otext);
    block.firstPos = 0;
    block.ptr = THESTR(otext);
    block.length = strlen(block.ptr);
    block.format = FMT8BIT;

    return (FIXNUM(XawTextSearch(widget, direction, &block)));
}
开发者ID:aosm,项目名称:X11,代码行数:35,代码来源:xaw.c

示例13: Lisp_XeditCharStore

/* helper function for setf
 *	DONT explicitly call. Non standard function
 */
LispObj *
Lisp_XeditCharStore(LispBuiltin *builtin)
/*
 xedit::char-store string index value
 */
{
    int character;
    long offset, length;
    LispObj *ostring, *oindex, *ovalue;

    ovalue = ARGUMENT(2);
    oindex = ARGUMENT(1);
    ostring = ARGUMENT(0);

    CHECK_STRING(ostring);
    CHECK_INDEX(oindex);
    length = STRLEN(ostring);
    offset = FIXNUM_VALUE(oindex);
    if (offset >= length)
	LispDestroy("%s: index %ld too large for string length %ld",
		    STRFUN(builtin), offset, length);
    CHECK_SCHAR(ovalue);
    CHECK_STRING_WRITABLE(ostring);

    character = SCHAR_VALUE(ovalue);

    if (character < 0 || character > 255)
	LispDestroy("%s: cannot represent character %d",
		    STRFUN(builtin), character);

    THESTR(ostring)[offset] = character;

    return (ovalue);
}
开发者ID:8l,项目名称:xedit,代码行数:37,代码来源:string.c

示例14: Lisp_Char

LispObj *
Lisp_Char(LispBuiltin *builtin)
/*
 char string index
 schar simple-string index
 */
{
    unsigned char *string;
    long offset, length;

    LispObj *ostring, *oindex;

    oindex = ARGUMENT(1);
    ostring = ARGUMENT(0);

    CHECK_STRING(ostring);
    CHECK_INDEX(oindex);
    offset = FIXNUM_VALUE(oindex);
    string = (unsigned char*)THESTR(ostring);
    length = STRLEN(ostring);

    if (offset >= length)
	LispDestroy("%s: index %ld too large for string length %ld",
		    STRFUN(builtin), offset, length);

    return (SCHAR(string[offset]));
}
开发者ID:8l,项目名称:xedit,代码行数:27,代码来源:string.c

示例15: __lxstat

/* Get information about the file NAME in BUF.  */
int
__lxstat (int vers, const char *name, struct stat *buf)
{
#if __ASSUME_STAT64_SYSCALL == 0
  struct kernel_stat kbuf;
#endif
  int result;

  if (vers == _STAT_VER_KERNEL)
    return INLINE_SYSCALL (lstat, 2, CHECK_STRING (name), CHECK_1 ((struct kernel_stat *) buf));

#if __ASSUME_STAT64_SYSCALL > 0
  {
    struct stat64 buf64;

    result = INLINE_SYSCALL (lstat64, 2, CHECK_STRING (name), __ptrvalue (&buf64));
    if (result == 0)
      result = __xstat32_conv (vers, &buf64, buf);
    return result;
  }
#else

# if defined __NR_stat64
  /* To support 32 bit UIDs, we have to use stat64.  The normal stat call only returns
     16 bit UIDs.  */
  if (! __have_no_stat64)
    {
      struct stat64 buf64;
      result = INLINE_SYSCALL (lstat64, 2, CHECK_STRING (name), __ptrvalue (&buf64));

      if (result == 0)
	result = __xstat32_conv (vers, &buf64, buf);

      if (result != -1 || errno != ENOSYS)
	return result;

      __have_no_stat64 = 1;
    }
# endif

  result = INLINE_SYSCALL (lstat, 2, CHECK_STRING (name), __ptrvalue (&kbuf));
  if (result == 0)
    result = __xstat_conv (vers, &kbuf, buf);

  return result;
#endif
}
开发者ID:mbref,项目名称:glibc-236-microblaze,代码行数:48,代码来源:lxstat.c


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