本文整理汇总了C++中seterror函数的典型用法代码示例。如果您正苦于以下问题:C++ seterror函数的具体用法?C++ seterror怎么用?C++ seterror使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了seterror函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: syn0
/*
* syn0
* syn1
* syn1 & syntax
*/
static struct command *
syn0(struct wordent *p1, struct wordent *p2, int flags)
{
struct wordent *p;
struct command *t, *t1;
int l;
l = 0;
for (p = p1; p != p2; p = p->next)
switch (p->word[0]) {
case '(':
l++;
continue;
case ')':
l--;
if (l < 0)
seterror(ERR_TOOMANYRP);
continue;
case '|':
if (p->word[1] == '|')
continue;
/* fall into ... */
case '>':
if (p->next != p2 && eq(p->next->word, STRand))
p = p->next;
continue;
case '&':
if (l != 0)
break;
if (p->word[1] == '&')
continue;
t1 = syn1(p1, p, flags);
if (t1->t_dtyp == NODE_LIST ||
t1->t_dtyp == NODE_AND ||
t1->t_dtyp == NODE_OR) {
t = (struct command *) xcalloc(1, sizeof(*t));
t->t_dtyp = NODE_PAREN;
t->t_dflg = F_AMPERSAND | F_NOINTERRUPT;
t->t_dspr = t1;
t1 = t;
}
else
t1->t_dflg |= F_AMPERSAND | F_NOINTERRUPT;
t = (struct command *) xcalloc(1, sizeof(*t));
t->t_dtyp = NODE_LIST;
t->t_dflg = 0;
t->t_dcar = t1;
t->t_dcdr = syntax(p, p2, flags);
return (t);
}
if (l == 0)
return (syn1(p1, p2, flags));
seterror(ERR_TOOMANYLP);
return (0);
}
开发者ID:jyin0813,项目名称:OpenBSD-src,代码行数:65,代码来源:parse.c
示例2: fopen
// 输入文件
bool myflexer::inputfile(const char * filename)
{
m_filename = filename;
FILE * file = fopen(filename, "r");
if (!file)
{
seterror(m_fk, efk_open_file_fail, "open %s fail", filename);
return false;
}
int8_t readbuff[100];
size_t len = 0;
while (!feof(file))
{
len = fread((void*)readbuff, 1, sizeof(readbuff)-1, file);
readbuff[len] = 0;
m_content += (char *)readbuff;
}
fclose(file);
if (m_content.empty())
{
seterror(m_fk, efk_open_file_empty, "open %s empty", filename);
return false;
}
m_num = m_content.size();
m_pos = 0;
return true;
}
开发者ID:swizl,项目名称:fakescript,代码行数:33,代码来源:myflexer.cpp
示例3: initread
int initread(int fdread, int fdwrite, int signo, char *buf, int bufsize) {
int error;
sigset_t oldset, fullset;
if ((sigfillset(&fullset) == -1) ||
(sigprocmask(SIG_SETMASK, &fullset, &oldset) == -1)) {
seterror(errno);
return -1;
}
aiocb.aio_fildes = fdread; /* set up structure */
aiocb.aio_offset = 0;
aiocb.aio_buf = (void *)buf;
aiocb.aio_nbytes = bufsize;
aiocb.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
aiocb.aio_sigevent.sigev_signo = signo;
aiocb.aio_sigevent.sigev_value.sival_ptr = &aiocb;
fdout = fdwrite;
doneflag = 0;
globalerror = 0;
totalbytes = 0;
error = readstart(); /* start first read */
if (sigprocmask(SIG_SETMASK, &oldset, NULL) == -1) {
seterror(errno);
return -1;
}
return error;
}
开发者ID:KeyMaker13,项目名称:portfolio,代码行数:27,代码来源:asyncmonitorsignal.c
示例4: aiohandler
/* ARGSUSED */
static void aiohandler(int signo, siginfo_t *info, void *context) {
int myerrno, mystatus, serrno;
serrno = errno;
myerrno = aio_error(&aiocb_read);
if (myerrno == EINPROGRESS) {
errno = serrno;
return;
}
if (myerrno) {
seterror(myerrno);
errno = serrno;
return;
}
mystatus = aio_return(&aiocb_read);
totalbytes += mystatus;
aiocb_read.aio_offset += mystatus;
aiocb_write.aio_nbytes = mystatus;
if (mystatus == 0)
doneflag = 1;
else if (aio_write(&aiocb_write) == -1)
seterror(errno);
else if (readstart() == -1)
seterror(errno);
errno = serrno;
}
开发者ID:rootcanal,项目名称:USP-work,代码行数:26,代码来源:async_utils.c
示例5: gsopen
int
gsopen(Modem *m)
{
int n;
char bytes[Gshdrsize];
/*
* Is this gs output
*/
n = Bread(m->bp, bytes, Gshdrsize);
if(n != Gshdrsize)
return seterror(m, Esys);
if(bytes[0]!='\0' || strcmp(bytes+1, "PC Research, Inc")!=0){
Bseek(m->bp, 0, 0);
return seterror(m, Esys);
}
m->valid |= Vtype;
if(bytes[0x1d])
m->vr = 1;
else
m->vr = 0;
m->wd = 0;
m->ln = 2;
m->df = 0;
return Eok;
}
开发者ID:bhanug,项目名称:harvey,代码行数:27,代码来源:file.c
示例6: while
/* skip entries until found search or dict end. skipped does not include the found key */
bool TorrentBase::try_next_dict_entry(BufferString search, BufferString prev, bool &error, BufferString *skipped) {
size_t start = m_buffer.pos();
error = true;
if (m_buffer.pos() >= m_buffer.m_len) return seterror("expected dict, found eof");
BufferString cur;
while (m_buffer.m_data[m_buffer.pos()] != 'e') {
size_t curpos = m_buffer.pos();;
if (!read_utf8(cur)) return errorcontext("parsing dict key failed");
if (cur <= prev) return seterror("(previous) dict entries in wrong order");
if (cur == search) {
error = false;
if (0 != skipped) *skipped = BufferString(m_buffer.data() + start, curpos - start);
return true;
}
if (cur > search) {
m_buffer.m_pos = curpos;
error = false;
if (0 != skipped) *skipped = BufferString(m_buffer.data() + start, m_buffer.pos() - start);
return false;
}
prev = cur;
if (m_buffer.pos() >= m_buffer.m_len) return seterror("expected dict value, found eof");
if (!skip_value()) return errorcontext("parsing dict value failed");
if (m_buffer.pos() >= m_buffer.m_len) return seterror("expected dict entry or 'e', found eof");
}
/* dict end found, don't skip the 'e' */
error = false;
if (0 != skipped) *skipped = BufferString(m_buffer.data() + start, m_buffer.pos() - start);
return false;
}
开发者ID:naacu,项目名称:torrent-sanitize,代码行数:34,代码来源:torrentbase.cpp
示例7: fixDolMod
static void
fixDolMod(void)
{
int c;
c = DgetC(0);
if (c == ':') {
do {
c = DgetC(0), dolmcnt = 1, dolwcnt = 1;
if (c == 'g' || c == 'a') {
if (c == 'g')
dolmcnt = 10000;
else
dolwcnt = 10000;
c = DgetC(0);
}
if ((c == 'g' && dolmcnt != 10000) ||
(c == 'a' && dolwcnt != 10000)) {
if (c == 'g')
dolmcnt = 10000;
else
dolwcnt = 10000;
c = DgetC(0);
}
if (c == 's') { /* [eichin:19910926.0755EST] */
int delimcnt = 2;
int delim = DgetC(0);
dolmod[dolnmod++] = c;
dolmod[dolnmod++] = delim;
if (!delim || letter(delim)
|| Isdigit(delim) || any(" \t\n", delim)) {
seterror(ERR_BADSUBST);
break;
}
while ((c = DgetC(0)) != (-1)) {
dolmod[dolnmod++] = c;
if(c == delim) delimcnt--;
if(!delimcnt) break;
}
if(delimcnt) {
seterror(ERR_BADSUBST);
break;
}
continue;
}
if (!any("htrqxes", c))
stderror(ERR_BADMOD, c);
dolmod[dolnmod++] = c;
if (c == 'q')
dolmcnt = 10000;
}
while ((c = DgetC(0)) == ':');
unDredc(c);
}
else
unDredc(c);
}
开发者ID:radixo,项目名称:openbsd-src,代码行数:59,代码来源:dol.c
示例8: fixDolMod
static void
fixDolMod(void)
{
eChar c;
c = DgetC(0);
if (c == ':') {
do {
c = DgetC(0), dolmcnt = 1, dol_flag_a = 0;
if (c == 'g' || c == 'a') {
if (c == 'g')
dolmcnt = INT_MAX;
else
dol_flag_a = 1;
c = DgetC(0);
}
if ((c == 'g' && dolmcnt != INT_MAX) ||
(c == 'a' && dol_flag_a == 0)) {
if (c == 'g')
dolmcnt = INT_MAX;
else
dol_flag_a = 1;
c = DgetC(0);
}
if (c == 's') { /* [eichin:19910926.0755EST] */
int delimcnt = 2;
eChar delim = DgetC(0);
Strbuf_append1(&dolmod, (Char) c);
Strbuf_append1(&dolmod, (Char) delim);
if (delim == DEOF || !delim || letter(delim)
|| Isdigit(delim) || any(" \t\n", delim)) {
seterror(ERR_BADSUBST);
break;
}
while ((c = DgetC(0)) != DEOF) {
Strbuf_append1(&dolmod, (Char) c);
if(c == delim) delimcnt--;
if(!delimcnt) break;
}
if(delimcnt) {
seterror(ERR_BADSUBST);
break;
}
continue;
}
if (!any("luhtrqxes", c))
stderror(ERR_BADMOD, (int)c);
Strbuf_append1(&dolmod, (Char) c);
if (c == 'q')
dolmcnt = INT_MAX;
}
while ((c = DgetC(0)) == ':');
unDredc(c);
}
else
unDredc(c);
}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:59,代码来源:sh.dol.c
示例9: character
/* Receives bytes on a socket up to the first new-line character (\n)
or until the number of bytes received is equal to n-1, whichever
comes first. Stores the result in string and adds a null
character (\0) to the end of the string. If n is equal to 1, the
string is empty. Returns a pointer to the string buffer if successful.
A NULL return value indicates an error or that the connection is
closed.*/
char* XIOsocket::gets(char* buffer, unsigned int size)
{
unsigned int done = 0;
char* p = buffer;
DEBUGLOG(("XIOsocket(%p{%d})::gets(%p, %d)\n", this, s_handle, buffer, size));
while (done < size - 1)
{
#ifdef TCPV40HDRS
// Work around for missing SO_RCVTIMEO in 16 bit IP stack.
struct timeval timeout = {0};
timeout.tv_sec = xio_socket_timeout();
if (timeout.tv_sec)
{ fd_set waitlist;
FD_ZERO(&waitlist);
FD_SET (s_handle, &waitlist);
switch (select(s_handle+1, &waitlist, NULL, NULL, &timeout))
{ case 0: // Timeout
seterror(SOCETIMEDOUT);
return NULL;
case -1: // Error
seterror();
return NULL;
}
}
#endif
int rc = recv(s_handle, p, 1, 0);
if( rc == 1 )
{ if (*p == '\r')
continue;
else if(*p == '\n')
break;
else
{ ++p;
++done;
}
} else
{ DEBUGLOG(("XIOsocket::gets: error %d\n", sock_errno()));
if (!done)
{ if (rc == 0)
eof = true;
else
seterror();
return NULL;
} else
break;
}
}
*p = 0;
DEBUGLOG(("XIOsocket::gets: %s\n", buffer));
return buffer;
}
开发者ID:OS2World,项目名称:MM-SOUND-PM123,代码行数:63,代码来源:xio_socket.cpp
示例10: seterror
bool TorrentBase::skip_value() {
char c;
if (m_buffer.pos() >= m_buffer.m_len) return seterror("expected value, found eof");
c = m_buffer.m_data[m_buffer.pos()];
if (c >= '0' && c <= '9') return skip_string();
if (c == 'i') return skip_number();
if (c == 'l') return skip_list();
if (c == 'd') return skip_dict();
return seterror("expected value");
}
开发者ID:naacu,项目名称:torrent-sanitize,代码行数:10,代码来源:torrentbase.cpp
示例11: length
bool vectrex_cart_slot_device::call_load()
{
if (m_cart)
{
UINT32 size = (software_entry() == nullptr) ? length() : get_software_region_length("rom");
UINT8 *ROM;
if (size > 0x10000)
{
seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
return IMAGE_INIT_FAIL;
}
m_cart->rom_alloc((size < 0x1000) ? 0x1000 : size, tag());
ROM = m_cart->get_rom_base();
if (software_entry() == nullptr)
fread(ROM, size);
else
memcpy(ROM, get_software_region("rom"), size);
// Verify the file is accepted by the Vectrex bios
if (memcmp(ROM, "g GCE", 5))
{
seterror(IMAGE_ERROR_UNSPECIFIED, "Invalid image");
return IMAGE_INIT_FAIL;
}
// determine type
m_type = VECTREX_STD;
if (!memcmp(ROM + 0x06, "SRAM", 4))
m_type = VECTREX_SRAM;
if (size > 0x8000)
m_type = VECTREX_64K;
//printf("Type: %s\n", vectrex_get_slot(m_type));
// determine 3D setup (to help video setup at machine_start)
if (!memcmp(ROM + 0x11, "NARROW", 6) && (ROM[0x39] == 0x0c))
m_vec3d = VEC3D_NARROW;
if (!memcmp(ROM + 0x11, "CRAZY COASTER", 13))
m_vec3d = VEC3D_CCOAST;
if (!memcmp(ROM + 0x11, "3D MINE STORM", 13))
m_vec3d = VEC3D_MINEST;
return IMAGE_INIT_PASS;
}
return IMAGE_INIT_PASS;
}
开发者ID:BenjaminSiskoo,项目名称:mame,代码行数:52,代码来源:slot.cpp
示例12: read_string
bool TorrentBase::read_string(BufferString &str) {
char c;
int64_t pos = m_buffer.pos(), len = m_buffer.m_len;
int64_t slen = 0;
str.m_data = 0; str.m_len = 0;
if (pos >= len) return seterror("expected string length, found eof");
c = m_buffer.m_data[pos++];
if (c < '0' || c > '9') return seterror("expected digit for string length, found eof");
if (pos >= len) return seterror("expected string length, found eof");
if (c == '0' && m_buffer.m_data[pos] != ':') return seterror("expected string length, found leading zero of non zero length (no following ':')");
slen = (c - '0');
for (;;) {
c = m_buffer.m_data[pos++];
if (c == ':') break;
if (c < '0' || c > '9') return seterror("expected digit or colon for string length, found eof");
if (pos >= len) return seterror("expected string length, found eof");
if (slen > std::numeric_limits<int32_t>::max()) return seterror("string length overflow");
slen = 10*slen + (c - '0');
}
if (slen > len || slen > len - pos) return seterror("file not large enough for string length"); /* overflow */
str.m_data = m_buffer.m_data + pos;
str.m_len = slen;
m_buffer.m_pos = pos + slen;
return true;
}
开发者ID:naacu,项目名称:torrent-sanitize,代码行数:32,代码来源:torrentbase.cpp
示例13: assembler_get_classmem_call
variant * assembler_get_classmem_call(fake * fk, variant * classvar, variant * callpos)
{
bool err = false;
variant * n = fk->con.newvariant();
void * classptr = 0;
const char * classprefix = 0;
// prefix
V_GET_POINTER(classvar, classptr, classprefix);
if (UNLIKE(err))
{
return 0;
}
const char * funcname = 0;
V_GET_STRING(callpos, funcname);
if (UNLIKE(err))
{
return 0;
}
if (UNLIKE(!classptr))
{
err = true;
seterror(fk, efk_jit_error, fkgetcurfile(fk), fkgetcurline(fk), fkgetcurfunc(fk), "jit class mem call error, the class ptr is null, type %s", classprefix);
return 0;
}
// whole name
char wholename[MAX_FAKE_REG_FUNC_NAME_LEN];
if (UNLIKE(classvar->data.ponter->typesz + callpos->data.str->sz >= MAX_FAKE_REG_FUNC_NAME_LEN))
{
err = true;
seterror(fk, efk_jit_error, fkgetcurfile(fk), fkgetcurline(fk), fkgetcurfunc(fk), "jit class mem call error, the name is too long, func %s %s", classprefix, funcname);
return 0;
}
memcpy(wholename, classprefix, classvar->data.ponter->typesz);
memcpy(wholename + classvar->data.ponter->typesz, funcname, callpos->data.str->sz);
wholename[classvar->data.ponter->typesz + callpos->data.str->sz] = 0;
// call it
V_SET_STRING(n, wholename);
return n;
}
开发者ID:26597925,项目名称:fakescript,代码行数:48,代码来源:assembler.cpp
示例14: enqueue
int enqueue(queue_t *q, RTP_header *h, unsigned ft, unsigned char *p, unsigned l, unsigned scale)
{
unsigned j = 0;
double t = h->timestamp / (double)scale;
if (q->mode & MODE_STREAM || .99 * t <= curtime()) {
if (!lock(&q->lock)) return 0;
if (l > sizeof q->packets[q->s].p) goto PS;
while (j++ < q->n && q->packets[q->s].blocked) INC(q);
if (q->packets[q->s].blocked) goto PS;
q->packets[q->s].id = h->id;
q->packets[q->s].tstamp = t;
q->packets[q->s].frame = ft;
q->packets[q->s].size = l;
q->packets[q->s].next = 0;
q->packets[q->s].prev = 0;
q->packets[q->s].blocked = 1;
memcpy(q->packets[q->s].p, p, l);
addpacket(q, &q->packets[q->s]);
INC(q);
unlock(&q->lock);
return 1;
} else {
return 0;
}
PS: seterror(err_PS);
unlock(&q->lock);
return 0;
}
开发者ID:anthcp,项目名称:evalvid-2.7,代码行数:34,代码来源:queue.c
示例15: putmchar
int
putmchar(Modem *m, char *p)
{
if(write(m->fd, p, 1) < 0)
return seterror(m, Esys);
return Eok;
}
开发者ID:grobe0ba,项目名称:plan9front,代码行数:7,代码来源:modem.c
示例16: CallRemote
bool CallRemote(int handle, char s[])
{
if(handle < 0 || handle >= ObjectCount || stack[handle]->tag != LIST) return False;
if(seterror() == 0)
{
Cell *res, *params, *list = stack[handle];
list->left = template_nil;
push(list->right->right->left);
push(template_nil);
for(params=list->right; params->left->tag==LIST; params->left=params->left->right)
{
push(params->left->left);
make(LIST);
}
buildstring(s);
push(list->right->right->right->left);
make(APPLY);
make(APPLY);
make(APPLY);
eval();
res = pop();
list->right->right->left = res->left;
list->left = res->right->left;
return True;
}
else
{
setstackheight(ObjectCount);
stack[handle] = template_nil;
interrupted = False;
return False;
}
}
开发者ID:gezichtshaar,项目名称:amanda,代码行数:33,代码来源:amsyslib.c
示例17: Interpret
void Interpret(char expr[])
{
SetIntSignal(True);
if(commandline(expr))
;
else if(seterror()==0)
{
initstack();
restoretemplates();
CloseAllIOFiles();
interrupted = False;
if(parseinput(expr))
checkexpression(top(), True);
else
{
checkexpression(top(), False);
settop(modify_expression(top()));
starttiming();
toplevel();
stoptiming();
}
}
SetIntSignal(False);
initstack();
restoretemplates();
CloseAllIOFiles();
interrupted = False;
Write("\n");
}
开发者ID:gezichtshaar,项目名称:amanda,代码行数:29,代码来源:amsyslib.c
示例18: global_alloc
bool floppy_image_device::call_create(int format_type, option_resolution *format_options)
{
image = global_alloc(floppy_image(tracks, sides, form_factor));
output_format = 0;
// search for a suitable format based on the extension
for(floppy_image_format_t *i = fif_list; i; i = i->next)
{
// only consider formats that actually support saving
if(!i->supports_save())
continue;
if (i->extension_matches(basename()))
{
output_format = i;
break;
}
}
// did we find a suitable format?
if (output_format == 0)
{
seterror(IMAGE_ERROR_INVALIDIMAGE, "Unable to identify the image format");
return IMAGE_INIT_FAIL;
}
return IMAGE_INIT_PASS;
}
开发者ID:ValleyBell,项目名称:mame,代码行数:28,代码来源:floppy.c
示例19: DEBUGLOG
int XIOsocket::open(const char* uri, XOFLAGS oflags)
{ DEBUGLOG(("XIOsocket(%p)::open(%s, %x)\n", this, uri, oflags));
if (strnicmp(uri, "tcpip://", 8) == 0)
uri += 8;
const char* cp = strchr(uri, ':');
if (cp == NULL)
{ seterror(SOCESOCKTNOSUPPORT);
return -1;
}
char* host = (char*)alloca(cp-uri+1);
memcpy(host, uri, cp-uri);
host[cp-uri] = 0;
u_long address = get_address(host);
if (address == (u_long)-1L)
{ error = errno;
return -1;
}
int port = get_service(cp+1);
if (port == -1)
{ error = errno;
return -1;
}
error = 0;
return open(address, port);
}
开发者ID:OS2World,项目名称:MM-SOUND-PM123,代码行数:26,代码来源:xio_socket.cpp
示例20: zippath_fopen
floppy_image_format_t *floppy_image_device::identify(std::string filename)
{
core_file *fd;
std::string revised_path;
file_error err = zippath_fopen(filename.c_str(), OPEN_FLAG_READ, fd, revised_path);
if(err) {
seterror(IMAGE_ERROR_INVALIDIMAGE, "Unable to open the image file");
return 0;
}
io_generic io;
io.file = fd;
io.procs = &corefile_ioprocs_noclose;
io.filler = 0xff;
int best = 0;
floppy_image_format_t *best_format = 0;
for(floppy_image_format_t *format = fif_list; format; format = format->next) {
int score = format->identify(&io, form_factor);
if(score > best) {
best = score;
best_format = format;
}
}
core_fclose(fd);
return best_format;
}
开发者ID:ValleyBell,项目名称:mame,代码行数:27,代码来源:floppy.c
注:本文中的seterror函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论