本文整理汇总了C++中s_append函数的典型用法代码示例。如果您正苦于以下问题:C++ s_append函数的具体用法?C++ s_append怎么用?C++ s_append使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了s_append函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:grobe0ba,项目名称:plan9front,代码行数:32,代码来源:smtp.c
示例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", '!');
}
开发者ID:HughPowell,项目名称:ztnetstring,代码行数:7,代码来源:ztns_impl.c
示例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));
}
开发者ID:E-LLP,项目名称:VICAR,代码行数:31,代码来源:terminal.np.c
示例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;
}
开发者ID:E-LLP,项目名称:VICAR,代码行数:26,代码来源:syntax.c
示例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_);
}
开发者ID:colinbouvry,项目名称:minuit,代码行数:25,代码来源:file.c
示例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;
}
开发者ID:aahud,项目名称:harvey,代码行数:59,代码来源:tar.c
示例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;
}
开发者ID:00001,项目名称:plan9port,代码行数:56,代码来源:cat_mail.c
示例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));
}
开发者ID:99years,项目名称:plan9,代码行数:15,代码来源:proto.c
示例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));
}
开发者ID:99years,项目名称:plan9,代码行数:15,代码来源:proto.c
示例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;
}
开发者ID:AustenConrad,项目名称:plan-9,代码行数:55,代码来源:list.c
示例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);
}
开发者ID:carriercomm,项目名称:plan9-gpl,代码行数:50,代码来源:du.c
示例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;
}
开发者ID:grobe0ba,项目名称:plan9front,代码行数:18,代码来源:smtp.c
示例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;
}
开发者ID:99years,项目名称:plan9,代码行数:18,代码来源:smtpd.c
示例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);
}
开发者ID:00001,项目名称:plan9port,代码行数:37,代码来源:rewrite.c
示例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;
}
开发者ID:99years,项目名称:plan9,代码行数:32,代码来源:runq.c
示例16: s_appendsub
String*
s_appendsub(String *s, char *p, int n, Sub *sub, int nsub)
{
int i, m;
char *q, *r, *ep;
ep = p+n;
while(p<ep){
q = ep;
m = -1;
for(i=0; i<nsub; i++){
if(sub[i].sub && (r = strstr(p, sub[i].match)) && r < q){
q = r;
m = i;
}
}
s = s_nappend(s, p, q-p);
p = q;
if(m >= 0){
s = s_append(s, sub[m].sub);
p += strlen(sub[m].match);
}
}
return s;
}
开发者ID:99years,项目名称:plan9,代码行数:25,代码来源:util.c
示例17: simplify
/*
* simplify an address, reduce to a domain
*/
static String*
simplify(char *addr)
{
int dots;
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 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 */
s_append(s, "(.*\\.)?");
p = addr+strlen(addr);
dots = 0;
for(; p > at; p--){
if(*p != '.')
continue;
if(dots++ > 0){
p++;
break;
}
}
for(; *p; p++){
if(strchr(".*+?(|)\\[]^$", *p) != 0)
s_putc(s, '\\');
s_putc(s, *p);
}
s_terminate(s);
return s;
}
开发者ID:00001,项目名称:plan9port,代码行数:49,代码来源:list.c
示例18: smbremovefile
int
smbremovefile(SmbTree *t, char *dir, char *name)
{
String *s;
int rv;
s = s_new();
s_append(s, t->serv->path);
s_append(s, "/");
if (dir) {
s_append(s, dir);
s_append(s, "/");
}
s_append(s, name);
rv = remove(s_to_c(s));
s_free(s);
return rv;
}
开发者ID:Requaos,项目名称:harvey,代码行数:17,代码来源:smbcomdelete.c
示例19: default_from
extern int
default_from(message *mp)
{
char *cp, *lp;
cp = getenv("upasname");
lp = getlog();
if(lp == nil)
return -1;
if(cp && *cp)
s_append(mp->sender, cp);
else
s_append(mp->sender, lp);
s_append(mp->date, thedate());
return 0;
}
开发者ID:99years,项目名称:plan9,代码行数:17,代码来源:message.c
示例20: translate
/* loop through the translation files */
static int
translate(char *name, /* name to translate */
char **namev, /* names of this system */
String *files, /* names of system alias files */
String *alias) /* where to put the alias */
{
String *file = s_new();
String **fullnamev;
int n, rv;
rv = -1;
DEBUG print("translate(%s, %s, %s)\n", name,
s_to_c(files), s_to_c(alias));
/* create the full name to avoid loops (system!name) */
for(n = 0; namev[n]; n++)
;
fullnamev = (String**)malloc(sizeof(String*)*(n+2));
n = 0;
fullnamev[n++] = s_copy(name);
for(; *namev; namev++){
fullnamev[n] = s_copy(*namev);
s_append(fullnamev[n], "!");
s_append(fullnamev[n], name);
n++;
}
fullnamev[n] = 0;
/* look at system-wide names */
s_restart(files);
while (s_parse(files, s_restart(file)) != 0) {
if (lookup(fullnamev, file, alias)==0) {
rv = 0;
goto out;
}
}
out:
for(n = 0; fullnamev[n]; n++)
s_free(fullnamev[n]);
s_free(file);
free(fullnamev);
return rv;
}
开发者ID:npe9,项目名称:harvey,代码行数:46,代码来源:aliasmail.c
注:本文中的s_append函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论