Esempio n. 1
0
File: async.c Progetto: Elohim/FGmud
int add_read(const char *fname, function_to_call_t *fun) {
	if (fname) {
		struct request *req = get_req();
		//printf("fname: %s\n", fname);
		req->buf = (char *)MALLOC(READ_FILE_MAX_SIZE);
		req->size = READ_FILE_MAX_SIZE;
		req->fun = fun;
		req->type = aread;
		strcpy(req->path, fname);
#ifdef PACKAGE_COMPRESS
		return aio_gzread(req);
#else
		return aio_read(req);
#endif
	}else
		error("permission denied\n");
	return 1;
}
Esempio n. 2
0
int add_read(const char *fname, function_to_call_t *fun) {
    if (fname) {
        aiob *aio = get_aiob();
        memset(aio, 0, sizeof(aiob));
        //printf("fname: %s\n", fname);
        int fd = open(fname, O_RDONLY);
        aio->aio_fildes = fd;
        aio->aio_buf = (char *)MALLOC(READ_FILE_MAX_SIZE);
        aio->aio_nbytes = READ_FILE_MAX_SIZE;
        struct request *req = get_req();
        req->aio = aio;
        req->fun = fun;
        req->type = aread;
        add_req(req);
#ifdef PACKAGE_COMPRESS
        return aio_gzread(aio);
#else
        return aio_read(aio);
#endif
    }else
        error("permission denied\n");
    return 1;
}