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


C++ seterr函数代码示例

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


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

示例1: gcgcef_msize

/*
 * Extension: report memory size
 */
size_t
gcgcef_msize(CGCEf *cgcef, CGCEf_Type type, size_t count, unsigned ver) {
    size_t n;

    if (cgcef) {
	if (cgcef->e_kind != CGCEF_K_CGCEF) {
	    seterr(ERROR_NOTCGCEF);
	}
	else if (!valid_class(cgcef->e_class)) {
	    seterr(ERROR_UNKNOWN_CLASS);
	}
	else if (!valid_version(ver)) {
	    seterr(ERROR_UNKNOWN_VERSION);
	}
	else if (!valid_type(type)) {
	    seterr(ERROR_UNKNOWN_TYPE);
	}
	else if (!(n = _msize(cgcef->e_class, ver, type))) {
	    seterr(ERROR_UNKNOWN_TYPE);
	}
	else {
	    return count * n;
	}
    }
    return 0;
}
开发者ID:BitK-,项目名称:libcgcef,代码行数:29,代码来源:32.fsize.c

示例2: ib

int TSolver::checkexpr()
{int i,j;
 int SL=strlen(S);
 if (SL==1)
   if (!(isconst(S[0])||isnumc(S[0])) )
     {seterr(E_EXPR);
      return 0;
     }
   else return 1;
 if (!(isnumc(S[SL-1])||S[SL-1]==')'||S[SL-1]==']'||isconst(S[SL-1])))
   {seterr(E_EXPR);
    return 0;
   }
#define ib(x) (i>0?(x):1)
 for (i=0;i<SL-1;i++)
   {if (isfn(S[i])||isconst(S[i])||issymbevul(S[i])||S[i]=='('||S[i]=='[')
    if(!( ( isfn(S[i]) && (S[i+1]=='(') )||
          ( i>0?S[i]=='(' && isfn(S[i-1]):1 )||
          ( isconst(S[i]) && (issymbevul(S[i+1])||S[i+1]==')'||S[i+1]==']') )||
          ( ((issymbevul(S[i])||S[i]=='('||S[i]=='[')&&(isnumc(S[i+1])||S[i+1]=='-'||S[i+1]=='_'||isstrevul(S[i+1])||S[i+1]=='('||S[i+1]=='[')) )
         )
      )
      {seterr(E_EXPR);
       return 0;
      }
   }
 return 1;
}
开发者ID:chemikadze,项目名称:oldschool,代码行数:28,代码来源:NPS.CPP

示例3: initiebucks

/*
 * initialize the external bucket sorting data structures
 */
static IEBucks*
initiebucks(Part *part, int bits, uint32_t size)
{
	IEBucks *ib;
	int i;

	ib = MKZ(IEBucks);
	if(ib == nil){
		seterr(EOk, "out of memory");
		return nil;
	}
	ib->bits = bits;
	ib->nbucks = 1 << bits;
	ib->size = size;
	ib->usable = (size - U32Size) / IEntrySize * IEntrySize;
	ib->bucks = MKNZ(IEBuck, ib->nbucks);
	if(ib->bucks == nil){
		seterr(EOk, "out of memory allocation sorting buckets");
		freeiebucks(ib);
		return nil;
	}
	ib->xbuf = MKN(uint8_t, size * ((1 << bits)+1));
	ib->buf = (uint8_t*)(((uintptr)ib->xbuf+size-1)&~(uintptr)(size-1));
	if(ib->buf == nil){
		seterr(EOk, "out of memory allocating sorting buckets' buffers");
		freeiebucks(ib);
		return nil;
	}
	for(i = 0; i < ib->nbucks; i++){
		ib->bucks[i].head = TWID32;
		ib->bucks[i].buf = &ib->buf[i * size];
	}
	ib->part = part;
	return ib;
}
开发者ID:aahud,项目名称:harvey,代码行数:38,代码来源:sortientry.c

示例4: gelf_getphdr

GElf_Phdr*
gelf_getphdr(Elf *elf, int ndx, GElf_Phdr *dst) {
    GElf_Phdr buf;
    char *tmp;
    size_t n;

    if (!elf) {
	return NULL;
    }
    elf_assert(elf->e_magic == ELF_MAGIC);
    tmp = _elf_getphdr(elf, elf->e_class);
    if (!tmp) {
	return NULL;
    }
    if (ndx < 0 || ndx >= elf->e_phnum) {
	seterr(ERROR_BADINDEX);
	return NULL;
    }
    n = _msize(elf->e_class, _elf_version, ELF_T_PHDR);
    if (n == 0) {
	seterr(ERROR_UNIMPLEMENTED);
	return NULL;
    }
    if (!dst) {
	dst = &buf;
    }
    if (elf->e_class == ELFCLASS64) {
	*dst = *(Elf64_Phdr*)(tmp + ndx * n);
    }
    else if (elf->e_class == ELFCLASS32) {
	Elf32_Phdr *src = (Elf32_Phdr*)(tmp + ndx * n);

	check_and_copy(GElf_Word,  dst, src, p_type,   NULL);
	check_and_copy(GElf_Word,  dst, src, p_flags,  NULL);
	check_and_copy(GElf_Off,   dst, src, p_offset, NULL);
	check_and_copy(GElf_Addr,  dst, src, p_vaddr,  NULL);
	check_and_copy(GElf_Addr,  dst, src, p_paddr,  NULL);
	check_and_copy(GElf_Xword, dst, src, p_filesz, NULL);
	check_and_copy(GElf_Xword, dst, src, p_memsz,  NULL);
	check_and_copy(GElf_Xword, dst, src, p_align,  NULL);
    }
    else {
	if (valid_class(elf->e_class)) {
	    seterr(ERROR_UNIMPLEMENTED);
	}
	else {
	    seterr(ERROR_UNKNOWN_CLASS);
	}
	return NULL;
    }
    if (dst == &buf) {
	dst = (GElf_Phdr*)malloc(sizeof(GElf_Phdr));
	if (!dst) {
	    seterr(ERROR_MEM_PHDR);
	    return NULL;
	}
	*dst = buf;
    }
    return dst;
}
开发者ID:samgh1230,项目名称:experiment_data,代码行数:60,代码来源:gelfphdr.c

示例5: _elf_read

void*
_elf_read(Elf *elf, void *buffer, size_t off, size_t len) {
    void *tmp;

    elf_assert(elf);
    elf_assert(elf->e_magic == ELF_MAGIC);
    elf_assert(off >= 0 && off + len <= elf->e_size);
    if (elf->e_disabled) {
	seterr(ERROR_FDDISABLED);
    }
    else if (len) {
	off += elf->e_base;
	if (lseek(elf->e_fd, (off_t)off, SEEK_SET) != (off_t)off) {
	    seterr(ERROR_IO_SEEK);
	}
	else if (!(tmp = buffer) && !(tmp = malloc(len))) {
	    seterr(ERROR_IO_2BIG);
	}
	else if (read(elf->e_fd, tmp, len) != (int)len) {
	    seterr(ERROR_IO_READ);
	    if (tmp != buffer) {
		free(tmp);
	    }
	}
	else {
	    return tmp;
	}
    }
    return NULL;
}
开发者ID:xyuan,项目名称:Path64,代码行数:30,代码来源:input.c

示例6: elf_strptr

char*
elf_strptr(Elf *elf, size_t section, size_t offset) {
    Elf_Scn *scn;
    Elf_Data *sd;

    if (!elf) {
	return NULL;
    }
    elf_assert(elf->e_magic == ELF_MAGIC);
    if (!(scn = elf_getscn(elf, section))) {
	return NULL;
    }
    if (scn->s_type != SHT_STRTAB) {
	seterr(ERROR_NOSTRTAB);
	return NULL;
    }
    if (offset >= 0 && offset < scn->s_size) {
	sd = NULL;
	while ((sd = elf_getdata(scn, sd))) {
	    if (sd->d_buf
	     && offset >= (size_t)sd->d_off
	     && offset < (size_t)sd->d_off + sd->d_size) {
		return (char*)sd->d_buf + (offset - sd->d_off);
	    }
	}
    }
    seterr(ERROR_BADSTROFF);
    return NULL;
}
开发者ID:rdeforest,项目名称:ColdStore,代码行数:29,代码来源:strptr.c

示例7: elf_newdata

Elf_Data*
elf_newdata(Elf_Scn *scn) {
    Scn_Data *sd;

    if (!scn) {
	return NULL;
    }
    elf_assert(scn->s_magic == SCN_MAGIC);
    if (scn->s_index == SHN_UNDEF) {
	seterr(ERROR_NULLSCN);
    }
    else if (!(sd = (Scn_Data*)malloc(sizeof(*sd)))) {
	seterr(ERROR_MEM_SCNDATA);
    }
    else {
	*sd = _elf_data_init;
	sd->sd_data_flags = ELF_F_DIRTY;
	sd->sd_freeme = 1;
	sd->sd_data.d_version = _elf_version;
	if (scn->s_data_n) {
	    scn->s_data_n->sd_link = sd;
	}
	else {
	    scn->s_data_1 = sd;
	}
	scn->s_data_n = sd;
	return &sd->sd_data;
    }
    return NULL;
}
开发者ID:rdeforest,项目名称:ColdStore,代码行数:30,代码来源:newdata.c

示例8: gelf_msize

/*
 * Extension: report memory size
 */
size_t
gelf_msize(Elf *elf, Elf_Type type, size_t count, unsigned ver) {
    size_t n;

    if (elf) {
	if (elf->e_kind != ELF_K_ELF) {
	    seterr(ERROR_NOTELF);
	}
	else if (!valid_class(elf->e_class)) {
	    seterr(ERROR_UNKNOWN_CLASS);
	}
	else if (!valid_version(ver)) {
	    seterr(ERROR_UNKNOWN_VERSION);
	}
	else if (!valid_type(type)) {
	    seterr(ERROR_UNKNOWN_TYPE);
	}
	else if (!(n = _msize(elf->e_class, ver, type))) {
	    seterr(ERROR_UNKNOWN_TYPE);
	}
	else {
	    return count * n;
	}
    }
    return 0;
}
开发者ID:cdaffara,项目名称:symbian-oss_adapt,代码行数:29,代码来源:32.fsize.c

示例9: gelf_update_shdr

int
gelf_update_shdr(Elf_Scn *scn, GElf_Shdr *src) {
    if (!scn || !src) {
	return 0;
    }
    elf_assert(scn->s_magic == SCN_MAGIC);
    elf_assert(scn->s_elf);
    elf_assert(scn->s_elf->e_magic == ELF_MAGIC);
    if (scn->s_elf->e_class == ELFCLASS64) {
	scn->s_shdr64 = *src;
    }
    else if (scn->s_elf->e_class == ELFCLASS32) {
	Elf32_Shdr *dst = &scn->s_shdr32;

	check_and_copy(Elf32_Word, dst, src, sh_name,      0);
	check_and_copy(Elf32_Word, dst, src, sh_type,      0);
	check_and_copy(Elf32_Word, dst, src, sh_flags,     0);
	check_and_copy(Elf32_Addr, dst, src, sh_addr,      0);
	check_and_copy(Elf32_Off,  dst, src, sh_offset,    0);
	check_and_copy(Elf32_Word, dst, src, sh_size,      0);
	check_and_copy(Elf32_Word, dst, src, sh_link,      0);
	check_and_copy(Elf32_Word, dst, src, sh_info,      0);
	check_and_copy(Elf32_Word, dst, src, sh_addralign, 0);
	check_and_copy(Elf32_Word, dst, src, sh_entsize,   0);
    }
    else if (valid_class(scn->s_elf->e_class)) {
	seterr(ERROR_UNIMPLEMENTED);
	return 0;
    }
    else {
	seterr(ERROR_UNKNOWN_CLASS);
	return 0;
    }
    return 1;
}
开发者ID:manojxantony,项目名称:compiler,代码行数:35,代码来源:gelfshdr.c

示例10: _elf_newehdr

static char*
_elf_newehdr(Elf *elf, unsigned cls) {
    size_t size;

    if (!elf) {
	return NULL;
    }
    elf_assert(elf->e_magic == ELF_MAGIC);
    if (elf->e_readable) {
	return _elf_getehdr(elf, cls);
    }
    else if (!elf->e_ehdr) {
	size = _msize(cls, _elf_version, ELF_T_EHDR);
	elf_assert(size);
	if ((elf->e_ehdr = (char*)malloc(size))) {
	    memset(elf->e_ehdr, 0, size);
	    elf->e_free_ehdr = 1;
	    elf->e_ehdr_flags |= ELF_F_DIRTY;
	    elf->e_kind = ELF_K_ELF;
	    elf->e_class = cls;
	    return elf->e_ehdr;
	}
	seterr(ERROR_MEM_EHDR);
    }
    else if (elf->e_class != cls) {
	seterr(ERROR_CLASSMISMATCH);
    }
    else {
	elf_assert(elf->e_kind == ELF_K_ELF);
	return elf->e_ehdr;
    }
    return NULL;
}
开发者ID:rdeforest,项目名称:ColdStore,代码行数:33,代码来源:32.newehdr.c

示例11: cgcef_nextscn

CGCEf_Scn*
cgcef_nextscn(CGCEf *cgcef, CGCEf_Scn *scn) {
    if (!cgcef) {
	return NULL;
    }
    cgcef_assert(cgcef->e_magic == CGCEF_MAGIC);
    if (scn) {
	cgcef_assert(scn->s_magic == SCN_MAGIC);
	if (scn->s_cgcef == cgcef) {
	    return scn->s_link;
	}
	seterr(ERROR_CGCEFSCNMISMATCH);
    }
    else if (cgcef->e_kind != CGCEF_K_CGCEF) {
	seterr(ERROR_NOTCGCEF);
    }
    else if (cgcef->e_ehdr || _cgcef_cook(cgcef)) {
	cgcef_assert(cgcef->e_ehdr);
	for (scn = cgcef->e_scn_1; scn; scn = scn->s_link) {
	    cgcef_assert(scn->s_magic == SCN_MAGIC);
	    cgcef_assert(scn->s_cgcef == cgcef);
	    if (scn->s_index == 1) {
		return scn;
	    }
	}
	seterr(ERROR_NOSUCHSCN);
    }
    return NULL;
}
开发者ID:BitK-,项目名称:libcgcef,代码行数:29,代码来源:nextscn.c

示例12: elf_nextscn

Elf_Scn*
elf_nextscn(Elf *elf, Elf_Scn *scn) {
    if (!elf) {
	return NULL;
    }
    elf_assert(elf->e_magic == ELF_MAGIC);
    if (scn) {
	elf_assert(scn->s_magic == SCN_MAGIC);
	if (scn->s_elf == elf) {
	    return scn->s_link;
	}
	seterr(ERROR_ELFSCNMISMATCH);
    }
    else if (elf->e_kind != ELF_K_ELF) {
	seterr(ERROR_NOTELF);
    }
    else if (elf->e_ehdr || _elf_cook(elf)) {
	elf_assert(elf->e_ehdr);
	for (scn = elf->e_scn_1; scn; scn = scn->s_link) {
	    elf_assert(scn->s_magic == SCN_MAGIC);
	    elf_assert(scn->s_elf == elf);
	    if (scn->s_index == 1) {
		return scn;
	    }
	}
	seterr(ERROR_NOSUCHSCN);
    }
    return NULL;
}
开发者ID:119,项目名称:aircam-openwrt,代码行数:29,代码来源:nextscn.c

示例13: elf_memory

Elf*
elf_memory(char *image, size_t size) {
    Elf *elf;

    elf_assert(_elf_init.e_magic == ELF_MAGIC);
    if (_elf_version == EV_NONE) {
	seterr(ERROR_VERSION_UNSET);
	return NULL;
    }
    else if (size == 0 || image == NULL) {
	/* TODO: set error code? */
	return NULL;
    }

    if (!(elf = (Elf*)malloc(sizeof(Elf)))) {
	seterr(ERROR_MEM_ELF);
	return NULL;
    }
    *elf = _elf_init;
    elf->e_size = elf->e_dsize = size;
    elf->e_data = elf->e_rawdata = image;
    elf->e_readable = 1;
    elf->e_disabled = 1;
    elf->e_memory = 1;

    _elf_check_type(elf, size);
    return elf;
}
开发者ID:rdeforest,项目名称:ColdStore,代码行数:28,代码来源:begin.c

示例14: wbisect

int
wbisect(ISect *is)
{
	ZBlock *b;

	b = alloczblock(HeadSize, 1, 0);
	if(b == nil){
		/* ZZZ set error? */
		return -1;
	}

	if(packisect(is, b->data) < 0){
		seterr(ECorrupt, "can't make index section header: %r");
		freezblock(b);
		return -1;
	}
	if(writepart(is->part, PartBlank, b->data, HeadSize) < 0 || flushpart(is->part) < 0){
		seterr(EAdmin, "can't write index section header: %r");
		freezblock(b);
		return -1;
	}
	freezblock(b);

	return 0;
}
开发者ID:99years,项目名称:plan9,代码行数:25,代码来源:index.c

示例15: initisect

ISect*
initisect(Part *part)
{
	ISect *is;
	ZBlock *b;
	int ok;

	b = alloczblock(HeadSize, 0, 0);
	if(b == nil || readpart(part, PartBlank, b->data, HeadSize) < 0){
		seterr(EAdmin, "can't read index section header: %r");
		return nil;
	}

	is = MKZ(ISect);
	if(is == nil){
		freezblock(b);
		return nil;
	}
	is->part = part;
	ok = unpackisect(is, b->data);
	freezblock(b);
	if(ok < 0){
		seterr(ECorrupt, "corrupted index section header: %r");
		freeisect(is);
		return nil;
	}

	if(is->version != ISectVersion1 && is->version != ISectVersion2){
		seterr(EAdmin, "unknown index section version %d", is->version);
		freeisect(is);
		return nil;
	}

	return initisect1(is);
}
开发者ID:99years,项目名称:plan9,代码行数:35,代码来源:index.c


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