本文整理汇总了C++中xstrcpy函数的典型用法代码示例。如果您正苦于以下问题:C++ xstrcpy函数的具体用法?C++ xstrcpy怎么用?C++ xstrcpy使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xstrcpy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printer_set
/* Set the value. */
static void
printer_set (struct printer *p,
const char * ppdkey, const char * command)
{
xstrcpy (p->ppdkey, ppdkey);
xstrcpy (p->command, command);
}
示例2: out_get_root
/*****************************************************************************
* Devide full outbound path on "root" directory, there other oubound
* directories created, and main outbound directory name
*
* Arguments:
* path pointer to the null-terminated outbound path string
* out_root pointer to the pointer for the resulting root directory
* out_main pointer to the pointer for the resulting main outbound
* name w/o path
*
* Return value:
* Zero on success (*out_root and *out_main must be freed)
*/
int out_get_root(const char *path, char **out_root, char **out_main)
{
char *p, *outb;
ASSERT(path != NULL && out_root != NULL && out_main != NULL);
*out_root = NULL;
*out_main = NULL;
outb = (char *)xstrcpy(path);
p = outb + strlen(outb) - 1;
if( *p == DIRSEPCHR )
*p = '\0';
/* Ohh.. where is no full path for outbound directory */
if( (p=strrchr(outb, DIRSEPCHR)) == NULL )
{
free(outb);
return -1;
}
*p = '\0';
*out_main = xstrcpy(p+1);
*out_root = xstrcat(outb, "/");
DEB((D_OUTBOUND, "out_getroot: out_root \"%s\", out_main \"%s\"",
*out_root, *out_main));
return 0;
}
示例3: irc_get_mask
char* irc_get_mask(char *buf, char *raw) {
char *data;
char *seperateFrmSp;
char *mask;
if(buf == NULL)
return buf;
data = (char*)callocm(MAX_LEN, sizeof(char));
if(data == NULL)
return NULL;
xstrcpy(data, raw, MAX_LEN);
seperateFrmSp = xstrtok(data, " ", NULL);
if(seperateFrmSp == NULL) {
freem(data);
return NULL;
}
xstrcpy(data, seperateFrmSp, MAX_LEN);
mask = xstrtok(data, ":", NULL);
if(mask == NULL) {
freem(data);
return NULL;
}
strcpy(buf, mask);
freem(data);
return buf;
}
示例4: irc_get_nick
char* irc_get_nick(char *buf, char *raw) {
char *data;
char *seperateFrmCol;
char *nick;
if(buf == NULL)
return buf;
data = (char*)callocm(MAX_LEN, sizeof(char));
if(data == NULL)
return NULL;
xstrcpy(data, raw, MAX_LEN);
seperateFrmCol = xstrtok(data, ":", NULL);
if(seperateFrmCol == NULL) {
freem(data);
return NULL;
}
strcpy(data, seperateFrmCol);
if(strchr(data, '!') == NULL)
nick = xstrtok(data, " ", NULL);
else
nick = xstrtok(data, "!", NULL);
if(nick == NULL) {
freem(data);
return NULL;
}
xstrcpy(buf, nick, MAX_NICKLEN);
freem(data);
return buf;
}
示例5: reg_ipm_r
/*
* Check for personal message
*/
void reg_ipm_r(char *data, char *buf)
{
char *name, *msg;
int rec;
pid_t pid;
buf[0] = '\0';
snprintf(buf, SS_BUFSIZE, "100:0;");
strtok(data, ",");
pid = (pid_t)atoi(strtok(NULL, ";"));
if ((rec = reg_find(pid)) == -1)
return;
reginfo[rec].lastcon = (int)time(NULL);
if (!reginfo[rec].ismsg)
return;
name = xstrcpy(clencode(reginfo[rec].fname[reginfo[rec].ptr_out]));
msg = xstrcpy(clencode(reginfo[rec].msg[reginfo[rec].ptr_out]));
snprintf(buf, SS_BUFSIZE, "100:2,%s,%s;", name, msg);
if (reginfo[rec].ptr_out < RB)
reginfo[rec].ptr_out++;
else
reginfo[rec].ptr_out = 0;
if (reginfo[rec].ptr_out == reginfo[rec].ptr_in)
reginfo[rec].ismsg = FALSE;
Syslog('+', "reg_ipm: in=%d out=%d ismsg=%d", reginfo[rec].ptr_in, reginfo[rec].ptr_out, reginfo[rec].ismsg);
free(name);
free(msg);
return;
}
示例6: Syslog
char *xtodos(char *orig)
{
char buf[13], *copy, *p;
if (orig == NULL)
return NULL;
if ((remote_flags & SESSION_FNC) == 0) {
Syslog('o', "No filename conversion for \"%s\"", MBSE_SS(orig));
return xstrcpy(orig);
}
copy = xstrcpy(orig);
if ((p = strrchr(copy,'/')))
p++;
else
p = copy;
name_mangle(p);
memset(&buf, 0, sizeof(buf));
strncpy(buf, p, 12);
Syslog('o', "name \"%s\" converted to \"%s\"", MBSE_SS(orig), buf);
free(copy);
return xstrcpy(buf);
}
示例7: coprintf
int
coprintf (const char *format, ...)
{
va_list
argptr; /* Argument list pointer */
int
fmtsize = 0; /* Size of formatted line */
char
*formatted = NULL, /* Formatted line */
*prefixed = NULL; /* Prefixed formatted line */
if (console_active)
{
formatted = mem_alloc (LINE_MAX + 1);
if (!formatted)
return (0);
va_start (argptr, format); /* Start variable args processing */
vsnprintf (formatted, LINE_MAX, format, argptr);
va_end (argptr); /* End variable args processing */
switch (console_mode)
{
case CONSOLE_DATETIME:
xstrcpy_debug ();
prefixed = xstrcpy (NULL, date_str (), " ", time_str (), ": ",
formatted, NULL);
break;
case CONSOLE_TIME:
xstrcpy_debug ();
prefixed = xstrcpy (NULL, time_str (), ": ", formatted, NULL);
break;
}
if (console_file)
{
file_write (console_file, prefixed? prefixed: formatted);
fflush (console_file);
}
if (console_fct)
(console_fct) (prefixed? prefixed: formatted);
if (console_echo)
{
fprintf (stdout, "%s", prefixed? prefixed: formatted);
fprintf (stdout, "\n");
fflush (stdout);
}
if (prefixed)
{
fmtsize = strlen (prefixed);
mem_free (prefixed);
}
else
fmtsize = strlen (formatted);
mem_free (formatted);
}
return (fmtsize);
}
示例8: UserCity
void UserCity(pid_t pid, char *user, char *city)
{
char *u, *c;
u = xstrcpy(clencode(user));
c = xstrcpy(clencode(city));
SockS("AUSR:3,%d,%s,%s;", pid, u, c);
free(u);
free(c);
}
示例9: log_init
int log_init(const char *logname, const char *ttyname)
{
FILE *log_f;
char *n, fac[30], *prio;
int fc;
size_t len;
if ( logname == NULL )
return 0;
log_tty = ttyname ? xstrdup( ttyname ) : NULL;
if ( *logname != '$' ) {
log_f = fopen( logname, "at" );
if ( log_f ) {
fclose( log_f );
log_type = LT_LOGFILE;
log_name = xstrdup( logname );
return 1;
}
return 0;
}
if ( ttyname ) {
len = strlen( progname ) + 2 + strlen( ttyname );
n = malloc( len );
if ( !n ) {
fprintf( stderr, "can't malloc() %d bytes of memory\n", len );
abort();
exit(1);
}
xstrcpy( n, progname, len );
xstrcat( n, ".", len );
xstrcat( n, ttyname, len );
} else
n = xstrdup( progname );
prio = strchr( logname + 1, ':' );
if ( prio ) {
prio++;
xstrcpy( fac, logname + 1, 30 );
if (( syslog_priority = parsefacorprio( prio, (SLNCODE *) prioritynames )) < 0 )
syslog_priority = LOG_INFO;
} else
xstrcpy( fac, logname + 1, 30);
if (( fc = parsefacorprio( fac, (SLNCODE *) facilitynames )) < 0 )
return 0;
log_type = LT_SYSLOG;
log_name = NULL;
openlog( n, LOG_PID, fc );
xfree( n );
return 1;
}
示例10: WriteError
void WriteError(const char *format, ...)
{
char *outputstr, *temp;
va_list va_ptr;
int i;
outputstr = calloc(10240, sizeof(char));
va_start(va_ptr, format);
vsnprintf(outputstr, 10240, format, va_ptr);
va_end(va_ptr);
for (i = 0; i < strlen(outputstr); i++)
if (outputstr[i] == '\r' || outputstr[i] == '\n')
outputstr[i] = ' ';
if (*outputstr == '$')
snprintf(outputstr+strlen(outputstr), 10240, ": %s", strerror(errno));
if (strlen(outputstr) > (SS_BUFSIZE - 64)) {
outputstr[SS_BUFSIZE - 65] = ';';
outputstr[SS_BUFSIZE - 64] = '\0';
}
tcrc = StringCRC32(outputstr);
if (tcrc == lcrc) {
lcnt++;
free(outputstr);
return;
} else {
lcrc = tcrc;
if (lcnt) {
lcnt++;
SockS("ALOG:5,%s,%s,%d,?,Last message repeated %d times;", logdebug, progname, mypid, lcnt);
SockS("ALOG:5,%s,%s,%d,?,Last message repeated %d times;", logfile, progname, mypid, lcnt);
SockS("ALOG:5,%s,%s,%d,?,Last message repeated %d times;", errfile, progname, mypid, lcnt);
}
lcnt = 0;
}
if (*outputstr == '$') {
temp = xstrcpy(clencode(outputstr+1));
} else {
temp = xstrcpy(clencode(outputstr));
}
SockS("ALOG:5,%s,%s,%d,?,%s;", logdebug, progname, mypid, temp);
SockS("ALOG:5,%s,%s,%d,?,%s;", logfile, progname, mypid, temp);
SockS("ALOG:5,%s,%s,%d,?,%s;", errfile, progname, mypid, temp);
free(temp);
free(outputstr);
}
示例11: reg_newcon
int reg_newcon(char *data)
{
char *tty, *uid, *prg, *city;
int retval;
pid_t pid;
strtok(data, ",");
pid = (pid_t)atoi(strtok(NULL, ","));
tty = xstrcpy(strtok(NULL, ","));
uid = xstrcpy(cldecode(strtok(NULL, ",")));
prg = xstrcpy(cldecode(strtok(NULL, ",")));
city = xstrcpy(cldecode(strtok(NULL, ";")));
/*
* Abort if no empty record is found
*/
if ((retval = reg_find((pid_t)0)) == -1) {
Syslog('?', "Maximum clients (%d) reached", MAXCLIENT);
retval = -1;
} else {
memset((char *)®info[retval], 0, sizeof(reg_info));
reginfo[retval].pid = pid;
strncpy((char *)®info[retval].tty, tty, 6);
strncpy((char *)®info[retval].uname, uid, 35);
strncpy((char *)®info[retval].prg, prg, 14);
strncpy((char *)®info[retval].city, city, 35);
strcpy((char *)®info[retval].doing, "-");
reginfo[retval].started = (int)time(NULL);
reginfo[retval].lastcon = (int)time(NULL);
reginfo[retval].altime = 600;
/*
* Everyone says do not disturb, unless the flag
* is cleared by the owner of this process.
*/
reginfo[retval].silent = 1;
stat_inc_clients();
if (strcmp(prg, (char *)"ftncico") == 0)
mailers++;
Syslog('-', "Registered client pgm \"%s\", pid %d, slot %d, mailers %d, TCP/IP %d",
prg, (int)pid, retval, mailers, ipmailers);
}
free(uid);
free(prg);
free(city);
free(tty);
return retval;
}
示例12: xmsg_unlink_dotfiles
/* kind = 0 for sent, 1 for toobig */
static void xmsg_unlink_dotfiles(session_t *s, const char *varname)
{
if (session_int_get(s, varname)) {
const int kind = !xstrcasecmp(varname, "unlink_sent");
const int maxfs = session_int_get(s, "max_filesize");
const char *dfsuffix = session_get(s, "dotfile_suffix");
const char *dir = xmsg_dirfix(session_uid_get(s)+XMSG_UID_DIROFFSET);
DIR *d;
struct dirent *de;
struct stat st, std;
char *df, *dfd, *dp, *dpd;
if (!dir || !(d = opendir(dir))) {
xdebug("unable to open specified directory");
return;
}
df = xmalloc(xstrlen(dir) + NAME_MAX + 2);
dfd = xmalloc(xstrlen(dir) + NAME_MAX + 3 + xstrlen(dfsuffix));
xstrcpy(df, dir);
dp = df + xstrlen(df);
*(dp++) = '/';
xstrcpy(dfd, df);
dpd = dfd + xstrlen(dfd);
*(dpd++) = '.';
while ((de = readdir(d))) {
if (de->d_name[0] == '.')
continue;
if (xstrlen(de->d_name) > NAME_MAX) {
xdebug2(DEBUG_ERROR, "Filename longer than NAME_MAX (%s), skipping.", de->d_name);
continue;
}
xstrcpy(dp, de->d_name);
xstrcpy(dpd, de->d_name);
xstrcat(dpd, dfsuffix);
if (!stat(df, &st) && !stat(dfd, &std)
&& ((!maxfs || (st.st_size < maxfs)) == kind)) {
xdebug("removing %s", de->d_name);
unlink(df);
unlink(dfd);
}
}
closedir(d);
xfree(df);
xfree(dfd);
}
}
示例13: get_lastcallerrec_r
void get_lastcallerrec_r(int Rec, char *buf)
{
char *temp, action[9], *name, *city;
FILE *fp;
snprintf(buf, SS_BUFSIZE, "201:1,16;");
temp = calloc(PATH_MAX, sizeof(char));
snprintf(temp, PATH_MAX, "%s/etc/lastcall.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r")) == NULL) {
free(temp);
return;
}
fread(&LCALLhdr, sizeof(LCALLhdr), 1, fp);
fseek(fp, ((Rec -1) * LCALLhdr.recsize) + LCALLhdr.hdrsize, SEEK_SET);
if (fread(&LCALL, LCALLhdr.recsize, 1, fp) == 1) {
LCALL.UserName[15] = '\0';
LCALL.Location[12] = '\0';
strcpy(action, "--------");
if (LCALL.Hidden)
action[0] = 'H';
if (LCALL.Download)
action[1] = 'D';
if (LCALL.Upload)
action[2] = 'U';
if (LCALL.Read)
action[3] = 'R';
if (LCALL.Wrote)
action[4] = 'P';
if (LCALL.Chat)
action[5] = 'C';
if (LCALL.Olr)
action[6] = 'O';
if (LCALL.Door)
action[7] = 'E';
action[8] = '\0';
name = xstrcpy(clencode(LCALL.UserName));
city = xstrcpy(clencode(LCALL.Location));
snprintf(buf, SS_BUFSIZE, "100:9,%s,%s,%d,%s,%s,%d,%d,%s,%s;", name, city,
LCALL.SecLevel, LCALL.Device, LCALL.TimeOn,
(int)LCALL.CallTime, LCALL.Calls, LCALL.Speed, action);
free(name);
free(city);
}
free(temp);
fclose(fp);
return;
}
示例14: mdm_dial
int mdm_dial(char *phone,char *port)
{
int rc;
char s[MAX_STRING],conn[MAX_STRING];
if((rc=tty_openport(port))) {
write_log("can't open port: %s",tty_errs[rc]);
return MC_BAD;
}
reset();
xstrcpy(s,cfgs(CFG_DIALPREFIX),MAX_STRING);
xstrcat(s,phone,MAX_STRING);
xstrcat(s,cfgs(CFG_DIALSUFFIX),MAX_STRING);
tty_local(1);
sline("Dialing %s",s);vidle();
rc=modem_chat(s,cfgsl(CFG_MODEMCONNECT),cfgsl(CFG_MODEMNODIAL),cfgsl(CFG_MODEMERROR),
cfgsl(CFG_MODEMBUSY),cfgs(CFG_MODEMRINGING),cfgi(CFG_MAXRINGS),
cfgi(CFG_WAITCARRIER),conn,MAX_STRING);
sline("Modem said: %s",conn);
xfree(connstr);connstr=xstrdup(conn);
if(rc!=MC_OK) {
write_log("got %s",conn);
if(rc==MC_FAIL)hangup();
tty_close();
if(rc==MC_RING) {
sline("RING found..");
sleep(2);
execsh("killall -USR1 mgetty vgetty >/dev/null 2>&1");
} else sline("Call failed (%s)",mcs[rc]);
return rc;
}
write_log("*** %s",conn);
tty_local(0);
return rc;
}
示例15: readalias
void readalias(char *fn)
{
FILE *fp;
char buf[256], *k, *v;
struct aliaslist *tmp = NULL;
faddr *ta = NULL;
if ((fp = fopen(fn,"r")) == NULL) {
WriteError("$cannot open system alias file %s", MBSE_SS(fn));
return;
}
while (fgets(buf, sizeof(buf)-1, fp)) {
k = strtok(buf, " \t:");
v = strtok(NULL, " \t\n\r\0:");
if (k && v)
if ((ta = parsefaddr(v))) {
if (alist) {
tmp->next = (struct aliaslist *) xmalloc(sizeof(struct aliaslist));
tmp = tmp->next;
} else {
alist = (struct aliaslist *) xmalloc(sizeof(struct aliaslist));
tmp = alist;
}
tmp->next = NULL;
tmp->addr = ta;
ta = NULL;
tmp->alias = xstrcpy(k);
}
}
fclose(fp);
}