本文整理汇总了C++中scan_ulong函数的典型用法代码示例。如果您正苦于以下问题:C++ scan_ulong函数的具体用法?C++ scan_ulong怎么用?C++ scan_ulong使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scan_ulong函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ");
}
示例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: ");
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
*/
}