Beispiel #1
0
bool
RawInput::read_native_scanline (int y, int z, void *data)
{
    if (y < 0 || y >= m_spec.height) // out of range scanline
        return false;

    if (! m_unpacked)
        do_unpack ();

    if (! m_process) {
        // The user has selected not to apply any debayering.
        // We take the raw data directly
        unsigned short *scanline = &((m_processor->imgdata.rawdata.raw_image)[m_spec.width*y]);
        memcpy(data, scanline, m_spec.scanline_bytes(true));
        return true;
    }

    // Check the state of the internal RAW reader.
    // Have to load the entire image at once, so only do this once
    if (! m_image) { 
        if (!process()) {
            return false;
        }
    }

    int length = m_spec.width*m_image->colors; // Should always be 3 colors

    // Because we are reading UINT16's, we need to cast m_image->data
    unsigned short *scanline = &(((unsigned short *)m_image->data)[length*y]);
    memcpy(data, scanline, m_spec.scanline_bytes(true));

    return true;
}
Beispiel #2
0
static void
do_block(const void *in, size_t len, size_t buf_len, size_t offset,
         size_t fp_len, int action, int options) {
  switch (action) {
  case BMZ_A_PACK:
    do_pack(in, len, buf_len, offset, fp_len, options);
    break;
  case BMZ_A_UNPACK:
    do_unpack(in, len, buf_len);
    break;
  default:
    DIE("unknown action: %d", action);
  }
}
int main(int argc, char ** argv)
{
	const char *incoming_dir;
	int uid;
	char *var;
	long long files_limit = DEFAULT_MAX_UPDATES_FILES;
	long long bytes_limit = DEFAULT_MAX_UPDATES_BYTES;

	if (argc < 3) {
		fprintf(stderr, "Invalid parameters, usage: %s user dir [-v]\n", argv[0]);
		exit(1);
	}

	if ((var=getenv("UPDATES_MAX_BYTES")))
		bytes_limit = atoll(var);
	if ((var=getenv("UPDATES_MAX_FILES")))
		files_limit = atoll(var);

	uid = prepare_creds_return_uid(argv[1]);

	incoming_dir = argv[2];
	mkdir(incoming_dir, 0700);
	if (chdir(incoming_dir)) {
		fprintf(stderr, "Error chdir to %s\n", incoming_dir);
		exit(1);
	}
	if (chroot(incoming_dir)) {//impossible
		fprintf(stderr, "Error chroot to %s\n", incoming_dir);
		exit(1);
	}
	if (setuid(uid) < 0) {
		perror("setuid");
		exit(1);
	}
	set_size_limit(bytes_limit, files_limit);
	if (argc > 3 && strcmp(argv[3],"-v")==0)
		set_verbose(1);
	return do_unpack();
}
Beispiel #4
0
int main(int argc, char ** argv)
{
	char *incoming_dir;
	int uid;
	char *remote_domain;

	uid = prepare_creds_return_uid("user");

	remote_domain = getenv("QREXEC_REMOTE_DOMAIN");
	if (!remote_domain) {
		gui_fatal("Cannot get remote domain name");
		exit(1);
	}
	mkdir(INCOMING_DIR_ROOT, 0700);
	asprintf(&incoming_dir, "%s/%s", INCOMING_DIR_ROOT, remote_domain);
	mkdir(incoming_dir, 0700);
	if (chdir(incoming_dir))
		gui_fatal("Error chdir to %s", incoming_dir); 
	if (chroot(incoming_dir)) //impossible
		gui_fatal("Error chroot to %s", incoming_dir);
	setuid(uid);
	return do_unpack();
}