本文整理汇总了C++中check_header函数的典型用法代码示例。如果您正苦于以下问题:C++ check_header函数的具体用法?C++ check_header怎么用?C++ check_header使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_header函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check_args
/* ---------------------------------------------------------------------- */
void check_args() {
/* check if filled elevation grid name is valid */
if (G_legal_filename (opt->filled_grid) < 0) {
G_fatal_error(_("<%s> is an illegal file name"), opt->filled_grid);
}
/* check if output grid names are valid */
if (G_legal_filename (opt->dir_grid) < 0) {
G_fatal_error(_("<%s> is an illegal file name"), opt->dir_grid);
}
if (G_legal_filename (opt->filled_grid) < 0) {
G_fatal_error(_("<%s> is an illegal file name"), opt->filled_grid);
}
if (G_legal_filename (opt->flowaccu_grid) < 0) {
G_fatal_error(_("<%s> is an illegal file name"), opt->flowaccu_grid);
}
if (G_legal_filename (opt->watershed_grid) < 0) {
G_fatal_error(_("<%s> is an illegal file name"), opt->watershed_grid);
}
#ifdef OUTPU_TCI
if (G_legal_filename (opt->tci_grid) < 0) {
G_fatal_error(_("<%s> is an illegal file name"), opt->tci_grid);
}
#endif
/* check compatibility with region */
check_header(opt->elev_grid);
/* what else ? */
}
示例2: copen
int
copen(const char *fname, int mode)
{
int fd;
struct sd *s = 0;
if ( ((fd = open(fname, mode)) == -1) || (mode != O_RDONLY) )
/* compression only for read */
return(fd);
ss[fd] = s = malloc(sizeof(struct sd));
if (s == 0)
goto errout;
memset(s, 0, sizeof(struct sd));
if (inflateInit2(&(s->stream), -15) != Z_OK)
goto errout;
s->stream.next_in = s->inbuf = (unsigned char*)malloc(Z_BUFSIZE);
if (s->inbuf == 0) {
inflateEnd(&(s->stream));
goto errout;
}
s->fd = fd;
check_header(s); /* skip the .gz header */
return(fd);
errout:
if (s != 0)
free(s);
close(fd);
return (-1);
}
示例3: flush_inbody_header_accum
static void flush_inbody_header_accum(struct mailinfo *mi)
{
if (!mi->inbody_header_accum.len)
return;
assert(check_header(mi, &mi->inbody_header_accum, mi->s_hdr_data, 0));
strbuf_reset(&mi->inbody_header_accum);
}
示例4: l_dissect_udp
static int l_dissect_udp(lua_State *L)
{
header_t *header = NULL;
udp_t *udp = NULL;
header = check_header(L, 1);
udp = (udp_t *)header->data;
lua_newtable(L);
lua_pushstring(L, "src_port");
lua_pushnumber(L, ntohs(udp->src_port));
lua_settable(L, -3);
lua_pushstring(L, "dst_port");
lua_pushnumber(L, ntohs(udp->dest_port));
lua_settable(L, -3);
lua_pushstring(L, "payload_len");
lua_pushnumber(L, ntohs(udp->len));
lua_settable(L, -3);
lua_pushstring(L, "cksum");
lua_pushnumber(L, ntohs(udp->checksum));
lua_settable(L, -3);
se_setro(L);
return 1;
}
示例5: dir_test
void dir_test()
{
ar::tar::header head;
head.format = ar::tar::pax;
head.type_flag = ar::tar::type_flag::directory;
head.path = "dir";
head.modified_time = fs_ex::timestamp(std::time(0), 123456789);
head.access_time = fs_ex::timestamp(1, 123456789);
head.change_time = fs_ex::timestamp(12345, 0);
head.file_size = 0;
head.permissions = 0123;
head.comment = "test comment";
io_ex::tmp_file archive;
ar::basic_tar_file_sink<
io_ex::dont_close_device<io_ex::tmp_file>
> sink(io_ex::dont_close(archive));
sink.create_entry(head);
sink.close();
sink.close_archive();
io::seek(archive, 0, BOOST_IOS::beg);
ar::basic_tar_file_source<io_ex::tmp_file> src(archive);
BOOST_CHECK(src.next_entry());
check_header(head, src.header());
BOOST_CHECK(!src.next_entry());
}
示例6: cw_log
static struct cw_filestream *au_open(FILE *f)
{
struct cw_filestream *tmp;
if (!(tmp = malloc(sizeof(struct cw_filestream))))
{
cw_log(LOG_ERROR, "Out of memory\n");
return NULL;
}
memset(tmp, 0, sizeof(struct cw_filestream));
if (check_header(f) < 0)
{
free(tmp);
return NULL;
}
if (cw_mutex_lock(&au_lock))
{
cw_log(LOG_WARNING, "Unable to lock au count\n");
free(tmp);
return NULL;
}
tmp->f = f;
cw_fr_init_ex(&tmp->fr, CW_FRAME_VOICE, CW_FORMAT_ULAW, NULL);
tmp->fr.data = tmp->buf;
/* datalen will vary for each frame */
tmp->fr.src = name;
localusecnt++;
cw_mutex_unlock(&au_lock);
cw_update_use_count();
return tmp;
}
示例7: eapi_load
int eapi_load(easyflash_cart_t * cart, const char* filename)
{
unsigned char buf[EAPI_SIZE + 2];
unsigned int load_addr = 0;
util_message("Loading EAPI '%s'...", filename);
if (util_prgfile_load(filename, buf, EAPI_SIZE, 0, &load_addr) < 0) {
return -1;
}
if (load_addr != EAPI_FILE_LOAD_ADDR) {
util_error("load address $%04x, expecting $%04x!", load_addr, EAPI_FILE_LOAD_ADDR);
return -1;
}
if (check_header(buf) != 0) {
util_error("file '%s' doesn't have EAPI header!", filename);
return -1;
}
memcpy(eapi_data, buf, EAPI_SIZE);
cart->main_flash_state |= MAIN_STATE_HAVE_EAPI;
return 0;
}
示例8: try_load
/* Try to load a savefile */
static bool try_load(ang_file *f, const struct blockinfo *loaders) {
struct blockheader b;
errr err;
if (!check_header(f)) {
note("Savefile is corrupted -- incorrect file header.");
return FALSE;
}
/* Get the next block header */
while ((err = next_blockheader(f, &b)) == 0) {
loader_t loader = find_loader(&b, loaders);
if (!loader) {
note("Savefile block can't be read.");
note("Maybe try and load the savefile in an earlier version of Angband.");
return FALSE;
}
if (!load_block(f, &b, loader)) {
note(format("Savefile corrupted - Couldn't load block %s", b.name));
return FALSE;
}
}
if (err == -1) {
note("Savefile is corrupted -- block header mangled.");
return FALSE;
}
/* XXX Reset cause of death */
if (p_ptr->chp >= 0)
my_strcpy(p_ptr->died_from, "(alive and well)", sizeof(p_ptr->died_from));
return TRUE;
}
示例9: init_zip
static gboolean
init_zip (GsfInputGZip *gzip, GError **err)
{
gsf_off_t cur_pos;
if (Z_OK != inflateInit2 (&(gzip->stream), -MAX_WBITS)) {
if (err != NULL)
*err = g_error_new (gsf_input_error_id (), 0,
"Unable to initialize zlib");
return TRUE;
}
cur_pos = gsf_input_tell (gzip->source);
if (gsf_input_seek (gzip->source, 0, G_SEEK_SET)) {
if (err)
*err = g_error_new (gsf_input_error_id (), 0,
"Failed to rewind source");
return TRUE;
}
if (check_header (gzip) != FALSE) {
if (err != NULL)
*err = g_error_new (gsf_input_error_id (), 0,
"Invalid gzip header");
if (gsf_input_seek (gzip->source, cur_pos, G_SEEK_SET)) {
g_warning ("attempt to restore position failed ??");
}
return TRUE;
}
return FALSE;
}
示例10: unicode_test
void unicode_test()
{
ar::lha::wheader head;
head.level = 2;
head.update_time = std::time(0);
head.attributes = ar::msdos::attributes::read_only;
head.path = L"\x3053\x3093\x306B\x3061\x306F/\x4F60\x597D.txt";
head.os = 'M';
io_ex::tmp_file archive;
ar::basic_lzh_file_sink<
io_ex::dont_close_device<io_ex::tmp_file>,
fs::wpath
> sink(io_ex::dont_close(archive));
sink.create_entry(head);
sink.close();
sink.close_archive();
io::seek(archive, 0, BOOST_IOS::beg);
ar::basic_lzh_file_source<io_ex::tmp_file,fs::wpath> src(archive);
BOOST_CHECK(src.next_entry());
check_header(head, src.header());
BOOST_CHECK(!src.next_entry());
}
示例11: handle_commit_msg
static int handle_commit_msg(char *line, unsigned linesize)
{
static int still_looking = 1;
char *endline = line + linesize;
if (!cmitmsg)
return 0;
if (still_looking) {
char *cp = line;
if (isspace(*line)) {
for (cp = line + 1; *cp; cp++) {
if (!isspace(*cp))
break;
}
if (!*cp)
return 0;
}
if ((still_looking = check_header(cp, endline - cp, s_hdr_data, 0)) != 0)
return 0;
}
/* normalize the log message to UTF-8. */
if (metainfo_charset)
convert_to_utf8(line, endline - line, charset);
if (patchbreak(line)) {
fclose(cmitmsg);
cmitmsg = NULL;
return 1;
}
fputs(line, cmitmsg);
return 0;
}
示例12: remote_read
static int remote_read(apacket *p, atransport *t)
{
if(usb_read(t->usb, &p->msg, sizeof(amessage))){
D("remote usb: read terminated (message)\n");
return -1;
}
fix_endians(p);
if(check_header(p)) {
D("remote usb: check_header failed\n");
return -1;
}
if(p->msg.data_length) {
if(usb_read(t->usb, p->data, p->msg.data_length)){
D("remote usb: terminated (data)\n");
return -1;
}
}
if(check_data(p)) {
D("remote usb: check_data failed\n");
return -1;
}
return 0;
}
示例13: check_header
int
basic_parser::do_header_field (char const* in, std::size_t bytes)
{
check_header();
field_.append (static_cast <char const*> (in), bytes);
return 0;
}
示例14: ns__echoString
int ns__echoString(struct soap *soap, char *str, char **res)
{ /* Get Header info and setup response Header */
if (check_header(soap))
{ printf("Malformed header\n");
return SOAP_FAULT; /* there was a problem */
}
/* If message with MessageID already received, ignore it */
if (check_received(soap->header->wsa__MessageID))
{ printf("Request message %s already received\n", soap->header->wsa__MessageID);
return SOAP_STOP;
}
printf("Request message %s accepted\n", soap->header->wsa__MessageID);
/* Check ReplyTo has Address */
if (!soap->header->wsa__ReplyTo || !soap->header->wsa__ReplyTo->Address)
return soap_sender_fault(soap, "No WS-Addressing ReplyTo address", NULL);
/* Copy Header info into response Header */
soap->header->wsa__To = soap->header->wsa__ReplyTo->Address;
/* Add info to response Header */
soap->header->wsa__MessageID = soap_strdup(soap, soap_int2s(soap, id_count++));
soap->header->wsa__Action = "http://genivia.com/udp/echoStringResponse";
/* Copy request string into response string */
printf("Response message %s returned\n", soap->header->wsa__MessageID);
*res = str;
return SOAP_OK;
}
示例15: remote_read
static int remote_read(apacket *p, atransport *t)
{
if(readx(t->sfd, &p->msg, sizeof(amessage))){
D("remote local: read terminated (message)\n");
return -1;
}
fix_endians(p);
#if 0 && defined __ppc__
D("read remote packet: %04x arg0=%0x arg1=%0x data_length=%0x data_check=%0x magic=%0x\n",
p->msg.command, p->msg.arg0, p->msg.arg1, p->msg.data_length, p->msg.data_check, p->msg.magic);
#endif
if(check_header(p)) {
D("bad header: terminated (data)\n");
return -1;
}
if(readx(t->sfd, p->data, p->msg.data_length)){
D("remote local: terminated (data)\n");
return -1;
}
if(check_data(p)) {
D("bad data: terminated (data)\n");
return -1;
}
return 0;
}