Esempio n. 1
0
int add_write(const char *fname, const char *buf, int size, char flags, function_to_call_t *fun) {
    if (fname) {
        aiob *aio = get_aiob();
        memset(aio, 0, sizeof(aiob));
        int fd = open(fname, flags & 1 ? O_CREAT|O_WRONLY
                : O_CREAT|O_WRONLY|O_APPEND, S_IRWXU|S_IRWXG);
        aio->aio_fildes = fd;
        aio->aio_buf = buf;
        aio->aio_nbytes = size;
        struct request *req = get_req();
        req->aio = aio;
        req->fun = fun;
        req->type = awrite;
        assign_svalue_no_free(&req->tmp, sp-2);
        add_req(req);
#ifdef PACKAGE_COMPRESS
        if(flags & 2)
            return aio_gzwrite(aio);
        else
#endif
            return aio_write(aio);
    } else
        error("permission denied\n");
    return 1;
}
Esempio n. 2
0
File: async.c Progetto: Elohim/FGmud
int add_write(const char *fname, const char *buf, int size, char flags, function_to_call_t *fun) {
	if (fname) {
		struct request *req = get_req();
		req->buf = buf;
		req->size = size;
		req->fun = fun;
		req->type = awrite;
		req->flags = flags;
		strcpy(req->path, fname);
		assign_svalue_no_free(&req->tmp, sp-2);
#ifdef PACKAGE_COMPRESS
		if(flags & 2)
			return aio_gzwrite(req);
		else
#endif
			return aio_write(req);
	} else
		error("permission denied\n");
	return 1;
}