本文整理汇总了C++中s_append函数的典型用法代码示例。如果您正苦于以下问题:C++ s_append函数的具体用法?C++ s_append怎么用?C++ s_append使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了s_append函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rcptto
/*
* report a recipient to remote
*/
char *
rcptto(char *to)
{
String *s;
s = unescapespecial(bangtoat(to));
if(toline == 0)
toline = s_new();
else
s_append(toline, ", ");
s_append(toline, s_to_c(s));
if(strchr(s_to_c(s), '@'))
dBprint("RCPT TO:<%s>\r\n", s_to_c(s));
else {
s_append(toline, "@");
s_append(toline, ddomain);
dBprint("RCPT TO:<%[email protected]%s>\r\n", s_to_c(s), ddomain);
}
alarm(10*alarmscale);
switch(getreply()){
case 2:
break;
case 5:
return Giveup;
default:
return Retry;
}
return 0;
}
示例2: ztns_append_bool
int
ztns_append_bool (ztns_t *self, bool data)
{
if (data)
return s_append (self, "true", '!');
return s_append (self, "false", '!');
}
示例3: return
FUNCTION COUNT t_highlight
(
TEXT string[] /* in/out: string to highlight */
)
{
TEXT local[STRINGSIZ+1];
/*
* t_highlight has a conceptual problem in unix: the escape
* sequences in the termcap file have numeric prefixes indicating
* the number of milliseconds delay required for highlighting.
* Such delays are normally interpreted by tputs, for example
* see t_clear. With the TAE highlight concept--i.e., surrounding
* a string with escape sequence and letting the user
* subsequently write the string with t_write/t_output--we
* never have the opportunity to call tputs to interpret the
* delays.
*
* Our approach is to strip the highlighting escape
* sequence of this delay element during the initialization
* phase. See t_init() above.
*/
if (stand_out1 == NULL || stand_out2 == NULL)
return(0);
s_copy (string, local); /* local copy */
s_copy(stand_out1, string);
s_append(local, string);
s_append(stand_out2, string);
return (s_length(stand_out1) + s_length(stand_out2));
}
示例4: s_copy
FUNCTION VOID synerr
(
FAST struct SYNBLK *sb, /* in/out: syntax block */
FAST TEXT *es /* in: error message string */
#define NERRCH 10 /* dump 10 chars of surrounding text */
)
{
FAST COUNT i;
TEXT txt[NERRCH+1]; /* buffer to hold surrounding text */
for (i=0; *es != 0; es++, i++) /* copy caller's string */
{
if (i == EMSIZ - (NERRCH+sizeof(" at or near ")+2) )
break; /* don't wipe out */
(*sb).errmsg[i] = *es; /* move caller's string to block */
}
s_copy(" at or near ", &(*sb).errmsg[i]);
errstr(sb, NERRCH, txt); /* get text surrounding error */
s_append("'", (*sb).errmsg); /* enclose in tick marks */
s_append(txt, (*sb).errmsg); /* append text to EM */
s_append("'", (*sb).errmsg);
return;
}
示例5: file_path_build
void file_path_build( t_file *file)
{
int c = 0;
char path[_PATH_];
bzero( path, _PATH_);
if( file->path_type == PATH_RELATIVE)
{
path[0] = '.';
c++;
}
else if( file->path_type == PATH_ABSOLUTE)
{
path[0] = '/';
c++;
}
int i;
for( i = 0; i <= file->dir_count; i++)
{
c = s_append( path, file->dirs[i], c);
c = s_append( path, "/", c);
}
s_cp( file->path, path, _PATH_);
}
示例6: putfullname
/*
* if name is int32_ter than Namsiz bytes, try to split it at a slash and fit the
* pieces into hp->prefix and hp->name.
*/
static int
putfullname(Hdr *hp, char *name)
{
int namlen, pfxlen;
char *sl, *osl;
String *slname = nil;
if (isdir(hp)) {
slname = s_new();
s_append(slname, name);
s_append(slname, "/"); /* posix requires this */
name = s_to_c(slname);
}
namlen = strlen(name);
if (namlen <= Namsiz) {
strncpy(hp->name, name, Namsiz);
hp->prefix[0] = '\0'; /* ustar paranoia */
return 0;
}
if (!posix || namlen > Maxname) {
fprint(2, "%s: name too int32_t for tar header: %s\n",
argv0, name);
return -1;
}
/*
* try various splits until one results in pieces that fit into the
* appropriate fields of the header. look for slashes from right
* to left, in the hopes of putting the largest part of the name into
* hp->prefix, which is larger than hp->name.
*/
sl = strrchr(name, '/');
while (sl != nil) {
pfxlen = sl - name;
if (pfxlen <= sizeof hp->prefix && namlen-1 - pfxlen <= Namsiz)
break;
osl = sl;
*osl = '\0';
sl = strrchr(name, '/');
*osl = '/';
}
if (sl == nil) {
fprint(2, "%s: name can't be split to fit tar header: %s\n",
argv0, name);
return -1;
}
*sl = '\0';
strncpy(hp->prefix, name, sizeof hp->prefix);
*sl++ = '/';
strncpy(hp->name, sl, sizeof hp->name);
if (slname)
s_free(slname);
return 0;
}
示例7: cat_mail
/* dispose of local addresses */
int
cat_mail(dest *dp, message *mp)
{
Biobuf *fp;
char *rcvr, *cp;
Mlock *l;
String *tmp, *s;
int i, n;
s = unescapespecial(s_clone(dp->repl1));
if (nflg) {
if(!xflg)
print("cat >> %s\n", s_to_c(s));
else
print("%s\n", s_to_c(dp->addr));
s_free(s);
return 0;
}
for(i = 0;; i++){
l = syslock(s_to_c(s));
if(l == 0)
return refuse(dp, mp, "can't lock mail file", 0, 0);
fp = sysopen(s_to_c(s), "al", MBOXMODE);
if(fp)
break;
tmp = s_append(0, s_to_c(s));
s_append(tmp, ".tmp");
fp = sysopen(s_to_c(tmp), "al", MBOXMODE);
if(fp){
syslog(0, "mail", "error: used %s", s_to_c(tmp));
s_free(tmp);
break;
}
s_free(tmp);
sysunlock(l);
if(i >= 5)
return refuse(dp, mp, "mail file cannot be opened", 0, 0);
sleep(1000);
}
s_free(s);
n = m_print(mp, fp, (char *)0, 1);
if (Bprint(fp, "\n") < 0 || Bflush(fp) < 0 || n < 0){
sysclose(fp);
sysunlock(l);
return refuse(dp, mp, "error writing mail file", 0, 0);
}
sysclose(fp);
sysunlock(l);
rcvr = s_to_c(dp->addr);
if(cp = strrchr(rcvr, '!'))
rcvr = cp+1;
logdelivery(dp, rcvr, mp);
return 0;
}
示例8: unixpath
/*
* walk up the tree building a Unix style path
*/
static void
unixpath(Node *node, String *path)
{
if(node == node->parent){
s_append(path, s_to_c(remrootpath));
return;
}
unixpath(node->parent, path);
if(s_len(path) > 0 && strcmp(s_to_c(path), "/") != 0)
s_append(path, "/");
s_append(path, s_to_c(node->remname));
}
示例9: mvspath
/*
* walk up the tree building a MVS style path
*/
static void
mvspath(Node *node, String *path)
{
if(node == node->parent){
s_append(path, s_to_c(remrootpath));
return;
}
mvspath(node->parent, path);
if(s_len(path) > 0)
s_append(path, ".");
s_append(path, s_to_c(node->remname));
}
示例10: simplify
/*
* simplify an address, reduce to a domain
*/
static String*
simplify(char *addr)
{
int dots, dotlim;
char *p, *at;
String *s;
mklower(addr);
at = strchr(addr, '@');
if(at == nil){
/* local address, make it an exact match */
s = s_copy("=");
s_append(s, addr);
return s;
}
/* copy up to, and including, the '@' sign */
at++;
s = s_copy("~");
for(p = addr; p < at; p++){
if(strchr(".*+?(|)\\[]^$", *p))
s_putc(s, '\\');
s_putc(s, *p);
}
/*
* just any address matching the two most significant domain elements,
* except for .uk, which needs three.
*/
s_append(s, "(.*\\.)?");
p = addr+strlen(addr); /* point at NUL */
if (p[-1] == '.')
*--p = '\0';
if (p - addr > 3 && strcmp(".uk", p - 3) == 0)
dotlim = 3;
else
dotlim = 2;
dots = 0;
while(--p > at)
if(*p == '.' && ++dots >= dotlim){
p++;
break;
}
for(; *p; p++){
if(strchr(".*+?(|)\\[]^$", *p) != nil)
s_putc(s, '\\');
s_putc(s, *p);
}
s_terminate(s);
return s;
}
示例11: du
vlong
du(char *name, Dir *dir)
{
int fd, i, n;
Dir *buf, *d;
String *file;
vlong nk, t;
if(dir == nil)
return warn(name);
if((dir->qid.type&QTDIR) == 0)
return dirval(dir, blkmultiple(dir->length));
fd = open(name, OREAD);
if(fd < 0)
return warn(name);
nk = 0;
while((n=dirread(fd, &buf)) > 0) {
d = buf;
for(i = n; i > 0; i--, d++) {
if((d->qid.type&QTDIR) == 0) {
nk += dufile(name, d);
continue;
}
if(strcmp(d->name, ".") == 0 ||
strcmp(d->name, "..") == 0 ||
/* !readflg && */ seen(d))
continue; /* don't get stuck */
file = s_copy(name);
s_append(file, "/");
s_append(file, d->name);
t = du(s_to_c(file), d);
nk += t;
t = dirval(d, t);
if(!sflag)
printamt(t, s_to_c(file));
s_free(file);
}
free(buf);
}
if(n < 0)
warn(name);
close(fd);
return dirval(dir, nk);
}
示例12: fixrouteaddr
/*
* ensure route addr has brackets around it
*/
String*
fixrouteaddr(String *raddr, Node *next, Node *last)
{
String *a;
if(last && last->c == '<' && next && next->c == '>')
return raddr; /* properly formed already */
a = s_new();
s_append(a, "<");
s_append(a, s_to_c(raddr));
s_append(a, ">");
s_free(raddr);
return a;
}
示例13: mailerpath
/*
* create abs path of the mailer
*/
String*
mailerpath(char *p)
{
String *s;
if(p == nil)
return nil;
if(*p == '/')
return s_copy(p);
s = s_new();
s_append(s, UPASBIN);
s_append(s, "/");
s_append(s, p);
return s;
}
示例14: rule_parse
/*
* Get the next token from `line'. The symbol `\l' is replaced by
* the name of the local system.
*/
extern String *
rule_parse(String *line, char *system, int *backl)
{
String *token;
String *expanded;
char *cp;
token = s_parse(line, 0);
if(token == 0)
return(token);
if(strchr(s_to_c(token), '\\')==0)
return(token);
expanded = s_new();
for(cp = s_to_c(token); *cp; cp++) {
if(*cp == '\\') switch(*++cp) {
case 'l':
s_append(expanded, system);
*backl = 1;
break;
case '\\':
s_putc(expanded, '\\');
break;
default:
s_putc(expanded, '\\');
s_putc(expanded, *cp);
break;
} else
s_putc(expanded, *cp);
}
s_free(token);
s_terminate(expanded);
return(expanded);
}
示例15: keeplockalive
/*
* like trylock, but we've already got the lock on fd,
* and don't want an L. lock file.
*/
static Mlock *
keeplockalive(char *path, int fd)
{
char buf[1];
Mlock *l;
l = malloc(sizeof(Mlock));
if(l == 0)
return 0;
l->fd = fd;
l->name = s_new();
s_append(l->name, path);
/* fork process to keep lock alive until sysunlock(l) */
switch(l->pid = rfork(RFPROC)){
default:
break;
case 0:
fd = l->fd;
for(;;){
sleep(1000*60);
if(pread(fd, buf, 1, 0) < 0)
break;
}
_exits(0);
}
return l;
}