示例#1
0
void handle_read(struct request *req, int val){
    aiob *aio = req->aio;
    close(aio->aio_fildes);
    if(val){
        FREE(aio->aio_buf);
        push_number(val);
        set_eval(max_cost);
        safe_call_efun_callback(req->fun, 1);
        return;
    }
    val = aio_return(aio);
    if(val < 0){
        FREE(aio->aio_buf);
        push_number(val);
        set_eval(max_cost);
        safe_call_efun_callback(req->fun, 1);
        return;
    }
    char *file = new_string(val, "read_file_async: str");
    memcpy(file, (char *)(aio->aio_buf), val);
    file[val]=0;
    push_malloced_string(file);
    FREE(aio->aio_buf);
    set_eval(max_cost);
    safe_call_efun_callback(req->fun, 1);
}
示例#2
0
文件: async.c 项目: Elohim/FGmud
void handle_write(struct request *req){
	free_svalue(&req->tmp, "handle_write");
	int val = req->ret;
	if(val < 0){
		push_number(val);
		set_eval(max_cost);
		safe_call_efun_callback(req->fun, 1);
		return;
	}
	push_undefined();
	set_eval(max_cost);
	safe_call_efun_callback(req->fun, 1);
}
示例#3
0
void handle_getdir(struct request *req, int val){
    aiob *aio = req->aio;
    close(aio->aio_fildes);
    val = aio_return(aio);
    array_t *ret = allocate_empty_array(val);
    int i;
    if(val > -1)
    {
        struct linux_dirent *de = (struct linux_dirent *)aio->aio_buf;
        for(i=0; ((char *)de) - (char *)(aio->aio_buf) < val; i++)
        {
            svalue_t *vp = &(ret->item[i]);
            vp->type = T_STRING;
            vp->subtype = STRING_MALLOC;
            //printf("%s ", de->d_name);
            vp->u.string = string_copy(de->d_name, "encode_stat");
            de = (struct linux_dirent *)(((char *)de) + de->d_reclen);
        }
    }
    ret = RESIZE_ARRAY(ret, i);
    ret->size = i;
    push_refed_array(ret);
    set_eval(max_cost);
    safe_call_efun_callback(req->fun, 1);
}
示例#4
0
文件: async.c 项目: Elohim/FGmud
void handle_getdir(struct request *req){
	int val = req->ret;
	if(val>MAX_ARRAY_SIZE)
		val = MAX_ARRAY_SIZE;
	array_t *ret = allocate_empty_array(val);
	int i=0;
	if(val > 0)
	{
		struct linux_dirent *de = (struct linux_dirent *)req->buf;
		for(i=0; i<MAX_ARRAY_SIZE && ((char *)de) - (char *)(req->buf) < val; i++)
		{
			svalue_t *vp = &(ret->item[i]);
			vp->type = T_STRING;
			vp->subtype = STRING_MALLOC;
			vp->u.string = string_copy(de->d_name, "encode_stat");
			de = (struct linux_dirent *)(((char *)de) + de->d_reclen);
		}
	}
	ret = resize_array(ret, i);
	ret->size = i;
	push_refed_array(ret);
	FREE((void *)req->buf);
	set_eval(max_cost);
	safe_call_efun_callback(req->fun, 1);
}
示例#5
0
文件: async.c 项目: Elohim/FGmud
void handle_read(struct request *req){
	int val = req->ret;
	if(val < 0){
		FREE((void *)req->buf);
		push_number(val);
		set_eval(max_cost);
		safe_call_efun_callback(req->fun, 1);
		return;
	}
	char *file = new_string(val, "read_file_async: str");
	memcpy(file, (char *)(req->buf), val);
	file[val]=0;
	push_malloced_string(file);
	FREE((void *)req->buf);
	set_eval(max_cost);
	safe_call_efun_callback(req->fun, 1);
}
示例#6
0
文件: async.c 项目: Elohim/FGmud
void handle_db_exec(struct request *req){
	free_svalue(&req->tmp, "handle_db_exec");
	int val = req->ret;
	if(val == -1){
		copy_and_push_string(req->path);
	}
	else
		push_number(val);
	set_eval(max_cost);
	safe_call_efun_callback(req->fun, 1);
}
示例#7
0
void handle_write(struct request *req, int val){
    aiob *aio = req->aio;
    close(aio->aio_fildes);
    free_svalue(&req->tmp, "handle_write");
    if(val){
        push_number(val);
        set_eval(max_cost);
        safe_call_efun_callback(req->fun, 1);
        return;
    }
    val = aio_return(aio);
    if(val < 0){
        push_number(val);
        set_eval(max_cost);
        safe_call_efun_callback(req->fun, 1);
        return;
    }
    push_undefined();
    set_eval(max_cost);
    safe_call_efun_callback(req->fun, 1);
}