本文整理汇总了C++中rerrstr函数的典型用法代码示例。如果您正苦于以下问题:C++ rerrstr函数的具体用法?C++ rerrstr怎么用?C++ rerrstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rerrstr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例9: geterrstr
char*
geterrstr(void)
{
static char errbuf[ERRMAX];
rerrstr(errbuf, sizeof errbuf);
return errbuf;
}
示例10: responderror
void
responderror(Req *r)
{
char errbuf[ERRMAX];
rerrstr(errbuf, sizeof errbuf);
respond(r, errbuf);
}
示例11: errfmt
int
errfmt(Fmt *f)
{
char buf[ERRMAX];
rerrstr(buf, sizeof buf);
return _fmtcpy(f, buf, utflen(buf), strlen(buf));
}
示例12: wasintr
static int
wasintr(void)
{
char err[64];
rerrstr(err, sizeof err);
return strstr(err, "interrupt") != 0;
}
示例13: responderrstr
void
responderrstr(Req *r)
{
char err[ERRMAX];
rerrstr(err, sizeof err);
respond(r, err);
}
示例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;
}
示例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);
}