本文整理汇总了C++中pfatal函数的典型用法代码示例。如果您正苦于以下问题:C++ pfatal函数的具体用法?C++ pfatal怎么用?C++ pfatal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pfatal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: fixup_superblock
/*
* Check and potentially fix certain fields in the super block.
*/
static void
fixup_superblock(void)
{
/*
* Kernel looks for FS_OPTTIME, and assumes that if that's not
* what's there, it must be FS_OPTSPACE, so not fixing does not
* require setting iscorrupt.
*/
if (sblock.fs_optim != FS_OPTTIME && sblock.fs_optim != FS_OPTSPACE) {
pfatal("UNDEFINED OPTIMIZATION IN SUPERBLOCK");
if (reply("SET TO DEFAULT") == 1) {
sblock.fs_optim = FS_OPTTIME;
sbdirty();
}
}
if ((sblock.fs_minfree < 0 || sblock.fs_minfree > 99)) {
pfatal("IMPOSSIBLE MINFREE=%d IN SUPERBLOCK",
sblock.fs_minfree);
if (reply("SET TO DEFAULT") == 1) {
sblock.fs_minfree = 10;
sbdirty();
} else if (sblock.fs_minfree < 0) {
/*
* Kernel uses minfree without verification,
* and a negative value would do bad things.
*/
iscorrupt = 1;
}
}
}
开发者ID:andreiw,项目名称:polaris,代码行数:33,代码来源:setup.c
示例2: find
/* Simulate a "/usr/bin/find . -print" */
void find(char *dirname)
{
DIR *fd;
struct dirent *d;
if ((fd = opendir(dirname)) == NULL)
pfatal("opendir");
while ((d = readdir(fd)))
{
char fullname[MAXPATHLEN];
struct stat statbuf;
if (strcmp(".", d->d_name) == 0)
continue;
if (strcmp("..", d->d_name) == 0)
continue;
snprintf(fullname, MAXPATHLEN-1, "%s/%s", dirname, d->d_name);
if (lstat(fullname, &statbuf) != 0)
pfatal("lstat");
printf(" %s\n", fullname);
if (S_ISDIR(statbuf.st_mode))
find(fullname);
}
closedir(fd);
}
开发者ID:mct,项目名称:junkdrawer,代码行数:32,代码来源:jailbird.c
示例3: array_read
static array_t
array_read (const char *filename)
{
FILE *fd;
array_t a;
int size;
int i, s;
fd = fopen (filename, "r");
if (!fd)
pfatal ("Lecture tableau, ouverture du fichier");
s = fscanf (fd, "%d\n", &size);
if (s !=1)
pfatal ("Lecture tableau, taille du tableau");
a = array_alloc (size);
for (i=0 ; i<a.size ; i++) {
s = fscanf (fd, "%e\n", a.val+i);
if (s != 1)
pfatal ("Lecture tableau, manque de valeur");
}
s = fclose (fd);
if (s)
pfatal ("Lecture tableau, fermeture fichier");
return a;
}
开发者ID:Tikiwinkie,项目名称:PPD,代码行数:30,代码来源:df.c
示例4: calcsb
/*
* Calculate a prototype superblock based on information in the disk label.
* When done the cgsblock macro can be calculated and the fs_ncg field
* can be used. Do NOT attempt to use other macros without verifying that
* their needed information is available!
*/
static int
calcsb(char *dev, int devfd, struct fs *fs)
{
struct disklabel *lp;
struct partition *pp;
char *cp;
int i, nspf;
cp = strchr(dev, '\0') - 1;
if (cp == (char *)-1 || ((*cp < 'a' || *cp > 'h') && !isdigit(*cp))) {
pfatal("%s: CANNOT FIGURE OUT FILE SYSTEM PARTITION\n", dev);
return (0);
}
lp = getdisklabel(dev, devfd);
if (isdigit(*cp))
pp = &lp->d_partitions[0];
else
pp = &lp->d_partitions[*cp - 'a'];
if (pp->p_fstype != FS_BSDFFS) {
pfatal("%s: NOT LABELED AS A BSD FILE SYSTEM (%s)\n",
dev, pp->p_fstype < FSMAXTYPES ?
fstypenames[pp->p_fstype] : "unknown");
return (0);
}
if (pp->p_fsize == 0 || pp->p_frag == 0 ||
pp->p_cpg == 0 || pp->p_size == 0) {
pfatal("%s: %s: type %s fsize %d, frag %d, cpg %d, size %d\n",
dev, "INCOMPLETE LABEL", fstypenames[pp->p_fstype],
pp->p_fsize, pp->p_frag, pp->p_cpg, pp->p_size);
return (0);
}
memset(fs, 0, sizeof(struct fs));
fs->fs_fsize = pp->p_fsize;
fs->fs_frag = pp->p_frag;
fs->fs_size = pp->p_size;
fs->fs_sblkno = roundup(
howmany(lp->d_bbsize + lp->d_sbsize, fs->fs_fsize),
fs->fs_frag);
nspf = fs->fs_fsize / lp->d_secsize;
for (fs->fs_fsbtodb = 0, i = nspf; i > 1; i >>= 1)
fs->fs_fsbtodb++;
dev_bsize = lp->d_secsize;
if (fs->fs_magic == FS_UFS2_MAGIC) {
fs->fs_fpg = pp->p_cpg;
fs->fs_ncg = howmany(fs->fs_size, fs->fs_fpg);
} else /* if (fs->fs_magic == FS_UFS1_MAGIC) */ {
fs->fs_old_cpg = pp->p_cpg;
fs->fs_old_cgmask = 0xffffffff;
for (i = lp->d_ntracks; i > 1; i >>= 1)
fs->fs_old_cgmask <<= 1;
if (!POWEROF2(lp->d_ntracks))
fs->fs_old_cgmask <<= 1;
fs->fs_old_cgoffset = roundup(howmany(lp->d_nsectors, nspf),
fs->fs_frag);
fs->fs_fpg = (fs->fs_old_cpg * lp->d_secpercyl) / nspf;
fs->fs_ncg = howmany(fs->fs_size / lp->d_secpercyl,
fs->fs_old_cpg);
}
return (1);
}
开发者ID:ornarium,项目名称:freebsd,代码行数:66,代码来源:setup.c
示例5: flush
void
flush(int fd, struct bufarea *bp)
{
int i, j;
if (!bp->b_dirty)
return;
bp->b_dirty = 0;
if (fswritefd < 0) {
pfatal("WRITING IN READ_ONLY MODE.\n");
return;
}
if (bp->b_errs != 0)
pfatal("WRITING %sZERO'ED BLOCK %lld TO DISK\n",
(bp->b_errs == bp->b_size / dev_bsize) ? "" : "PARTIALLY ",
(long long)bp->b_bno);
bp->b_errs = 0;
blwrite(fd, bp->b_un.b_buf, bp->b_bno, (long)bp->b_size);
if (bp != &sblk)
return;
for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize, j++) {
blwrite(fswritefd, (char *)sblock.fs_csp + i,
fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag),
sblock.fs_cssize - i < sblock.fs_bsize ?
sblock.fs_cssize - i : sblock.fs_bsize);
}
}
开发者ID:ppaeps,项目名称:freebsd-head,代码行数:27,代码来源:fsutil.c
示例6: fileerror
void
fileerror(ino_t cwd, ino_t ino, const char *errmesg)
{
char pathbuf[MAXPATHLEN + 1];
struct uvnode *vp;
pwarn("%s ", errmesg);
pinode(ino);
printf("\n");
pwarn("PARENT=%lld\n", (long long)cwd);
getpathname(pathbuf, sizeof(pathbuf), cwd, ino);
if (ino < ULFS_ROOTINO || ino >= maxino) {
pfatal("NAME=%s\n", pathbuf);
return;
}
vp = vget(fs, ino);
if (vp == NULL)
pfatal("INO is NULL\n");
else {
if (ftypeok(VTOD(vp)))
pfatal("%s=%s\n",
(lfs_dino_getmode(fs, VTOI(vp)->i_din) & LFS_IFMT) == LFS_IFDIR ?
"DIR" : "FILE", pathbuf);
else
pfatal("NAME=%s\n", pathbuf);
}
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:27,代码来源:dir.c
示例7: dolabel
/*******************************************************************************
* Labeling
******************************************************************************/
void dolabel(mdl_t *mdl) {
// First, load the model provided by the user. This is mandatory to
// label new datas ;-)
if (mdl->opt->model == NULL)
fatal("you must specify a model");
info("* Load model\n");
FILE *file = fopen(mdl->opt->model, "r");
if (file == NULL)
pfatal("cannot open input model file");
mdl_load(mdl, file);
// Open input and output files
FILE *fin = stdin, *fout = stdout;
if (mdl->opt->input != NULL) {
fin = fopen(mdl->opt->input, "r");
if (fin == NULL)
pfatal("cannot open input data file");
}
if (mdl->opt->output != NULL) {
fout = fopen(mdl->opt->output, "w");
if (fout == NULL)
pfatal("cannot open output data file");
}
// Do the labelling
info("* Label sequences\n");
tag_label(mdl, fin, fout);
info("* Done\n");
// And close files
if (mdl->opt->input != NULL)
fclose(fin);
if (mdl->opt->output != NULL)
fclose(fout);
}
开发者ID:tomwolfe,项目名称:wapiti-ruby,代码行数:35,代码来源:wapiti.c
示例8: findsrc
u_long findsrc(u_long dest)
{
struct sockaddr_in sinsrc, sindest;
int s, size;
if ((s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
pfatal("socket error");
memset(&sinsrc, 0, sizeof(struct sockaddr_in));
memset(&sindest, 0, sizeof(struct sockaddr_in));
sindest.sin_family = AF_INET;
sindest.sin_addr.s_addr = dest;
sindest.sin_port = htons(53); /* can be anything but zero */
if (connect(s, (struct sockaddr *)&sindest, sizeof(sindest)) < 0)
pfatal("connect");
size = sizeof(sinsrc);
if (getsockname(s, (struct sockaddr *)&sinsrc, &size) < 0)
pfatal("getsockname");
close(s);
debug("Determined source address of %s to reach %s\n",
iptos(sinsrc.sin_addr.s_addr), iptos(dest));
return sinsrc.sin_addr.s_addr;
}
开发者ID:ginggs,项目名称:maemo-tcptraceroute,代码行数:27,代码来源:datalink.c
示例9: copy_file
void
copy_file (char const *from, char const *to, struct stat *tost,
int to_flags, mode_t mode, bool to_dir_known_to_exist)
{
int tofd;
if (debug & 4)
say ("Copying %s %s to %s\n",
S_ISLNK (mode) ? "symbolic link" : "file",
quotearg_n (0, from), quotearg_n (1, to));
if (S_ISLNK (mode))
{
char *buffer = xmalloc (PATH_MAX);
if (readlink (from, buffer, PATH_MAX) < 0)
pfatal ("Can't read %s %s", "symbolic link", from);
if (symlink (buffer, to) != 0)
pfatal ("Can't create %s %s", "symbolic link", to);
if (tost && lstat (to, tost) != 0)
pfatal ("Can't get file attributes of %s %s", "symbolic link", to);
free (buffer);
}
else
{
assert (S_ISREG (mode));
tofd = create_file (to, O_WRONLY | O_BINARY | to_flags, mode,
to_dir_known_to_exist);
copy_to_fd (from, tofd);
if (tost && fstat (tofd, tost) != 0)
pfatal ("Can't get file attributes of %s %s", "file", to);
if (close (tofd) != 0)
write_fatal ();
}
}
开发者ID:infoburp,项目名称:patch,代码行数:35,代码来源:util.c
示例10: ifetch
/*
* Fetch a line from the input file, \n terminated, not necessarily \0.
*/
char *
ifetch(LINENUM line, int whichbuf)
{
if (line < 1 || line > input_lines) {
if (warn_on_invalid_line) {
say("No such line %ld in input file, ignoring\n", line);
warn_on_invalid_line = false;
}
return NULL;
}
if (using_plan_a)
return i_ptr[line];
else {
LINENUM offline = line % lines_per_buf;
LINENUM baseline = line - offline;
if (tiline[0] == baseline)
whichbuf = 0;
else if (tiline[1] == baseline)
whichbuf = 1;
else {
tiline[whichbuf] = baseline;
if (lseek(tifd, (off_t) (baseline / lines_per_buf *
tibuflen), SEEK_SET) < 0)
pfatal("cannot seek in the temporary input file");
if (read(tifd, tibuf[whichbuf], tibuflen) !=
(ssize_t) tibuflen)
pfatal("error reading tmp file %s", TMPINNAME);
}
return tibuf[whichbuf] + (tireclen * offline);
}
}
开发者ID:adityavs,项目名称:unix-history-make,代码行数:37,代码来源:inp.c
示例11: parser_wordlist
/* check if (arg) is a valid wordlist file */
void parser_wordlist(char *arg)
{
struct stat wrd_stat;
#ifdef HAVE_LIBMAGIC
const char *target_mime = "text/plain;";
#endif
if(arg == NULL)
fatal("called with NULL argument.");
else if(globals.options.dict == false)
fatal("dictionary features OFF. unable to parse wordlist.");
else if( stat(arg,&wrd_stat) ) // if can't get file stats
pfatal(arg);
else if( S_ISREG(wrd_stat.st_mode) == 0 ) // if isn't a regular file
fatal_long("\"%s\" is not a regular file.",arg);
else if( access(arg,R_OK))
pfatal(arg);
else
{
#ifdef HAVE_LIBMAGIC
if(strncmp(get_mime(arg),target_mime,strlen(target_mime)+1) != 0)
report(warning,"\"%s\" is not a \"%s\" file.",arg,target_mime);
#endif
if((globals.wordlist = (const char *) get_full_path(arg)) == NULL)
fatal("unable to resolve full path for wordlist.");
}
return;
}
开发者ID:napitek,项目名称:autohack,代码行数:29,代码来源:parser.c
示例12: net_init
/*
* It would be nice to use some of the infrastructure in network.c,
* but ServerNetInit only sets up UDP sockets. Maybe when we revisit
* and refactor...
*/
static void
net_init(void)
{
struct sockaddr_in name;
if ((sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
pfatal("Could not allocate socket");
name.sin_family = AF_INET;
name.sin_addr.s_addr = clientif.s_addr;
name.sin_port = htons(portnum);
if (bind(sock, (struct sockaddr *)&name, sizeof(name)) < 0) {
/*
* We reproduce ServerNetInit behavior here: if we cannot
* bind to the indicated port we exit with a special status
* so that the master server which invoked us can pick
* another.
*/
perror("Binding to socket");
close(sock);
exit(EADDRINUSE);
}
if (listen(sock, 128) < 0) {
close(sock);
pfatal("Could not listen on socket");
}
}
开发者ID:senseisimple,项目名称:emulab-stable,代码行数:32,代码来源:frisuploader.c
示例13: dodump
/*******************************************************************************
* Dumping
******************************************************************************/
static void dodump(mdl_t *mdl) {
// Load input model file
info("* Load model\n");
FILE *fin = stdin;
if (mdl->opt->input != NULL) {
fin = fopen(mdl->opt->input, "r");
if (fin == NULL)
pfatal("cannot open input data file");
}
mdl_load(mdl, fin);
if (mdl->opt->input != NULL)
fclose(fin);
// Open output file
FILE *fout = stdout;
if (mdl->opt->output != NULL) {
fout = fopen(mdl->opt->output, "w");
if (fout == NULL)
pfatal("cannot open output data file");
}
// Dump model
info("* Dump model\n");
const uint32_t Y = mdl->nlbl;
const uint64_t O = mdl->nobs;
const qrk_t *Qlbl = mdl->reader->lbl;
const qrk_t *Qobs = mdl->reader->obs;
char fmt[16];
sprintf(fmt, "%%.%df\n", mdl->opt->prec);
for (uint64_t o = 0; o < O; o++) {
const char *obs = qrk_id2str(Qobs, o);
bool empty = true;
if (mdl->kind[o] & 1) {
const double *w = mdl->theta + mdl->uoff[o];
for (uint32_t y = 0; y < Y; y++) {
if (!mdl->opt->all && w[y] == 0.0)
continue;
const char *ly = qrk_id2str(Qlbl, y);
fprintf(fout, "%s\t#\t%s\t", obs, ly);
fprintf(fout, fmt, w[y]);
empty = false;
}
}
if (mdl->kind[o] & 2) {
const double *w = mdl->theta + mdl->boff[o];
for (uint32_t d = 0; d < Y * Y; d++) {
if (!mdl->opt->all && w[d] == 0.0)
continue;
const char *ly = qrk_id2str(Qlbl, d % Y);
const char *lyp = qrk_id2str(Qlbl, d / Y);
fprintf(fout, "%s\t%s\t%s\t", obs, lyp, ly);
fprintf(fout, fmt, w[d]);
empty = false;
}
}
if (!empty)
fprintf(fout, "\n");
}
if (mdl->opt->output != NULL)
fclose(fout);
}
开发者ID:yanqingmen,项目名称:Wapiti,代码行数:62,代码来源:wapiti.c
示例14: load_conf
void
load_conf(struct opts *opts)
{
FILE *f;
struct conf_entry *conf, *e;
char *conf_file = opts->conf_file;
if (!opts->conf_file)
conf_file = DEFAULT_CONF_FILE;
f = fopen (conf_file, "r");
if (!f) {
if (opts->conf_file) {
pfatal ("can't open conf file '%s'", opts->conf_file);
} else {
pinfo ("can't open conf file '%s'", conf_file);
return;
}
}
conf = conf_parse (f);
if (!conf)
pfatal ("can't parse config file");
for (e = conf; e; e = e->next) {
if (!strcmp (e->key, "max-tries") && e->value) {
opts->max_tries = atoi (e->value);
} else if (!strcmp (e->key, "min-steady-state-interval") && e->value) {
opts->min_steady_state_interval = atoi (e->value);
} else if (!strcmp (e->key, "wait-between-tries") && e->value) {
opts->wait_between_tries = atoi (e->value);
} else if (!strcmp (e->key, "subprocess-tries") && e->value) {
opts->subprocess_tries = atoi (e->value);
} else if (!strcmp (e->key, "subprocess-wait-between-tries") && e->value) {
opts->subprocess_wait_between_tries = atoi (e->value);
} else if (!strcmp (e->key, "steady-state-interval") && e->value) {
opts->steady_state_interval = atoi (e->value);
} else if (!strcmp (e->key, "base-path") && e->value) {
opts->base_path = strdup (e->value);
if (!opts->base_path)
fatal ("out of memory for base path");
} else if (!strcmp (e->key, "should-sync-hwclock")) {
opts->should_sync_hwclock = e->value ? !strcmp(e->value, "yes") : 1;
} else if (!strcmp (e->key, "should-load-disk")) {
opts->should_load_disk = e->value ? !strcmp(e->value, "yes") : 1;
} else if (!strcmp (e->key, "should-save-disk")) {
opts->should_save_disk = e->value ? !strcmp(e->value, "yes") : 1;
} else if (!strcmp (e->key, "should-netlink")) {
opts->should_netlink = e->value ? !strcmp(e->value, "yes") : 1;
} else if (!strcmp (e->key, "dry-run")) {
opts->dry_run = e->value ? !strcmp(e->value, "yes") : 1;
} else if (!strcmp (e->key, "jitter") && e->value) {
opts->jitter = atoi (e->value);
} else if (!strcmp (e->key, "verbose")) {
verbose = e->value ? !strcmp(e->value, "yes") : 1;
} else if (!strcmp (e->key, "source")) {
e = parse_source(opts, e);
}
}
}
开发者ID:pjbakker,项目名称:tlsdate,代码行数:57,代码来源:tlsdated.c
示例15: route
void
route(const char * gw)
{
int ret;
struct uinet_socket * so;
struct rt_msghdr * rtm;
struct uinet_sockaddr * sa;
struct uinet_sockaddr_in * sin;
char buf[4096];
errno = 0;
ret = uinet_socreate(uinet_instance_default(), UINET_PF_ROUTE, &so, UINET_SOCK_RAW, 0);
if (ret) {
errno = ret;
pfatal("uinet_socreate");
}
memset(buf, 0, sizeof(buf));
rtm = (struct rt_msghdr *)buf;
rtm->rtm_version = RTM_VERSION;
rtm->rtm_type = RTM_ADD;
rtm->rtm_flags = RTF_GATEWAY;
rtm->rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK;
rtm->rtm_pid = getpid();
rtm->rtm_seq = 1234;
sa = (struct uinet_sockaddr *)(rtm + 1);
sin = (struct uinet_sockaddr_in *)(sa);
sin->sin_len = sizeof(struct uinet_sockaddr_in);
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = inet_addr("0.0.0.0");
sa = (struct uinet_sockaddr *)((unsigned char *)(sa) + ROUNDUP(sa->sa_len));
sin = (struct uinet_sockaddr_in *)(sa);
sin->sin_len = sizeof(struct uinet_sockaddr_in);
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = inet_addr(gw);
sa = (struct uinet_sockaddr *)((unsigned char *)(sa) + ROUNDUP(sa->sa_len));
sin = (struct uinet_sockaddr_in *)(sa);
sin->sin_len = 0;
sin->sin_family = AF_INET;
sa = (struct uinet_sockaddr *)((unsigned char *)(sa) + ROUNDUP(sa->sa_len));
rtm->rtm_msglen = (char *)sa - buf;
errno = socket_write(so, buf, rtm->rtm_msglen);
if (errno) pfatal("socket_write");
/* probably should loop through reply messages and see whether
the setting of the route succeeded; right now we just assume
it worked. */
return;
}
开发者ID:f0r34chb3t4,项目名称:pbscan,代码行数:56,代码来源:route.c
示例16: parser_outfile
/* check if (arg) is a vlid output file */
void parser_outfile(char *arg)
{
struct stat out_stat;
struct statvfs disk_stat;
char *path=NULL;
FILE *fout;
if(arg == NULL)
fatal("called with NULL argument.");
else if(stat(arg,&out_stat) == 0)
{
if(S_ISREG(out_stat.st_mode))
{
if((path = get_full_path(arg)) != NULL)
{
if(access(path,W_OK) == 0)
{
if(statvfs(path,&disk_stat) == 0)
{
if((disk_stat.f_bsize * disk_stat.f_bavail) > MIN_FREE_SPACE )
{
argcpy(&(globals.outfile),path,strlen(path)+1);
}
else
fatal_long("we need at least %lu free bytes for writing some output.",MIN_FREE_SPACE);
}
else
pfatal(path);
}
else
pfatal(path);
}
else
fatal("unable to find full path for outfile.");
}
else
fatal_long("file \"%s\" isn't a regular file.",arg);
}
else if(errno == ENOENT)
{
if((fout = fopen(arg,"w+")) != NULL)
{
fclose(fout);
parser_outfile(arg); // restart
}
else
pfatal(arg);
}
else
pfatal(arg);
if(path!=NULL)
free((void *) path);
return;
}
开发者ID:napitek,项目名称:autohack,代码行数:57,代码来源:parser.c
示例17: text_mode_fseek
/*
* We need this because regular seek does not work in text mode
*/
void
text_mode_fseek(FILE *stream, file_offset offset, int ptrname)
{
/* We do not support SEEK_CUR, SEEK_END etc in text mode */
assert(ptrname == SEEK_SET);
if (fseek (stream, 0, SEEK_SET) != 0)
pfatal ("fseek");
while (ftell(stream) != offset) {
if (getc(stream) == EOF)
pfatal ("fseek");
}
}
开发者ID:AlexShiLucky,项目名称:bitkeeper,代码行数:15,代码来源:util.c
示例18: qrk_load
/* qrk_load:
* Load a list of key from the given file and add them to the map. Each lines
* of the file is taken as a single key and mapped to the next available id if
* not already present. If all keys are single lines and the given map is
* initilay empty, this will load a map exactly as saved by qrk_save.
*/
void qrk_load(qrk_t *qrk, FILE *file) {
uint64_t cnt = 0;
if (fscanf(file, "#qrk#%"SCNu64"\n", &cnt) != 1) {
if (ferror(file) != 0)
pfatal("cannot read from file");
pfatal("invalid format");
}
for (uint64_t n = 0; n < cnt; ++n) {
char *str = ns_readstr(file);
qrk_str2id(qrk, str);
free(str);
}
}
开发者ID:elif021,项目名称:Wapiti,代码行数:19,代码来源:quark.c
示例19: get_raw_fd
int
get_raw_fd()
{
int fd, ret, one;
fd = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP);
if (fd < 0) pfatal("socket");
one = 1;
ret = setsockopt(fd, IPPROTO_IP, IP_HDRINCL, &one, sizeof(one));
if (ret < 0) pfatal("setsockopt");
return fd;
}
开发者ID:f0r34chb3t4,项目名称:pbscan,代码行数:14,代码来源:utils.c
示例20: version_get
/* Get FILENAME from version control system CS. The file already exists if
EXISTS. Only readonly access is needed if READONLY.
Use the command GETBUF to actually get the named file.
Store the resulting file status into *FILESTAT.
Return true if successful. */
bool
version_get (char const *filename, char const *cs, bool exists, bool readonly,
char const *getbuf, struct stat *filestat)
{
if (patch_get < 0)
{
ask ("Get file %s from %s%s? [y] ",
quotearg (filename), cs, readonly ? "" : " with lock");
if (*buf == 'n')
return 0;
}
if (dry_run)
{
if (! exists)
fatal ("can't do dry run on nonexistent version-controlled file %s; invoke '%s' and try again",
quotearg (filename), getbuf);
}
else
{
if (verbosity == VERBOSE)
say ("Getting file %s from %s%s...\n", quotearg (filename),
cs, readonly ? "" : " with lock");
if (systemic (getbuf) != 0)
fatal ("Can't get file %s from %s", quotearg (filename), cs);
if (stat (filename, filestat) != 0)
pfatal ("%s", quotearg (filename));
}
return 1;
}
开发者ID:infoburp,项目名称:patch,代码行数:36,代码来源:util.c
注:本文中的pfatal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论