本文整理汇总了C++中rerrstr函数的典型用法代码示例。如果您正苦于以下问题:C++ rerrstr函数的具体用法?C++ rerrstr怎么用?C++ rerrstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rerrstr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: execproc
static void
execproc(void *a)
{
int i, fd;
Client *c;
char tmp[32];
c = a;
snprint(tmp, sizeof tmp, "execproc%d", c->num);
threadsetname(tmp);
if(pipe(c->fd) < 0){
rerrstr(c->err, sizeof c->err);
sendul(c->execpid, -1);
return;
}
rfork(RFFDG);
fd = c->fd[1];
close(c->fd[0]);
dup(fd, 0);
dup(fd, 1);
for(i=3; i<100; i++) /* should do better */
close(i);
strcpy(c->err, "exec failed");
procexecl(c->execpid, "/bin/rc", "rc", "-c", c->cmd, nil);
}
开发者ID:rminnich,项目名称:harvey,代码行数:25,代码来源:client.c
示例2: rremove
char *
rremove(Fid *f)
{
VacFile *vf, *vfp;
char errbuf[80];
char *err = nil;
if(!f->busy)
return vtstrdup(Enotexist);
vf = f->file;
vfp = vacfilegetparent(vf);
if(!permf(vfp, f->user, Pwrite)) {
err = Eperm;
goto Exit;
}
if(!vacfileremove(vf)) {
rerrstr(errbuf, sizeof errbuf);
err = errbuf;
}
Exit:
vacfiledecref(vfp);
rclunk(f);
return vtstrdup(err);
}
开发者ID:npe9,项目名称:harvey,代码行数:27,代码来源:vacfs.c
示例3: writethread
void
writethread(void *v)
{
WriteReq wr;
char err[ERRMAX];
USED(v);
while(recv(writechan, &wr) == 1){
nrecv++;
if(wr.p == nil)
break;
if(fastwrites && vtread(z, wr.score, wr.type, nil, 0) < 0){
rerrstr(err, sizeof err);
if(strstr(err, "read too small")){ /* already exists */
nskip++;
packetfree(wr.p);
continue;
}
}
if(vtwritepacket(z, wr.score, wr.type, wr.p) < 0)
sysfatal("vtwritepacket: %r");
packetfree(wr.p);
}
}
开发者ID:00001,项目名称:plan9port,代码行数:26,代码来源:vbackup.c
示例4: rread
char*
rread(Fid *f)
{
char *buf;
int64_t off;
int cnt;
VacFile *vf;
char err[80];
int n;
if(!f->busy)
return vtstrdup(Enotexist);
vf = f->file;
thdr.count = 0;
off = rhdr.offset;
buf = thdr.data;
cnt = rhdr.count;
if(f->qid.type & QTDIR)
n = vacdirread(f, buf, off, cnt);
else if(vacfilegetmode(f->file)&ModeDevice)
return vtstrdup("device");
else if(vacfilegetmode(f->file)&ModeLink)
return vtstrdup("symbolic link");
else if(vacfilegetmode(f->file)&ModeNamedPipe)
return vtstrdup("named pipe");
else
n = vacfileread(vf, buf, cnt, off);
if(n < 0) {
rerrstr(err, sizeof err);
return vtstrdup(err);
}
thdr.count = n;
return 0;
}
开发者ID:npe9,项目名称:harvey,代码行数:34,代码来源:vacfs.c
示例5: plumbopen
int
plumbopen(char *name, int omode)
{
int fd;
char buf[128], err[ERRMAX];
if(name[0] == '/')
return open(name, omode);
if(access("/mnt/plumb/send", AWRITE) < 0)
return -1;
snprint(buf, sizeof buf, "/mnt/plumb/%s", name);
fd = open(buf, omode);
if(fd >= 0)
return fd;
/* try creating port; used by non-standard plumb implementations */
rerrstr(err, sizeof err);
fd = create(buf, omode, 0600);
if(fd >= 0)
return fd;
errstr(err, sizeof err);
return -1;
}
开发者ID:grobe0ba,项目名称:plan9front,代码行数:26,代码来源:mesg.c
示例6: vtDial
VtSession *
vtDial(char *host, int canfail)
{
VtSession *z;
int fd;
char *na;
char e[ERRMAX];
if(host == nil)
host = getenv("venti");
if(host == nil)
host = "$venti";
if (host == nil) {
if (!canfail)
werrstr("no venti host set");
na = "";
fd = -1;
} else {
na = netmkaddr(host, 0, "venti");
fd = dial(na, 0, 0, 0);
}
if(fd < 0){
rerrstr(e, sizeof e);
if(!canfail){
vtSetError("venti dialstring %s: %s", na, e);
return nil;
}
}
z = vtClientAlloc();
if(fd < 0)
strcpy(z->fderror, e);
vtSetFd(z, fd);
return z;
}
开发者ID:aahud,项目名称:harvey,代码行数:35,代码来源:client.c
示例7: fsfauth_proxy
/*
* this just proxies what the factotum tells it to.
*/
AuthInfo*
fsfauth_proxy(CFid *fid, AuthRpc *rpc, AuthGetkey *getkey, char *params)
{
char *buf;
int m, n, ret;
AuthInfo *a;
char oerr[ERRMAX];
rerrstr(oerr, sizeof oerr);
werrstr("UNKNOWN AUTH ERROR");
if(dorpc(rpc, "start", params, strlen(params), getkey) != ARok){
werrstr("fauth_proxy start: %r");
return nil;
}
buf = malloc(AuthRpcMax);
if(buf == nil)
return nil;
for(;;){
switch(dorpc(rpc, "read", nil, 0, getkey)){
case ARdone:
free(buf);
a = auth_getinfo(rpc);
errstr(oerr, sizeof oerr); /* no error, restore whatever was there */
return a;
case ARok:
if(fswrite(fid, rpc->arg, rpc->narg) != rpc->narg){
werrstr("auth_proxy write fid: %r");
goto Error;
}
break;
case ARphase:
n = 0;
memset(buf, 0, AuthRpcMax);
while((ret = dorpc(rpc, "write", buf, n, getkey)) == ARtoosmall){
if(atoi(rpc->arg) > AuthRpcMax)
break;
m = fsread(fid, buf+n, atoi(rpc->arg)-n);
if(m <= 0){
if(m == 0)
werrstr("auth_proxy short read: %s", buf);
goto Error;
}
n += m;
}
if(ret != ARok){
werrstr("auth_proxy rpc write: %s: %r", buf);
goto Error;
}
break;
default:
werrstr("auth_proxy rpc: %r");
goto Error;
}
}
Error:
free(buf);
return nil;
}
开发者ID:00001,项目名称:plan9port,代码行数:63,代码来源:auth_proxy.c
示例8: rattach
char*
rattach(Fid *f)
{
/* no authentication for the momment */
VacFile *file;
char err[80];
file = vacfsgetroot(fs);
if(file == nil) {
rerrstr(err, sizeof err);
return vtstrdup(err);
}
f->busy = 1;
f->file = file;
f->qid.path = vacfilegetid(f->file);
f->qid.vers = 0;
f->qid.type = QTDIR;
thdr.qid = f->qid;
if(rhdr.uname[0])
f->user = vtstrdup(rhdr.uname);
else
f->user = "none";
return 0;
}
开发者ID:npe9,项目名称:harvey,代码行数:25,代码来源:vacfs.c
示例9: geterrstr
char*
geterrstr(void)
{
static char errbuf[ERRMAX];
rerrstr(errbuf, sizeof errbuf);
return errbuf;
}
开发者ID:rminnich,项目名称:harvey,代码行数:8,代码来源:main.c
示例10: responderror
void
responderror(Req *r)
{
char errbuf[ERRMAX];
rerrstr(errbuf, sizeof errbuf);
respond(r, errbuf);
}
开发者ID:99years,项目名称:plan9,代码行数:8,代码来源:srv.c
示例11: errfmt
int
errfmt(Fmt *f)
{
char buf[ERRMAX];
rerrstr(buf, sizeof buf);
return _fmtcpy(f, buf, utflen(buf), strlen(buf));
}
开发者ID:8l,项目名称:inferno,代码行数:8,代码来源:errfmt.c
示例12: wasintr
static int
wasintr(void)
{
char err[64];
rerrstr(err, sizeof err);
return strstr(err, "interrupt") != 0;
}
开发者ID:aahud,项目名称:harvey,代码行数:8,代码来源:ssh1.c
示例13: responderrstr
void
responderrstr(Req *r)
{
char err[ERRMAX];
rerrstr(err, sizeof err);
respond(r, err);
}
开发者ID:00001,项目名称:plan9port,代码行数:8,代码来源:main.c
示例14: smtpdial
/* Taken from imapdial, replaces tlsclient call with stunnel */
static int
smtpdial(char *server)
{
int p[2];
int fd[3];
char *tmp;
char *fpath;
if(pipe(p) < 0)
return -1;
fd[0] = dup(p[0], -1);
fd[1] = dup(p[0], -1);
fd[2] = dup(2, -1);
#ifdef PLAN9PORT
tmp = smprint("%s:587", server);
fpath = searchpath("stunnel3");
if (!fpath) {
werrstr("stunnel not found. it is required for tls support.");
return -1;
}
if(threadspawnl(fd, fpath, "stunnel", "-n", "smtp" , "-c", "-r", tmp, nil) < 0) {
#else
tmp = smprint("tcp!%s!587", server);
if(threadspawnl(fd, "/bin/tlsclient", "tlsclient", tmp, nil) < 0){
#endif
free(tmp);
close(p[0]);
close(p[1]);
close(fd[0]);
close(fd[1]);
close(fd[2]);
return -1;
}
free(tmp);
close(p[0]);
return p[1];
}
int
mxdial(char *addr, char *ddomain, char *gdomain)
{
int fd;
DS ds;
char err[Errlen];
addr = netmkaddr(addr, 0, "smtp");
dial_string_parse(addr, &ds);
/* try connecting to destination or any of it's mail routers */
fd = callmx(&ds, addr, ddomain);
/* try our mail gateway */
rerrstr(err, sizeof(err));
if(fd < 0 && gdomain && strstr(err, "can't translate") != 0)
fd = dial(netmkaddr(gdomain, 0, "smtp"), 0, 0, 0);
return fd;
}
开发者ID:9fans,项目名称:plan9port,代码行数:59,代码来源:mxdial.c
示例15: xioproc
static void
xioproc(void *a)
{
Channel *c;
Ioproc *io;
Iocall *r;
c = a;
if(io = mallocz(sizeof(*io), 1)){
char buf[128];
/*
* open might fail, ignore it for programs like factotum
* that don't use iointerrupt() anyway.
*/
snprint(buf, sizeof(buf), "/proc/%d/ctl", getpid());
io->ctl = open(buf, OWRITE);
if((io->creply = chancreate(sizeof(void*), 0)) == nil){
if(io->ctl >= 0)
close(io->ctl);
free(io);
io = nil;
} else
io->c = c;
}
while(send(c, &io) < 0)
;
if(io == nil)
return;
for(;;){
while(recv(io->c, &r) < 0)
;
if(r == 0)
break;
if(io->intr){
r->ret = -1;
strcpy(r->err, "interrupted");
} else if((r->ret = r->op(&r->arg)) < 0)
rerrstr(r->err, sizeof r->err);
qlock(io);
if(io->intr){
io->intr = 0;
if(io->ctl >= 0)
write(io->ctl, "nointerrupt", 11);
}
while(send(io->creply, &r) < 0)
;
qunlock(io);
}
if(io->ctl >= 0)
close(io->ctl);
chanfree(io->c);
chanfree(io->creply);
free(io);
}
开发者ID:grobe0ba,项目名称:plan9front,代码行数:58,代码来源:ioproc.c
示例16: rcreate
char*
rcreate(Fid* fid)
{
VacFile *vf;
uint32_t mode;
if(fid->open)
return vtstrdup(Eisopen);
if(!fid->busy)
return vtstrdup(Enotexist);
if(fs->mode & ModeSnapshot)
return vtstrdup(Erdonly);
vf = fid->file;
if(!vacfileisdir(vf))
return vtstrdup(Enotdir);
if(!permf(vf, fid->user, Pwrite))
return vtstrdup(Eperm);
mode = rhdr.perm & 0777;
if(rhdr.perm & DMDIR){
if((rhdr.mode & OTRUNC) || (rhdr.perm & DMAPPEND))
return vtstrdup(Emode);
switch(rhdr.mode & OPERM){
default:
return vtstrdup(Emode);
case OEXEC:
case OREAD:
break;
case OWRITE:
case ORDWR:
return vtstrdup(Eperm);
}
mode |= ModeDir;
}
vf = vacfilecreate(vf, rhdr.name, mode);
if(vf == nil) {
char err[80];
rerrstr(err, sizeof err);
return vtstrdup(err);
}
vacfiledecref(fid->file);
fid->file = vf;
fid->qid.type = QTFILE;
if(vacfileisdir(vf))
fid->qid.type = QTDIR;
fid->qid.vers = vacfilegetmcount(vf);
fid->qid.path = vacfilegetid(vf);
thdr.qid = fid->qid;
thdr.iounit = messagesize - IOHDRSZ;
return 0;
}
开发者ID:npe9,项目名称:harvey,代码行数:57,代码来源:vacfs.c
示例17: xopenfd
int
xopenfd(Msg *m)
{
char errs[ERRMAX];
int n, p[2];
Conn *nc;
if(pipe(p) < 0){
rerrstr(errs, sizeof errs);
err(m, errs);
/* XXX return here? */
}
if(verbose) fprint(2, "%T xopen pipe %d %d...", p[0], p[1]);
/* now we're committed. */
/* a new connection for this fid */
nc = emalloc(sizeof(Conn));
nc->internal = chancreate(sizeof(void*), 0);
/* a ref for us */
nc->fdfid = m->fid;
m->fid->ref++;
nc->fdfid->openfd++;
nc->fdmode = m->tx.mode;
nc->fd = p[0];
/* a thread to tend the pipe */
threadcreate(openfdthread, nc, STACK);
/* if mode is ORDWR, that openfdthread will write; start a reader */
if((m->tx.mode&3) == ORDWR){
nc = emalloc(sizeof(Conn));
nc->internal = chancreate(sizeof(void*), 0);
nc->fdfid = m->fid;
m->fid->ref++;
nc->fdfid->openfd++;
nc->fdmode = OREAD;
nc->fd = dup(p[0], -1);
threadcreate(openfdthread, nc, STACK);
}
/* steal fid from other connection */
if(delhash(m->c->fid, m->fid->cfid, m->fid) == 0)
fidput(m->fid);
/* rewrite as Ropenfd */
m->rx.type = Ropenfd;
n = GBIT32(m->rpkt);
m->rpkt = erealloc(m->rpkt, n+4);
PBIT32(m->rpkt+n, p[1]);
n += 4;
PBIT32(m->rpkt, n);
m->rpkt[4] = Ropenfd;
m->rx.unixfd = p[1];
return 0;
}
开发者ID:00001,项目名称:plan9port,代码行数:57,代码来源:9pserve.c
示例18: main
void
main(int argc, char **argv)
{
int bytes, fd, i;
char now[30];
char *deliveredto;
Addr *a;
Mlock *l;
ARGBEGIN{
}ARGEND;
if(argc != 3)
usage();
deliveredto = strrchr(argv[0], '!');
if(deliveredto == nil)
deliveredto = argv[0];
else
deliveredto++;
a = readaddrs(argv[1], nil);
if(a == nil)
sysfatal("missing from address");
l = syslock(argv[2]);
/* append to mbox */
i = 0;
retry:
fd = open(argv[2], OWRITE);
if(fd < 0){
rerrstr(now, sizeof(now));
if(strstr(now, "exclusive lock") && i++ < 20){
sleep(500); /* wait for lock to go away */
goto retry;
}
sysfatal("opening mailbox: %r");
}
seek(fd, 0, 2);
strncpy(now, ctime(time(0)), sizeof(now));
now[28] = 0;
if(fprint(fd, "From %s %s\n", a->val, now) < 0)
sysfatal("writing mailbox: %r");
/* copy message handles escapes and any needed new lines */
bytes = appendfiletombox(0, fd);
if(bytes < 0)
sysfatal("writing mailbox: %r");
close(fd);
sysunlock(l);
/* log it */
syslog(0, "mail", "delivered %s From %s %s (%s) %d", deliveredto,
a->val, now, argv[0], bytes);
exits(0);
}
开发者ID:99years,项目名称:plan9,代码行数:57,代码来源:deliver.c
示例19: responderrstr
static void
responderrstr(Req *r)
{
char e[ERRMAX];
*e = 0;
rerrstr(e, sizeof e);
respond(r, e);
}
开发者ID:Nurb432,项目名称:plan9front,代码行数:9,代码来源:main.c
示例20: errstr
void
errstr(char *buf, int n) {
char tmp[IXP_ERRMAX];
strncpy(tmp, buf, sizeof tmp);
rerrstr(buf, n);
strncpy(thread->errbuf(), tmp, IXP_ERRMAX);
errno = EPLAN9;
}
开发者ID:bartman,项目名称:libixp,代码行数:9,代码来源:error.c
注:本文中的rerrstr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论