本文整理汇总了C++中read_buf函数的典型用法代码示例。如果您正苦于以下问题:C++ read_buf函数的具体用法?C++ read_buf怎么用?C++ read_buf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_buf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: decode_lockowner
static __be32 decode_lockowner(struct xdr_stream *xdr, struct cb_notify_lock_args *args)
{
__be32 *p;
unsigned int len;
p = read_buf(xdr, 12);
if (unlikely(p == NULL))
return htonl(NFS4ERR_BADXDR);
p = xdr_decode_hyper(p, &args->cbnl_owner.clientid);
len = be32_to_cpu(*p);
p = read_buf(xdr, len);
if (unlikely(p == NULL))
return htonl(NFS4ERR_BADXDR);
/* Only try to decode if the length is right */
if (len == 20) {
p += 2; /* skip "lock id:" */
args->cbnl_owner.s_dev = be32_to_cpu(*p++);
xdr_decode_hyper(p, &args->cbnl_owner.id);
args->cbnl_valid = true;
} else {
args->cbnl_owner.s_dev = 0;
args->cbnl_owner.id = 0;
args->cbnl_valid = false;
}
return 0;
}
开发者ID:AshishNamdev,项目名称:linux,代码行数:29,代码来源:callback_xdr.c
示例2: GetId
pid_t LightProcess::waitpid(pid_t pid, int *stat_loc, int options,
int timeout) {
if (!Available()) {
// light process is not really there
return ::waitpid(pid, stat_loc, options);
}
int id = GetId();
Lock lock(g_procs[id].m_procMutex);
fprintf(g_procs[id].m_fout, "waitpid\n%lld %d %d\n", (int64)pid, options,
timeout);
fflush(g_procs[id].m_fout);
char buf[BUFFER_SIZE];
read_buf(g_procs[id].m_fin, buf);
if (!buf[0]) return -1;
int64 ret;
int stat;
sscanf(buf, "%lld %d", &ret, &stat);
*stat_loc = stat;
if (ret < 0) {
read_buf(g_procs[id].m_fin, buf);
sscanf(buf, "%d", &errno);
}
return (pid_t)ret;
}
开发者ID:HyeongKyu,项目名称:hiphop-php,代码行数:27,代码来源:light_process.cpp
示例3: GetId
int LightProcess::pclose(FILE *f) {
if (!Available()) {
return ::pclose(f);
}
int id = GetId();
Lock lock(g_procs[id].m_procMutex);
std::map<int64_t, int64_t>::iterator it = g_procs[id].m_popenMap.find((int64_t)f);
if (it == g_procs[id].m_popenMap.end()) {
// try to close it with normal pclose
return ::pclose(f);
}
int64_t f2 = it->second;
g_procs[id].m_popenMap.erase((int64_t)f);
fclose(f);
fprintf(g_procs[id].m_fout, "pclose\n%" PRId64 "\n", f2);
fflush(g_procs[id].m_fout);
char buf[BUFFER_SIZE];
read_buf(g_procs[id].m_fin, buf);
int ret = -1;
sscanf(buf, "%d", &ret);
if (ret < 0) {
read_buf(g_procs[id].m_fin, buf);
sscanf(buf, "%d", &errno);
}
return ret;
}
开发者ID:Alienfeel,项目名称:hhvm,代码行数:30,代码来源:light-process.cpp
示例4: decode_layoutrecall_args
static __be32 decode_layoutrecall_args(struct svc_rqst *rqstp,
struct xdr_stream *xdr,
struct cb_layoutrecallargs *args)
{
__be32 *p;
__be32 status = 0;
uint32_t iomode;
args->cbl_addr = svc_addr(rqstp);
p = read_buf(xdr, 4 * sizeof(uint32_t));
if (unlikely(p == NULL)) {
status = htonl(NFS4ERR_BADXDR);
goto out;
}
args->cbl_layout_type = ntohl(*p++);
/* Depite the spec's xdr, iomode really belongs in the FILE switch,
* as it is unusable and ignored with the other types.
*/
iomode = ntohl(*p++);
args->cbl_layoutchanged = ntohl(*p++);
args->cbl_recall_type = ntohl(*p++);
if (args->cbl_recall_type == RETURN_FILE) {
args->cbl_range.iomode = iomode;
status = decode_fh(xdr, &args->cbl_fh);
if (unlikely(status != 0))
goto out;
p = read_buf(xdr, 2 * sizeof(uint64_t));
if (unlikely(p == NULL)) {
status = htonl(NFS4ERR_BADXDR);
goto out;
}
p = xdr_decode_hyper(p, &args->cbl_range.offset);
p = xdr_decode_hyper(p, &args->cbl_range.length);
status = decode_stateid(xdr, &args->cbl_stateid);
if (unlikely(status != 0))
goto out;
} else if (args->cbl_recall_type == RETURN_FSID) {
p = read_buf(xdr, 2 * sizeof(uint64_t));
if (unlikely(p == NULL)) {
status = htonl(NFS4ERR_BADXDR);
goto out;
}
p = xdr_decode_hyper(p, &args->cbl_fsid.major);
p = xdr_decode_hyper(p, &args->cbl_fsid.minor);
} else if (args->cbl_recall_type != RETURN_ALL) {
status = htonl(NFS4ERR_BADXDR);
goto out;
}
dprintk("%s: ltype 0x%x iomode %d changed %d recall_type %d\n",
__func__,
args->cbl_layout_type, iomode,
args->cbl_layoutchanged, args->cbl_recall_type);
out:
dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
return status;
}
开发者ID:JamesAng,项目名称:lx-sk,代码行数:59,代码来源:callback_xdr.c
示例5: read_packet
/* read data from source, determine underlying protocol
* (if not already known); and process the packet
* if needed (for RTP - register packet)
*
* return the number of octets read from the source
* into the buffer
*/
static ssize_t
read_packet( struct dstream_ctx* spc, int fd, char* buf, size_t len )
{
ssize_t n = -1;
size_t chunk_len = len;
assert( spc && buf && len );
assert( fd > 0 );
/* if *RAW* data specified - read AS IS
* and exit */
if( UPXDT_RAW == spc->stype ) {
return read_buf( fd, buf, len, g_flog );
}
/* if it is (or *could* be) RTP, read only MTU bytes
*/
if( (spc->stype == UPXDT_RTP_TS) || (spc->flags & F_CHECK_FMT) )
chunk_len = (len > spc->mtu) ? spc->mtu : len;
#ifdef UDPXY_FILEIO
if( spc->flags & F_FILE_INPUT ) {
assert( !buf_overrun( buf, len, 0, chunk_len, g_flog ) );
n = read_frecord( fd, buf, chunk_len, &(spc->stype), g_flog );
if( n <= 0 ) return n;
}
else
#endif /* UDPXY_FILEIO */
{
assert( !buf_overrun(buf, len, 0, chunk_len, g_flog) );
n = read_buf( fd, buf, chunk_len, g_flog );
if( n <= 0 ) return n;
}
if( spc->flags & F_CHECK_FMT ) {
spc->stype = get_mstream_type( buf, n, g_flog );
switch (spc->stype) {
case UPXDT_RTP_TS:
/* scattered: exclude RTP headers */
spc->flags |= F_SCATTERED; break;
case UPXDT_TS:
spc->flags &= ~F_SCATTERED; break;
default:
spc->stype = UPXDT_RAW;
TRACE( (void)tmfputs( "Unrecognized stream type\n", g_flog ) );
break;
} /* switch */
TRACE( (void)tmfprintf( g_flog, "Established stream as [%s]\n",
fmt2str( spc->stype ) ) );
spc->flags &= ~F_CHECK_FMT;
}
if( spc->flags & F_SCATTERED )
if( -1 == register_packet( spc, buf, n ) ) return -1;
return n;
}
开发者ID:Einheri,项目名称:wl500g,代码行数:66,代码来源:dpkt.c
示例6: read_cmd
static int read_cmd(byte *buf)
{
int len;
if (read_buf(0, buf, 2) != 2)
return 0;
len = dec_int16(buf);
if (read_buf(0, buf, len) != len)
return 0;
return 1;
}
开发者ID:0879dc,项目名称:ejabberd,代码行数:10,代码来源:epam.c
示例7: init_mysql_conf
// read the configue file
void init_mysql_conf() {
FILE *fp;
char buf[BUFFER_SIZE];
host_name[0] = 0;
user_name[0] = 0;
password[0] = 0;
db_name[0] = 0;
port_number = 3306;
max_running = 3;
sleep_time = 3;
strcpy(java_xmx, "-Xmx256M");
fp = fopen("./etc/judge.conf", "r");
while (fgets(buf, BUFFER_SIZE - 1, fp)) {
read_buf(buf,"OJ_HOST_NAME",host_name);
read_buf(buf, "OJ_USER_NAME",user_name);
read_buf(buf, "OJ_PASSWORD",password);
read_buf(buf, "OJ_DB_NAME",db_name);
read_int(buf , "OJ_PORT_NUMBER", &port_number);
read_int(buf, "OJ_JAVA_TIME_BONUS", &java_time_bonus);
read_int(buf, "OJ_JAVA_MEMORY_BONUS", &java_memory_bonus);
read_int(buf , "OJ_SIM_ENABLE", &sim_enable);
read_buf(buf,"OJ_JAVA_XMX",java_xmx);
read_int(buf,"OJ_HTTP_JUDGE",&http_judge);
read_buf(buf,"OJ_HTTP_BASEURL",http_baseurl);
read_buf(buf,"OJ_HTTP_USERNAME",http_username);
read_buf(buf,"OJ_HTTP_PASSWORD",http_password);
read_int(buf , "OJ_OI_MODE", &oi_mode);
}
}
开发者ID:hanjinze,项目名称:neuoj,代码行数:31,代码来源:judger.cpp
示例8: decode_compound_hdr_arg
static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound_hdr_arg *hdr)
{
__be32 *p;
__be32 status;
status = decode_string(xdr, &hdr->taglen, &hdr->tag);
if (unlikely(status != 0))
return status;
if (hdr->taglen > CB_OP_TAGLEN_MAXSZ - 12) {
printk("NFS: NFSv4 CALLBACK %s: client sent tag of length %u\n",
__func__, hdr->taglen);
return htonl(NFS4ERR_RESOURCE);
}
p = read_buf(xdr, 12);
if (unlikely(p == NULL))
return htonl(NFS4ERR_RESOURCE);
hdr->minorversion = ntohl(*p++);
if (hdr->minorversion <= 1) {
hdr->cb_ident = ntohl(*p++);
} else {
pr_warn_ratelimited("NFS: %s: NFSv4 server callback with "
"illegal minor version %u!\n",
__func__, hdr->minorversion);
return htonl(NFS4ERR_MINOR_VERS_MISMATCH);
}
hdr->nops = ntohl(*p);
dprintk("%s: minorversion %d nops %d\n", __func__,
hdr->minorversion, hdr->nops);
return 0;
}
开发者ID:Albinoman887,项目名称:pyramid-3.4.10,代码行数:32,代码来源:callback_xdr.c
示例9: get_next_line
int get_next_line(int const fd, char **line)
{
static t_stock *d;
int ret;
ret = 1;
if (!line)
return (-1);
*line = NULL;
if (!d)
{
if (!(d = (t_stock*)malloc(sizeof(t_stock))))
return (-1);
if (!((d)->buff = (char **)malloc(sizeof(char *) * 255)))
return (-1);
}
if (d->i[fd] >= d->s[fd] || !d->s[fd])
{
if (!d->buff[fd] &&
!((d)->buff[fd] = (char*)malloc(sizeof(char) * (BUFF_SIZE))))
return (-1);
ret = read_buf(fd, d);
if (ret == -1 || ret == 0)
return (ret);
}
ret = gnl_do(fd, line, d);
return (ret);
}
开发者ID:lord0gnome,项目名称:get_next_line,代码行数:28,代码来源:get_next_line.c
示例10: gnl_do
int gnl_do(int const fd, char **line, t_stock *d)
{
t_ints v;
v.size = 0;
v.ret = 42;
while (v.ret == 42)
{
if (d->i[fd] >= d->s[fd])
v.ret = read_buf(fd, d);
if (v.ret == -1 || v.ret == 0)
{
if (v.ret == 0)
v.ret = 1;
return (v.ret);
}
v.ret = 42;
v.i = 0;
while (d->buff[fd][v.i + d->i[fd]] != '\n' && d->i[fd] + v.i < d->s[fd])
v.i++;
if (!(handle_i(&v, d, line, fd)))
return (-1);
}
return (v.ret);
}
开发者ID:lord0gnome,项目名称:get_next_line,代码行数:25,代码来源:get_next_line.c
示例11: fstyp_zfs
int
fstyp_zfs(FILE *fp, char *label, size_t labelsize)
{
vdev_label_t *vdev_label = NULL;
vdev_phys_t *vdev_phys;
char *zpool_name = NULL;
nvlist_t *config = NULL;
int err = 0;
/*
* Read in the first ZFS vdev label ("L0"), located at the beginning
* of the vdev and extract the pool name from it.
*
* TODO: the checksum of label should be validated.
*/
vdev_label = (vdev_label_t *)read_buf(fp, 0, sizeof(*vdev_label));
if (vdev_label == NULL)
return (1);
vdev_phys = &(vdev_label->vl_vdev_phys);
if ((nvlist_unpack(vdev_phys->vp_nvlist, sizeof(vdev_phys->vp_nvlist),
&config, 0)) == 0 &&
(nvlist_lookup_string(config, "name", &zpool_name) == 0)) {
strlcpy(label, zpool_name, labelsize);
} else
err = 1;
nvlist_free(config);
free(vdev_label);
return (err);
}
开发者ID:ngkaho1234,项目名称:freebsd,代码行数:33,代码来源:zfs.c
示例12: LookupInsert
void LookupInsert(Cache_Annotation *cache, String *name)
{
// use a separate scratch buffer for annotation CFG lookups.
// reading information about bounds can cause a lookup on the block
// or initializer CFGs.
static Buffer annot_buf;
name->IncRef(cache);
if (!DoLookupTransaction(m_db_name, name->Value(), &annot_buf)) {
cache->Insert(name, NULL);
return;
}
Vector<BlockCFG*> *cfg_list = new Vector<BlockCFG*>();
Buffer read_buf(annot_buf.base, annot_buf.pos - annot_buf.base);
BlockCFG::ReadList(&read_buf, cfg_list);
annot_buf.Reset();
for (size_t ind = 0; ind < cfg_list->Size(); ind++)
cfg_list->At(ind)->MoveRef(NULL, cfg_list);
cache->Insert(name, cfg_list);
}
开发者ID:wh5a,项目名称:xgill,代码行数:25,代码来源:storage.cpp
示例13: get_next_line
int get_next_line(int const fd, char **line)
{
static t_list *lst = NULL;
t_mem *mem;
int ret;
char *buf;
if (!line || !(BUFF_SIZE > 0) || !(mem = get_mem(fd, &lst)))
return (-1);
if (!(ret = read_mem(mem, line)))
{
if (!(buf = ft_strnew(BUFF_SIZE)))
return (-1);
while ((ret = read(fd, buf, BUFF_SIZE)))
{
if (ret < 0)
return (free_str_return(buf, -1));
buf[ret] = '\0';
if ((ret = read_buf(buf, mem, line)))
return (free_str_return(buf, ret));
}
if (**line)
return (free_str_return(buf, 1));
return (free_str_return(buf, 0));
}
return (ret);
}
开发者ID:NSSX,项目名称:PPPPPPP,代码行数:27,代码来源:get_next_line.c
示例14: decode_compound_hdr_arg
static unsigned decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound_hdr_arg *hdr)
{
uint32_t *p;
unsigned int minor_version;
unsigned status;
status = decode_string(xdr, &hdr->taglen, &hdr->tag);
if (unlikely(status != 0))
return status;
/* We do not like overly long tags! */
if (hdr->taglen > CB_OP_TAGLEN_MAXSZ-12 || hdr->taglen < 0) {
printk("NFSv4 CALLBACK %s: client sent tag of length %u\n",
__FUNCTION__, hdr->taglen);
return htonl(NFS4ERR_RESOURCE);
}
p = read_buf(xdr, 12);
if (unlikely(p == NULL))
return htonl(NFS4ERR_RESOURCE);
minor_version = ntohl(*p++);
/* Check minor version is zero. */
if (minor_version != 0) {
printk(KERN_WARNING "%s: NFSv4 server callback with illegal minor version %u!\n",
__FUNCTION__, minor_version);
return htonl(NFS4ERR_MINOR_VERS_MISMATCH);
}
hdr->callback_ident = ntohl(*p++);
hdr->nops = ntohl(*p);
return 0;
}
开发者ID:FatSunHYS,项目名称:OSCourseDesign,代码行数:29,代码来源:callback_xdr.c
示例15: read_ts_file
/* read a sequence of MPEG TS packets (to fit into the given buffer)
*/
static ssize_t
read_ts_file( int fd, char* data, const size_t len, FILE* log )
{
const size_t pkt_len = ((len - 1) / TS_SEG_LEN) * TS_SEG_LEN;
off_t k = 0;
u_int bad_frg = 0;
ssize_t n = -1;
assert( (fd > 0) && data && len && log);
assert( !buf_overrun( data, len, 0, pkt_len, log ) );
n = read_buf( fd, data, pkt_len, log );
if( n <= 0 ) return n;
if( 0 != sizecheck( "Bad TS packet stream",
pkt_len, n, log, __func__ ) )
return -1;
/* make sure we've read TS records, not random data
*/
for( k = 0; k < (off_t)pkt_len; k += TS_SEG_LEN ) {
if( -1 == ts_sigcheck( data[k], k, (u_long)pkt_len,
log, __func__ ) ) {
++bad_frg;
}
}
return (bad_frg ? -1 : n);
}
开发者ID:Einheri,项目名称:wl500g,代码行数:31,代码来源:dpkt.c
示例16: fstyp_ext2fs
int
fstyp_ext2fs(FILE *fp, char *label, size_t size)
{
e2sb_t *fs;
char *s_volume_name;
fs = (e2sb_t *)read_buf(fp, EXT2FS_SB_OFFSET, 512);
if (fs == NULL)
return (1);
/* Check for magic and versio n*/
if (fs->s_magic == EXT2_SUPER_MAGIC &&
fs->s_rev_level == EXT2_DYNAMIC_REV) {
//G_LABEL_DEBUG(1, "ext2fs file system detected on %s.",
// pp->name);
} else {
free(fs);
return (1);
}
s_volume_name = fs->s_volume_name;
/* Terminate label */
s_volume_name[sizeof(fs->s_volume_name) - 1] = '\0';
if (s_volume_name[0] == '/')
s_volume_name += 1;
strlcpy(label, s_volume_name, size);
free(fs);
return (0);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:32,代码来源:ext2fs.c
示例17: decode_compound_hdr_arg
static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound_hdr_arg *hdr)
{
__be32 *p;
__be32 status;
status = decode_string(xdr, &hdr->taglen, &hdr->tag);
if (unlikely(status != 0))
return status;
/* We do not like overly long tags! */
if (hdr->taglen > CB_OP_TAGLEN_MAXSZ - 12) {
printk("NFSv4 CALLBACK %s: client sent tag of length %u\n",
__func__, hdr->taglen);
return htonl(NFS4ERR_RESOURCE);
}
p = read_buf(xdr, 12);
if (unlikely(p == NULL))
return htonl(NFS4ERR_RESOURCE);
hdr->minorversion = ntohl(*p++);
/* Check minor version is zero or one. */
if (hdr->minorversion <= 1) {
hdr->cb_ident = ntohl(*p++); /* ignored by v4.1 */
} else {
printk(KERN_WARNING "%s: NFSv4 server callback with "
"illegal minor version %u!\n",
__func__, hdr->minorversion);
return htonl(NFS4ERR_MINOR_VERS_MISMATCH);
}
hdr->nops = ntohl(*p);
dprintk("%s: minorversion %d nops %d\n", __func__,
hdr->minorversion, hdr->nops);
return 0;
}
开发者ID:JamesAng,项目名称:lx-sk,代码行数:32,代码来源:callback_xdr.c
示例18: fstyp_cd9660
int
fstyp_cd9660(FILE *fp, char *label, size_t size)
{
char *sector, *volume;
int i;
sector = read_buf(fp, ISO9660_OFFSET, 512);
if (sector == NULL)
return (1);
if (bcmp(sector, ISO9660_MAGIC, sizeof(ISO9660_MAGIC) - 1) != 0) {
free(sector);
return (1);
}
volume = sector + 0x28;
bzero(label, size);
strlcpy(label, volume, MIN(size, VOLUME_LEN));
free(sector);
for (i = size - 1; i > 0; i--) {
if (label[i] == '\0')
continue;
else if (label[i] == ' ')
label[i] = '\0';
else
break;
}
return (0);
}
开发者ID:jamesbjackson,项目名称:src,代码行数:27,代码来源:cd9660.c
示例19: read_int
void read_int(char *buf, const char *key, int *value)
{
char buf2[BUFFER_SIZE];
if (read_buf(buf, key, buf2)) {
sscanf(buf2, "%d", value);
}
}
开发者ID:gwq5210,项目名称:learn_curl,代码行数:7,代码来源:judged.c
示例20: decode_cb_sequence_args
static __be32 decode_cb_sequence_args(struct svc_rqst *rqstp,
struct xdr_stream *xdr,
struct cb_sequenceargs *args)
{
__be32 *p;
int i;
__be32 status;
status = decode_sessionid(xdr, &args->csa_sessionid);
if (status)
goto out;
status = htonl(NFS4ERR_RESOURCE);
p = read_buf(xdr, 5 * sizeof(uint32_t));
if (unlikely(p == NULL))
goto out;
args->csa_addr = svc_addr(rqstp);
args->csa_sequenceid = ntohl(*p++);
args->csa_slotid = ntohl(*p++);
args->csa_highestslotid = ntohl(*p++);
args->csa_cachethis = ntohl(*p++);
args->csa_nrclists = ntohl(*p++);
args->csa_rclists = NULL;
if (args->csa_nrclists) {
args->csa_rclists = kmalloc(args->csa_nrclists *
sizeof(*args->csa_rclists),
GFP_KERNEL);
if (unlikely(args->csa_rclists == NULL))
goto out;
for (i = 0; i < args->csa_nrclists; i++) {
status = decode_rc_list(xdr, &args->csa_rclists[i]);
if (status)
goto out_free;
}
}
status = 0;
dprintk("%s: sessionid %x:%x:%x:%x sequenceid %u slotid %u "
"highestslotid %u cachethis %d nrclists %u\n",
__func__,
((u32 *)&args->csa_sessionid)[0],
((u32 *)&args->csa_sessionid)[1],
((u32 *)&args->csa_sessionid)[2],
((u32 *)&args->csa_sessionid)[3],
args->csa_sequenceid, args->csa_slotid,
args->csa_highestslotid, args->csa_cachethis,
args->csa_nrclists);
out:
dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
return status;
out_free:
for (i = 0; i < args->csa_nrclists; i++)
kfree(args->csa_rclists[i].rcl_refcalls);
kfree(args->csa_rclists);
goto out;
}
开发者ID:JamesAng,项目名称:lx-sk,代码行数:59,代码来源:callback_xdr.c
注:本文中的read_buf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论