本文整理汇总了C++中scan_ulong函数的典型用法代码示例。如果您正苦于以下问题:C++ scan_ulong函数的具体用法?C++ scan_ulong怎么用?C++ scan_ulong使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scan_ulong函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: didentd_init
void didentd_init()
{
char *x;
unsigned long id;
x = env_get("ROOT");
if (!x)
strerr_die2x(111,FATAL,"$ROOT not set");
if (chdir(x) == -1)
strerr_die4sys(111,FATAL,"unable to chdir to ",x,": ");
x = env_get("GID");
if (!x)
strerr_die2x(111,FATAL,"$GID not set");
scan_ulong(x,&id);
if (prot_gid((int) id) == -1)
strerr_die2sys(111,FATAL,"unable to setgid: ");
x = env_get("UID");
if (!x)
strerr_die2x(111,FATAL,"$UID not set");
scan_ulong(x,&id);
if (prot_uid((int) id) == -1)
strerr_die2sys(111,FATAL,"unable to setuid: ");
}
开发者ID:kjseefried,项目名称:didentd,代码行数:25,代码来源:init-freebsd-chdir.c
示例2: didentd_init
void didentd_init()
{
/* chroot() to /proc/net/ and switch to $UID:$GID */
char *x;
unsigned long id;
if (chdir("/proc/net/") == -1)
strerr_die2sys(111,FATAL,"unable to chdir to '/proc/net/': ");
if (chroot(".") == -1)
strerr_die2sys(111,FATAL,"unable to chdir to '/proc/net/': ");
x = env_get("GID");
if (!x)
strerr_die2x(111,FATAL,"$GID not set");
scan_ulong(x,&id);
if (prot_gid((int) id) == -1)
strerr_die2sys(111,FATAL,"unable to setgid: ");
x = env_get("UID");
if (!x)
strerr_die2x(111,FATAL,"$UID not set");
scan_ulong(x,&id);
if (prot_uid((int) id) == -1)
strerr_die2sys(111,FATAL,"unable to setuid: ");
}
开发者ID:kjseefried,项目名称:didentd,代码行数:25,代码来源:init-linux-chroot.c
示例3: parsetime
static int parsetime(const char*c,struct tm* x) {
unsigned long tmp;
c+=scan_ulong(c,&tmp); x->tm_hour=tmp;
if (*c!=':') return -1; ++c;
c+=scan_ulong(c,&tmp); x->tm_min=tmp;
if (*c!=':') return -1; ++c;
c+=scan_ulong(c,&tmp); x->tm_sec=tmp;
if (*c!=' ') return -1;
return 0;
}
开发者ID:Moscarda,项目名称:opentracker-1,代码行数:10,代码来源:scan_httpdate.c
示例4: pls_reader
static int
pls_reader(playlist* pl) {
int ret;
static playlist_entry entry;
buffer* inbuf = pl->ptr;
stralloc line;
stralloc_init(&line);
if(( ret = buffer_getline_sa(inbuf, &line))) {
size_t index2, index;
index2 = index = 0;
while(line.len > 1 &&
(line.s[line.len - 1] == '\r' || line.s[line.len - 1] == '\n'))
line.len--;
stralloc_0(&line);
if(!str_diffn(&line.s[index], "Number", 6)) {
} else if(line.s[index] == '[') {
} else if((index2 = str_chr(&line.s[index], '=')) > 0) {
unsigned long trackno = 0;
index = index2;
index2++;
do { index--; } while(isdigit(line.s[index]) && index > 0);
scan_ulong(&line.s[index], &trackno);
if(!str_diffn(&line.s[index], "File", 4)) {
stralloc_copys(&entry.path, &line.s[index2]);
stralloc_0(&entry.path);
} else if(!str_diffn(&line.s[index], "Title", 5)) {
stralloc_copys(&entry.title, &line.s[index2]);
stralloc_0(&entry.title);
} else if(!str_diffn(&line.s[index], "Length", 6)) {
unsigned long len;
scan_ulong(&line.s[index2], &len);
entry.length = len;
}
/*
uint32 index = 8;
index += scan_ulong(&line.s[index], &len);
entry.length = len;
index++;
stralloc_copys(&entry.title, &line.s[index]);
stralloc_0(&entry.title);
*/
} else {
/*
stralloc_copy(&entry.path, &line);
stralloc_0(&entry.path);
if(pl->callback) {
pl->callback(pl, &entry.title, &entry.path, entry.length);
}*/
}
}
return ret;
}
开发者ID:rsenn,项目名称:dirlist,代码行数:52,代码来源:playlist_pls.c
示例5: stralloc_0
const char *get_from(const char *adr, /* target address */
const char *act) /* action */
/* If we captured a from line, it will be from the subscriber, except */
/* when -S is used when it's usually from the subscriber, but of course */
/* could be from anyone. The matching to stored data is required only */
/* to support moderated lists, and in cases where a new -sc is issued */
/* because an old one was invalid. In this case, we read through the */
/* from file trying to match up a timestamp with that starting in */
/* *(act+3). If the time stamp matches, we compare the target address */
/* itself. act + 3 must be a legal part of the string returns pointer to*/
/* fromline, NULL if not found. Since the execution time from when to */
/* storage may differ, we can't assume that the timestamps are in order.*/
{
int fd;
const char *fl;
unsigned int pos;
unsigned long thistime;
unsigned long linetime;
if (!flagstorefrom) return 0;
if (fromline.len) { /* easy! We got it in this message */
stralloc_0(&fromline);
return fromline.s;
} /* need to recover it from DIR/from */
fl = 0;
(void) scan_ulong(act+3,&thistime);
if ((fd = open_read("from")) == -1) {
if (errno == error_noent)
return 0;
else
strerr_die2sys(111,FATAL,MSG1(ERR_READ,"from"));
}
substdio_fdbuf(&sstext,read,fd,textbuf,(int) sizeof(textbuf));
for (;;) {
if (getln(&sstext,&fromline,&match,'\n') == -1)
strerr_die2sys(111,FATAL,MSG1(ERR_READ,"from"));
if (!match) break;
fromline.s[fromline.len - 1] = (char) 0;
/* now:time addr\0fromline\0 read all. They can be out of order! */
pos = scan_ulong(fromline.s,&linetime);
if (linetime != thistime) continue;
if (!str_diff(fromline.s + pos + 1,adr)) {
pos = str_len(fromline.s);
if (pos < fromline.len) {
fl = fromline.s + pos + 1;
break;
}
}
}
close(fd);
return fl;
}
开发者ID:chayapan-computing,项目名称:ezmlm-idx,代码行数:52,代码来源:ezmlm-manage.c
示例6: main
void main(int argc,char **argv)
{
int fdlock;
unsigned long delay;
(void) umask(022);
sig_pipeignore();
when = now();
getconfopt(argc,argv,options,1,0);
if (flagreturn < 0)
/* default to returning timed-out messages */
flagreturn = !getconf_isset("noreturnposts");
getconf_line(&modtime,"modtime",0);
if (!stralloc_0(&modtime)) die_nomem();
scan_ulong(modtime.s,&delay);
if (!delay) delay = DELAY_DEFAULT;
else if (delay < DELAY_MIN) delay = DELAY_MIN;
else if (delay > DELAY_MAX) delay = DELAY_MAX;
older = (unsigned long) when - 3600L * delay; /* delay is in hours */
fdlock = lockfile("mod/lock");
dodir("mod/pending/",flagreturn);
dodir("mod/accepted/",0);
dodir("mod/rejected/",0);
dodir("mod/unconfirmed/",0);
_exit(0);
}
开发者ID:debdungeon,项目名称:qint,代码行数:29,代码来源:ezmlm-clean.c
示例7: scan_uint
size_t
scan_uint(const char* src, unsigned int* dest) {
if(sizeof(unsigned int) == sizeof(unsigned long)) {
/* a good optimizing compiler should remove the else clause when not
* needed */
return scan_ulong(src, (unsigned long*)dest);
} else if(sizeof(unsigned int) < sizeof(unsigned long)) {
const char* cur;
unsigned int l;
for(cur = src, l = 0; *cur >= '0' && *cur <= '9'; ++cur) {
unsigned long tmp = l * 10ul + *cur - '0';
if((unsigned int)tmp != tmp)
break;
l = tmp;
}
if(cur > src)
*dest = l;
return (size_t)(cur - src);
#ifdef __GNUC__
} else {
/* the C standard says that sizeof(short) <= sizeof(unsigned int) <=
* sizeof(unsigned long); this can never happen. Provoke a compile
* error if it does */
char compileerror[sizeof(unsigned long) - sizeof(unsigned int)];
(void)compileerror;
#endif
}
}
开发者ID:rsenn,项目名称:dirlist,代码行数:28,代码来源:scan_uint.c
示例8: getlarg
void getlarg(long *l) {
unsigned long ul;
if (str_equal(optarg, "=")) { *l =-1; return; }
if (optarg[scan_ulong(optarg, &ul)]) usage();
*l =ul;
}
开发者ID:psi,项目名称:runit-gentoo,代码行数:7,代码来源:chpst.c
示例9: ip4_scan
unsigned int ip4_scan(const char *s,unsigned char ip[4])
{
unsigned int i;
unsigned int len;
unsigned long u;
len = 0;
i = scan_ulong(s,&u); if (!i) return 0; ip[0] = u; s += i; len += i;
if (*s != '.') return 0; ++s; ++len;
i = scan_ulong(s,&u); if (!i) return 0; ip[1] = u; s += i; len += i;
if (*s != '.') return 0; ++s; ++len;
i = scan_ulong(s,&u); if (!i) return 0; ip[2] = u; s += i; len += i;
if (*s != '.') return 0; ++s; ++len;
i = scan_ulong(s,&u); if (!i) return 0; ip[3] = u; s += i; len += i;
return len;
}
开发者ID:anders94,项目名称:geoipdns,代码行数:16,代码来源:ip4_scan.c
示例10: do_get
static void do_get(const char *action)
{
unsigned long u;
struct stat st;
char ch;
int r;
unsigned int pos;
int fd;
if (!flagget)
strerr_die2x(100,FATAL,MSG(ERR_NOT_AVAILABLE));
hdr_subject(MSG(SUB_GET_MSG));
hdr_ctboundary();
copy(&qq,"text/top",flagcd);
pos = str_len(ACTION_GET);
if (!case_starts(action,ACTION_GET))
pos = str_len(ALT_GET);
if (action[pos] == '.' || action [pos] == '_') pos++;
scan_ulong(action + pos,&u);
stralloc_copys(&line,"archive/");
stralloc_catb(&line,strnum,fmt_ulong(strnum,u / 100));
stralloc_cats(&line,"/");
stralloc_catb(&line,strnum,fmt_uint0(strnum,(unsigned int) (u % 100),2));
stralloc_0(&line);
fd = open_read(line.s);
if (fd == -1)
if (errno != error_noent)
strerr_die2sys(111,FATAL,MSG1(ERR_OPEN,line.s));
else
copy_act("text/get-bad");
else {
if (fstat(fd,&st) == -1)
copy_act("text/get-bad");
else if (!(st.st_mode & 0100))
copy_act("text/get-bad");
else {
showsend("get");
substdio_fdbuf(&sstext,read,fd,textbuf,sizeof(textbuf));
qmail_puts(&qq,"> ");
for (;;) {
r = substdio_get(&sstext,&ch,1);
if (r == -1) strerr_die2sys(111,FATAL,MSG1(ERR_READ,line.s));
if (r == 0) break;
qmail_put(&qq,&ch,1);
if (ch == '\n') qmail_puts(&qq,"> ");
}
qmail_puts(&qq,"\n");
}
close(fd);
}
copybottom(0);
qmail_to(&qq,target.s);
}
开发者ID:chayapan-computing,项目名称:ezmlm-idx,代码行数:57,代码来源:ezmlm-manage.c
示例11: c_init
void c_init(char **script)
{
int i;
struct cyclog *d;
char *processor;
unsigned long num;
unsigned long size;
cnum = 0;
for (i = 0;script[i];++i)
if ((script[i][0] == '.') || (script[i][0] == '/'))
++cnum;
c = (struct cyclog *) alloc(cnum * sizeof(*c));
if (!c) strerr_die2x(111,FATAL,"out of memory");
d = c;
processor = 0;
num = 10;
size = 99999;
for (i = 0;script[i];++i)
if (script[i][0] == 's') {
scan_ulong(script[i] + 1,&size);
if (size < 4096) size = 4096;
if (size > 16777215) size = 16777215;
}
else if (script[i][0] == 'n') {
scan_ulong(script[i] + 1,&num);
if (num < 2) num = 2;
}
else if (script[i][0] == '!') {
processor = script[i] + 1;
}
else if ((script[i][0] == '.') || (script[i][0] == '/')) {
d->num = num;
d->size = size;
d->processor = processor;
d->dir = script[i];
buffer_init(&d->ss,c_write,d - c,d->buf,sizeof d->buf);
restart(d);
++d;
}
}
开发者ID:schmurfy,项目名称:daemontools,代码行数:44,代码来源:multilog.c
示例12: scan_ushort
unsigned int scan_ushort(char *s, unsigned short *u)
{
unsigned long l;
unsigned int r;
r = scan_ulong(s, &l);
*u = l;
return r;
}
开发者ID:kjseefried,项目名称:didentd,代码行数:10,代码来源:scan_ushort.c
示例13: scan_uint
unsigned int scan_uint(const char *s, unsigned int *up)
{
unsigned long ul;
unsigned int ui;
unsigned int len;
len = scan_ulong(s, &ul);
if (!len) return 0;
ui = (unsigned int) ul; *up = ui;
return len;
}
开发者ID:io7m,项目名称:coreland-corelib,代码行数:12,代码来源:scan_int.c
示例14: scan_long
unsigned int scan_long(register const char* s,register long* i)
{
int sign;
unsigned long u;
register unsigned int len;
len = scan_plusminus(s,&sign);
s += len;
len += scan_ulong(s,&u);
if (sign < 0) *i = -u;
else *i = u;
return len;
}
开发者ID:edwardt,项目名称:Pipeline-Sort,代码行数:12,代码来源:scan_long.c
示例15: log_init
void
log_init(int fd, unsigned long mask, int via_spawn)
/*
* Known LOGLEVELs:
*/
{
char *a = env_get("LOGLEVEL");
loglevel = 0;
addLOG = via_spawn;
if ( a && *a ) {
scan_ulong(a, &loglevel);
} else if ((a = env_get("DEBUGLEVEL")) && *a ) {
scan_ulong(a, &loglevel);
}
loglevel &= mask;
substdio_fdbuf(&sslog, subwrite, fd, logbuffer, sizeof(logbuffer) );
/* logit(4, "LOGLEVEL set to %i\n", loglevel);
*/
}
开发者ID:ajtulloch,项目名称:qmail,代码行数:21,代码来源:qldap-debug.c
示例16: _searchlog
/* Searches the subscriber log and outputs via subwrite(s,len) any entry
* that matches search. A '_' is search is a wildcard. Any other
* non-alphanum/'.' char is replaced by a '_'. */
static void _searchlog(struct subdbinfo *info,
const char *table,
char *search, /* search string */
int subwrite()) /* output fxn */
{
sqlite3_stmt *stmt;
int res;
datetime_sec when;
struct datetime dt;
char date[DATE822FMT];
/* SELECT (*) FROM list_slog WHERE fromline LIKE '%search%' OR address */
/* LIKE '%search%' ORDER BY tai; */
/* The '*' is formatted to look like the output of the non-mysql version */
/* This requires reading the entire table, since search fields are not */
/* indexed, but this is a rare query and time is not of the essence. */
if (!stralloc_copys(&line,"SELECT tai, edir||etype||' '||address||' '||fromline"
" FROM ")) die_nomem();
if (!stralloc_cat_table(&line,info,table)) die_nomem();
if (!stralloc_cats(&line,"_slog")) die_nomem();
if (*search) { /* We can afford to wait for LIKE '%xx%' */
if (!stralloc_cats(&line," WHERE fromline LIKE '%")) die_nomem();
if (!stralloc_cats(&line,search)) die_nomem();
if (!stralloc_cats(&line,"%' OR address LIKE '%")) die_nomem();
if (!stralloc_cats(&line,search)) die_nomem();
if (!stralloc_cats(&line,"%'")) die_nomem();
} /* ordering by tai which is an index */
if (!stralloc_cats(&line," ORDER by tai")) die_nomem();
if (!stralloc_0(&line)) die_nomem();
if ((stmt = _sqlquery(info, &line)) == NULL)
strerr_die2x(111,FATAL,sqlite3_errmsg((sqlite3*)info->conn));
while ((res = sqlite3_step(stmt)) != SQLITE_DONE) {
if (res != SQLITE_ROW)
strerr_die2x(111,FATAL,sqlite3_errmsg((sqlite3*)info->conn));
(void)scan_ulong((const char*)sqlite3_column_text(stmt,0),&when);
datetime_tai(&dt,when);
if (!stralloc_copyb(&line,date,date822fmt(date,&dt)-1)) die_nomem();
if (!stralloc_cats(&line,": ")) die_nomem();
if (!stralloc_catb(&line,strnum,fmt_ulong(strnum,when))) die_nomem();
if (!stralloc_cats(&line," ")) die_nomem();
if (!stralloc_catb(&line,
(const char*)sqlite3_column_text(stmt,1),
sqlite3_column_bytes(stmt,1)))
die_nomem();
if (subwrite(line.s,line.len) == -1) die_write();
}
sqlite3_finalize(stmt);
}
开发者ID:abh,项目名称:ezmlm-idx,代码行数:56,代码来源:sub-sqlite3.c
示例17: scan_uchar
unsigned int scan_uchar(const char *s, unsigned char *up)
{
unsigned long ul;
unsigned int len;
unsigned char uc;
len = scan_ulong(s, &ul);
if (!len) return 0;
uc = (unsigned char) ul; *up = uc;
return len;
}
开发者ID:io7m,项目名称:coreland-corelib,代码行数:12,代码来源:scan_char.c
示例18: ipsvd_scan_port
unsigned int ipsvd_scan_port(const char *s, const char *proto,
unsigned long *p) {
struct servent *se;
if (! *s) return(0);
if ((se =getservbyname(s, proto))) {
/* what is se->s_port, uint16 or uint32? */
*p =htons(se->s_port);
return(1);
}
if (s[scan_ulong(s, p)]) return(0);
return(1);
}
开发者ID:alexgirao,项目名称:ipsvd,代码行数:13,代码来源:ipsvd_scan.c
示例19: control_readint
int control_readint(int *i,char *fn)
{
unsigned long u;
switch(control_readline(&line,fn))
{
case 0: return 0;
case -1: return -1;
}
if (!stralloc_0(&line)) return -1;
if (!scan_ulong(line.s,&u)) return 0;
*i = u;
return 1;
}
开发者ID:kp-org,项目名称:eQmail,代码行数:13,代码来源:control.c
示例20: sub_sql_searchlog
/* Searches the subscriber log and outputs via subwrite(s,len) any entry
* that matches search. A '_' is search is a wildcard. Any other
* non-alphanum/'.' char is replaced by a '_'. */
void sub_sql_searchlog(struct subdbinfo *info,
const char *table,
char *search, /* search string */
int subwrite()) /* output fxn */
{
void *result;
datetime_sec when;
struct datetime dt;
char date[DATE822FMT];
int nparams;
char strnum[FMT_ULONG];
make_name(info,table?"_":0,table,0);
/* SELECT (*) FROM list_slog WHERE fromline LIKE '%search%' OR address */
/* LIKE '%search%' ORDER BY tai; */
/* The '*' is formatted to look like the output of the non-mysql version */
/* This requires reading the entire table, since search fields are not */
/* indexed, but this is a rare query and time is not of the essence. */
stralloc_copys(&query,"SELECT ");
stralloc_cats(&query,sql_searchlog_select_defn);
stralloc_cats(&query," FROM ");
stralloc_cat(&query,&name);
stralloc_cats(&query,"_slog");
if (*search) { /* We can afford to wait for LIKE '%xx%' */
stralloc_copys(¶ms[0],search);
stralloc_copys(¶ms[1],search);
nparams = 2;
stralloc_cats(&query," WHERE ");
stralloc_cats(&query,sql_searchlog_where_defn);
}
else
nparams = 0;
/* ordering by tai which is an index */
stralloc_cats(&query," ORDER by tai");
result = sql_select(info,&query,nparams,params);
while (sql_fetch_row(info,result,2,params)) {
stralloc_0(¶ms[0]);
(void)scan_ulong(params[0].s,&when);
datetime_tai(&dt,when);
stralloc_copyb(¶ms[0],date,date822fmt(date,&dt)-1);
stralloc_cats(¶ms[0],": ");
stralloc_catb(¶ms[0],strnum,fmt_ulong(strnum,when));
stralloc_cats(¶ms[0]," ");
stralloc_cat(¶ms[0],¶ms[1]);
if (subwrite(params[0].s,params[0].len) == -1) die_write();
}
sql_free_result(info,result);
}
开发者ID:bruceg,项目名称:ezmlm-idx,代码行数:53,代码来源:sub_sql.c
注:本文中的scan_ulong函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论