本文整理汇总了C++中pop_n_elems函数的典型用法代码示例。如果您正苦于以下问题:C++ pop_n_elems函数的具体用法?C++ pop_n_elems怎么用?C++ pop_n_elems使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pop_n_elems函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: f_bson_buf_find
void f_bson_buf_find(void){
int size;
bson b[1];
bson sub;
svalue_t v;
bson_iterator it;
size = (sp-1)->u.buf->size;
bson_init_empty(b);
bson_init_size( b, size );
memcpy(b->data, (sp-1)->u.buf->item, size);
b->finished = 1;
/* buff不合法 */
if(bson_size(b) != size){
pop_n_elems(st_num_arg);
push_number(0);
goto free_bson;
}
/* 找不到数据 */
if(!bson_find( &it, b, sp->u.string )){
pop_n_elems(st_num_arg);
push_number(0);
goto free_bson;
}
bson_to_v(&it, &v);
free_buffer((sp-1)->u.buf);
pop_stack();
*sp = v;
free_bson:
bson_destroy( b );
}
开发者ID:carriercomm,项目名称:mudos-1,代码行数:32,代码来源:mg.c
示例2: f_socket_write
void
f_socket_write (void)
{
int i, fd, port;
svalue_t *arg;
char addr[ADDR_BUF_SIZE];
int num_arg = st_num_arg;
arg = sp - num_arg + 1;
if ((num_arg == 3) && (arg[2].type != T_STRING)) {
bad_arg(3, F_SOCKET_WRITE);
}
fd = arg[0].u.number;
get_socket_address(fd, addr, &port, 0);
if (VALID_SOCKET("write")) {
i = socket_write(fd, &arg[1],
(num_arg == 3) ? arg[2].u.string : (char *) NULL);
pop_n_elems(num_arg - 1);
sp->u.number = i;
} else {
pop_n_elems(num_arg - 1);
sp->u.number = EESECURITY;
}
}
开发者ID:Yuffster,项目名称:fluffOS,代码行数:25,代码来源:sockets.c
示例3: f_extension
static void f_extension( INT32 args ) {
int i, found=0;
struct pike_string *src;
char *orig, *ptr;
if(Pike_sp[-1].type != T_STRING)
SIMPLE_BAD_ARG_ERROR("Caudium.extension", 1, "string");
src = Pike_sp[-1].u.string;
if(src->size_shift) {
Pike_error("Caudium.extension(): Only 8-bit strings allowed.\n");
}
orig = src->str;
for(i = src->len-1; i >= 0; i--) {
if(orig[i] == 0x2E) {
found = 1;
i++;
break;
}
}
if(found) {
int len = src->len - i;
switch(orig[src->len-1]) {
case '#': case '~':
/* Remove unix backup extension */
len--;
}
pop_n_elems(args);
push_string(make_shared_binary_string(orig+i, len));
} else {
pop_n_elems(args);
push_text("");
}
}
开发者ID:Letractively,项目名称:caudium,代码行数:35,代码来源:caudium.c
示例4: port_listen_fd
/*! @decl int listen_fd(int fd, void|function accept_callback)
*!
*! This function does the same as @[bind], except that instead of
*! creating a new socket and bind it to a port, it expects the file
*! descriptor @[fd] to be an already open port.
*!
*! @note
*! This function is only for the advanced user, and is generally used
*! when sockets are passed to Pike at exec time.
*!
*! @seealso
*! @[bind], @[accept]
*/
static void port_listen_fd(INT32 args)
{
struct port *p = THIS;
struct svalue *cb = NULL;
int fd;
do_close(p);
get_all_args(NULL, args, "%d.%*", &fd, &cb);
if(fd<0)
{
errno = p->my_errno=EBADF;
pop_n_elems(args);
push_int(0);
return;
}
if(fd_listen(fd, 16384) < 0)
{
p->my_errno=errno;
pop_n_elems(args);
push_int(0);
return;
}
change_fd_for_box (&p->box, fd);
if(cb) assign_accept_cb (p, cb);
p->my_errno=0;
pop_n_elems(args);
push_int(1);
}
开发者ID:pikelang,项目名称:Pike,代码行数:44,代码来源:socket.c
示例5: f_got_data
static void f_got_data( INT32 args )
{
struct pf_source *s =
((struct callback_prog *)Pike_fp->current_object->storage)->s;
remove_callbacks( (struct source *)s );
if( s->str ||
TYPEOF(Pike_sp[-1]) != PIKE_T_STRING ||
Pike_sp[-1].u.string->size_shift ||
Pike_sp[-1].u.string->len == 0)
{
s->s.eof = 1;
pop_n_elems(args);
push_int(0);
return;
}
s->str = Pike_sp[-1].u.string;
Pike_sp--;
pop_n_elems(args-1);
push_int(0);
if( s->when_data_cb )
s->when_data_cb( s->when_data_cb_arg );
}
开发者ID:pikelang,项目名称:Pike,代码行数:25,代码来源:d_source_pikestream.c
示例6: regexp_split
/*! @decl array(string) split(string s)
*! Works as @[match], but returns an array of the strings that
*! matched the subregexps. Subregexps are those contained in "( )" in
*! the regexp. Subregexps that were not matched will contain zero.
*! If the total regexp didn't match, zero is returned.
*!
*! @bugs
*! You can currently only have 39 subregexps.
*!
*! @bugs
*! The current implementation doesn't support searching
*! in strings containing the NUL character or any
*! wide character.
*!
*! @seealso
*! @[match]
*/
static void regexp_split(INT32 args)
{
struct pike_string *s;
struct regexp *r;
get_all_args("Regexp.SimpleRegexp->split", args, "%S", &s);
if(pike_regexec(r=THIS->regexp, s->str))
{
int i,j;
add_ref(s);
pop_n_elems(args);
for(j=i=1;i<NSUBEXP;i++)
{
if(!r->startp[i] || !r->endp[i])
{
push_int(0);
}else{
push_string(make_shared_binary_string(r->startp[i],
r->endp[i]-r->startp[i]));
j=i;
}
}
if(j<i-1) pop_n_elems(i-j-1);
push_array(aggregate_array(j));
free_string(s);
}else{
pop_n_elems(args);
push_int(0);
}
}
开发者ID:ajinkya007,项目名称:pike-1,代码行数:48,代码来源:glue.c
示例7: f_compress
void f_compress (void)
{
unsigned char* buffer;
unsigned char* input;
int size;
buffer_t* real_buffer;
uLongf new_size;
if (sp->type == T_STRING) {
size = SVALUE_STRLEN(sp);
input = (unsigned char*)sp->u.string;
} else if (sp->type == T_BUFFER) {
size = sp->u.buf->size;
input = sp->u.buf->item;
} else {
pop_n_elems(st_num_arg);
push_undefined();
return ;
}
new_size = size;
// Make it a little larger as specified in the docs.
buffer = (unsigned char*)DXALLOC(size * 101 / 100 + 12, TAG_TEMPORARY, "compress");
compress(buffer, &new_size, input, size);
// Shrink it down.
pop_n_elems(st_num_arg);
real_buffer = allocate_buffer(new_size);
write_buffer(real_buffer, 0, (char *)buffer, new_size);
FREE(buffer);
push_buffer(real_buffer);
}
开发者ID:Yuffster,项目名称:fluffOS,代码行数:32,代码来源:compress.c
示例8: pop_n_elems
/* Note that now, once the master object loads once, there is ALWAYS a
* master object, so the only way this can fail is if the master object
* hasn't loaded yet. In that case, we return (svalue_t *)-1, and the
* calling routine should let the check succeed. 失败只可能是还没有load进master
这像是在让master调用函数? */
svalue_t *apply_master_ob(int fun, int num_arg) /* 将master应用起来? */
{
if (!master_ob) {
pop_n_elems(num_arg); /* 只要master还没有load进来,就将栈清空? */
return (svalue_t *)-1;
}
if (master_applies[fun].func) { /* 这里会调用不同的函数,函数都在里边? */
#ifdef TRACE
if (TRACEP(TRACE_APPLY)) {
do_trace("master apply", master_applies[fun].func->name, "\n");
}
#endif
DEBUG_CHECK(master_ob->flags & O_SWAPPED, "Master object swapped!\n");
call_direct(master_ob, master_applies[fun].index, ORIGIN_DRIVER, num_arg); /* 像是在调用函数? */
free_svalue(&apply_ret_value, "apply_master_ob");
apply_ret_value = *sp--; /* 从栈中取出返回值 */
return &apply_ret_value;
} else {
pop_n_elems(num_arg);
return 0;
}
}
开发者ID:xcw0579,项目名称:mudOS,代码行数:30,代码来源:master.c
示例9: f_reference_allowed
void
f_reference_allowed()
{
svalue_t *sv = sp - st_num_arg + 1;
svalue_t *v;
object_t *referee = NULL;
object_t *referrer_obj = command_giver; /* Default to this_player(). */
const char *referrer_name = NULL;
int result = 0;
int num_arg = st_num_arg;
/* Maybe I could learn how to use this :p
CHECK_TYPES(sp-1, T_NUMBER, 1, F_MEMBER_ARRAY); */
if (sv->type == T_OBJECT && sv->u.ob) {
referee = sv->u.ob;
}
if (st_num_arg > 1) {
if (sv[1].type == T_STRING && sv[1].u.string) {
/* We've been passed in a string, now we need to call
* find_player() */
#ifdef F_FIND_PLAYER
/* If we have a find_player() efun, then we need to sue
* the following method. This hasn't been tested!
*/
referrer = find_living_object(sv[1].u.string, 1);
#else
if (simul_efun_ob) {
push_svalue(&sv[1]);
v = apply("find_player", simul_efun_ob, 1, ORIGIN_EFUN);
if (v && v->type == T_OBJECT) {
referrer_obj = v->u.ob;
referrer_name = sv[1].u.string;
}
else {
referrer_obj = NULL;
referrer_name = sv[1].u.string;
}
}
#endif
}
if (sv[1].type == T_OBJECT && sv[1].u.ob) {
referrer_obj = sv[1].u.ob;
referrer_name = NULL;
}
}
if (referee && (referrer_obj || referrer_name)) {
result = reference_allowed(referee, referrer_obj, referrer_name);
pop_n_elems(num_arg);
push_number(result);
} else {
pop_n_elems(num_arg);
push_undefined();
}
}
开发者ID:Yuffster,项目名称:fluffOS,代码行数:59,代码来源:dwlib.c
示例10: f_tokenize
/*! @decl array(array(string)|string) tokenize(string code)
*!
*! Tokenize a string of Pike tokens.
*!
*! @returns
*! Returns an array with Pike-level tokens and the remainder (a
*! partial token), if any.
*/
static void f_tokenize( INT32 args )
{
struct array *res;
struct pike_string *left_s = NULL; /* Make gcc happy. */
struct pike_string *data;
int left;
ONERROR tmp;
get_all_args("tokenize", args, "%W", &data);
if(!data->len)
{
pop_n_elems(args);
push_empty_array();
push_empty_string();
f_aggregate(2);
return;
}
res = allocate_array_no_init( 0, 128 );
SET_ONERROR(tmp, do_free_arrayptr, &res);
switch(data->size_shift)
{
case 0:
left = tokenize0(&res, STR0(data), data->len);
left_s = make_shared_binary_string0(STR0(data)+left, data->len-left);
break;
case 1:
left = tokenize1(&res, STR1(data), data->len);
left_s = make_shared_binary_string1(STR1(data)+left, data->len-left);
break;
case 2:
left = tokenize2(&res,STR2(data), data->len);
left_s = make_shared_binary_string2(STR2(data)+left, data->len-left);
break;
#ifdef PIKE_DEBUG
default:
Pike_error("Unknown shift size %d.\n", data->size_shift);
#endif
}
UNSET_ONERROR(tmp);
pop_n_elems(args);
if (!res->size) {
free_array(res);
push_empty_array();
}
else
push_array(res);
push_string( left_s );
f_aggregate( 2 );
}
开发者ID:ajinkya007,项目名称:pike-1,代码行数:61,代码来源:pike.c
示例11: image_orient4
void image_orient4(INT32 args)
{
struct object *o[5];
struct image *img[5];
CHECK_INIT();
pop_n_elems(args);
_image_orient(THIS,o,img);
pop_n_elems(1);
f_aggregate(4);
}
开发者ID:pikelang,项目名称:Pike,代码行数:13,代码来源:orient.c
示例12: free_input
/* Free an input */
static INLINE void free_input(input *inp) {
ninputs--;
switch(inp->type) {
case NBIO_STR:
DERR(fprintf(stderr, "Freeing string input 0x%x\n", (unsigned int)inp));
free_string(inp->u.data);
nstrings--;
break;
#ifdef USE_MMAP
case NBIO_MMAP:
DERR(fprintf(stderr, "Freeing mmap input 0x%x\n", (unsigned int)inp));
if(inp->u.mmap_storage->data != MAP_FAILED) {
munmap(inp->u.mmap_storage->data, inp->u.mmap_storage->m_len);
mmapped -= inp->u.mmap_storage->m_len;
}
push_int(0); push_int(0); push_int(0);
apply_low(inp->u.mmap_storage->file, inp->set_nb_off, 3);
apply_low(inp->u.mmap_storage->file, inp->set_b_off, 0);
pop_n_elems(2);
free_object(inp->u.mmap_storage->file);
free(inp->u.mmap_storage);
break;
#endif
case NBIO_OBJ:
push_int(0); push_int(0); push_int(0);
apply_low(inp->u.file, inp->set_nb_off, 3);
apply_low(inp->u.file, inp->set_b_off, 0);
pop_n_elems(2);
/* FALL THROUGH */
case NBIO_BLOCK_OBJ:
DERR(fprintf(stderr, "Freeing obj input 0x%x\n", (unsigned int)inp));
free_object(inp->u.file);
nobjects--;
break;
}
if(THIS->last_input == inp)
THIS->last_input = NULL;
THIS->inputs = inp->next;
if(!THIS->finished && THIS->inputs && THIS->inputs->type == NBIO_OBJ) {
/* Aha! Set read callback here */
DERR(fprintf(stderr, "Setting read/close callbacks for input 0x%x\n", (unsigned int)THIS->inputs));
push_callback(input_read_cb_off);
push_int(0);
push_callback(input_close_cb_off);
apply_low(THIS->inputs->u.file, THIS->inputs->set_nb_off, 3);
THIS->inputs->mode = READING;
}
free(inp);
}
开发者ID:Letractively,项目名称:caudium,代码行数:52,代码来源:nb_send.c
示例13: f_external_start
void f_external_start (void)
{
int fd, num_arg = st_num_arg;
svalue_t *arg = sp - num_arg + 1;
if (check_valid_socket("external", -1, current_object, "N/A", -1)) {
fd = external_start(arg[0].u.number, arg + 1,
arg + 2, arg + 3, (num_arg == 5 ? arg + 4 : 0));
pop_n_elems(num_arg - 1);
sp->u.number = fd;
} else {
pop_n_elems(num_arg - 1);
sp->u.number = EESECURITY;
}
}
开发者ID:Elohim,项目名称:FGmud,代码行数:15,代码来源:external.c
示例14: pipe_read_input_callback
static void pipe_read_input_callback(INT32 args)
{
struct input *i;
struct pike_string *s;
if (args<2 || sp[1-args].type!=T_STRING)
Pike_error("Illegal argument to pipe->read_input_callback\n");
i=THIS->firstinput;
if (!i)
Pike_error("Pipe read callback without any inputs left.\n");
s=sp[1-args].u.string;
if(append_buffer(s))
{
/* THIS DOES NOT WORK */
push_int(0);
push_int(0);
push_callback(offset_input_close_callback);
apply_low(i->u.obj,i->set_nonblocking_offset,3);
pop_stack();
THIS->sleeping=1;
}
low_start();
pop_n_elems(args-1);
}
开发者ID:ajinkya007,项目名称:pike-1,代码行数:29,代码来源:pipe.c
示例15: f_all
/*! @decl mapping(string:string) all(string map)
*!
*! Returns the whole map as a mapping.
*!
*! @[map] is the YP-map to search in. This must be the full map name,
*! you have to use @tt{[email protected]} instead of just @tt{[email protected]}.
*/
static void f_all(INT32 args)
{
int err, num=0;
char *retval, *retkey;
int retlen, retkeylen;
char *map;
struct mapping *res_map;
check_all_args(NULL, args, BIT_STRING, 0);
map = sp[-1].u.string->str;
res_map = allocate_mapping( (this->last_size?this->last_size+2:40) );
if(!(err = yp_first(this->domain, map, &retkey,&retkeylen, &retval,&retlen)))
do {
push_string(make_shared_binary_string(retkey, retkeylen));
push_string(make_shared_binary_string(retval, retlen));
mapping_insert( res_map, sp-2, sp-1 );
pop_stack(); pop_stack();
err = yp_next(this->domain, map, retkey, retkeylen,
&retkey, &retkeylen, &retval, &retlen);
num++;
} while(!err);
if(err != YPERR_NOMORE)
{
free_mapping( res_map );
YPERROR( err );
}
this->last_size = num;
pop_n_elems(args);
push_mapping( res_map );
}
开发者ID:pikelang,项目名称:Pike,代码行数:41,代码来源:yp.c
示例16: f_bindtextdomain
/*! @decl string bindtextdomain(string|void domainname, string|void dirname)
*!
*! Binds the path predicate for a message @[domainname] domainname to
*! the directory name specified by @[dirname].
*!
*! If @[domainname] is a non-empty string and has not been bound
*! previously, bindtextdomain() binds @[domainname] with @[dirname].
*!
*! If @[domainname] is a non-empty string and has been bound previously,
*! bindtextdomain() replaces the old binding with @[dirname].
*!
*! The @[dirname] argument can be an absolute or relative pathname
*! being resolved when @[gettext()], @[dgettext()] or @[dcgettext()]
*! are called.
*!
*! If @[domainname] is zero or an empty string, @[bindtextdomain()]
*! returns 0.
*!
*! User defined domain names cannot begin with the string @expr{"SYS_"@}.
*! Domain names beginning with this string are reserved for system use.
*!
*! @returns
*! The return value from @[bindtextdomain()] is a string containing
*! @[dirname] or the directory binding associated with @[domainname] if
*! @[dirname] is unspecified. If no binding is found, the default locale
*! path is returned. If @[domainname] is unspecified or is an empty string,
*! @[bindtextdomain()] takes no action and returns a 0.
*!
*! @seealso
*! @[textdomain], @[gettext], @[setlocale], @[localeconv]
*/
void f_bindtextdomain(INT32 args)
{
char *returnstring;
const char *domain = NULL, *dirname = NULL;
get_all_args (NULL, args, ".%C%C", &domain, &dirname);
if (!domain || !*domain)
returnstring = NULL;
else {
#ifdef BINDTEXTDOMAIN_HANDLES_NULL
returnstring = bindtextdomain (domain, dirname);
#else
if (dirname)
returnstring = bindtextdomain (domain, dirname);
else
/* Awkward, but not much we can do. Still better than a
* coredump.. */
Pike_error ("Pike has been compiled with a version of libintl "
"that doesn't support NULL as directory name.\n");
#endif
}
pop_n_elems(args);
if(returnstring == NULL)
push_int(0);
else
push_text(returnstring);
}
开发者ID:pikelang,项目名称:Pike,代码行数:59,代码来源:gettext.c
示例17: f__xpm_trim_rows
/*! @decl array(string) _xpm_trim_rows(array(string) rows)
*/
void f__xpm_trim_rows( INT32 args )
{
struct array *a;
int i,j=0;
get_all_args("_xpm_trim_rows", args, "%a", &a );
for(i=0; i<a->size; i++)
{
int len,start;
struct pike_string *s = a->item[i].u.string;
if(a->item[i].type != T_STRING)
Pike_error("Array must be array(string).\n");
if(s->len > 4)
{
for(start=0; start<s->len; start++)
if(s->str[start] == '/' || s->str[start] == '"')
break;
if(s->str[start] == '/')
continue;
for(len=start+1; len<s->len; len++)
if(s->str[len] == '"')
break;
if(len>=s->len || s->str[len] != '"')
continue;
free_string(a->item[j].u.string);
a->item[j++].u.string=make_shared_binary_string(s->str+start+1,len-start-1);
}
}
pop_n_elems(args-1);
}
开发者ID:ajinkya007,项目名称:pike-1,代码行数:31,代码来源:_xpm.c
示例18: f_crypt_md5
static void f_crypt_md5(INT32 args)
{
char salt[8];
char *ret, *saltp ="";
char *choice =
"cbhisjKlm4k65p7qrJfLMNQOPxwzyAaBDFgnoWXYCZ0123tvdHueEGISRTUV89./";
if (args < 1)
SIMPLE_TOO_FEW_ARGS_ERROR("crypt_md5", 1);
if (Pike_sp[-args].type != T_STRING)
SIMPLE_BAD_ARG_ERROR("crypt_md5", 1, "string");
if (args > 1)
{
if (Pike_sp[1-args].type != T_STRING)
SIMPLE_BAD_ARG_ERROR("crypt_md5", 2, "string");
saltp = Pike_sp[1-args].u.string->str;
} else {
unsigned int i, r;
for (i = 0; i < sizeof(salt); i++)
{
r = my_rand();
salt[i] = choice[r % (size_t) strlen(choice)];
}
saltp = salt;
}
ret = (char *)crypt_md5(Pike_sp[-args].u.string->str, saltp);
pop_n_elems(args);
push_string(make_shared_string(ret));
}
开发者ID:ajinkya007,项目名称:societyserver,代码行数:34,代码来源:md5_pike.c
示例19: f_parse_headers
static void f_parse_headers( INT32 args )
{
struct mapping *headermap;
struct pike_string *headers;
unsigned char *ptr;
int len = 0, parsed = 0;
get_all_args("Caudium.parse_headers", args, "%S", &headers);
headermap = allocate_mapping(1);
ptr = (unsigned char *)headers->str;
len = headers->len;
/*
* FIXME:
* What do we do if memory allocation fails halfway through
* allocating a new mapping? Should we return that half-finished
* mapping or rather return NULL? For now it's the former case.
* /Grendel
*
* If memory allocation fails, just bail out with error()
*/
while(len > 0 &&
(parsed = get_next_header(ptr, len, headermap)) >= 0 ) {
ptr += parsed;
len -= parsed;
}
if(parsed == -1) {
Pike_error("Caudium.parse_headers(): Out of memory while parsing.\n");
}
pop_n_elems(args);
push_mapping(headermap);
}
开发者ID:Letractively,项目名称:caudium,代码行数:30,代码来源:caudium.c
示例20: f_async_write
void f_async_write(){
function_to_call_t *cb = get_cb();
process_efun_callback(3, cb, F_ASYNC_WRITE);
cb->f.fp->hdr.ref++;
add_write(check_valid_path((sp-3)->u.string, current_object, "write_file", 1), (sp-2)->u.string, strlen((sp-2)->u.string), (sp-1)->u.number, cb);
pop_n_elems(4);
}
开发者ID:Hobbitron,项目名称:tmi2_fluffos_v3,代码行数:7,代码来源:async.c
注:本文中的pop_n_elems函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论