コード例 #1
0
ファイル: main.c プロジェクト: caomw/grass
static int use_r_out(void)
{
    char *mpfilename;
    int ret;

    mpfilename = G_tempfile();
    write_params(mpfilename, vfiles[0], outfile, frames, quality, 0, 0, 1);

    if (G_verbose() <= G_verbose_min())
	ret = G_spawn(encoder, encoder, mpfilename,
		      SF_REDIRECT_FILE, SF_STDOUT, SF_MODE_OUT, G_DEV_NULL,
		      SF_REDIRECT_FILE, SF_STDERR, SF_MODE_OUT, G_DEV_NULL,
		      NULL);
    else
	ret = G_spawn(encoder, encoder, mpfilename, NULL);

    if (ret != 0)
	G_warning(_("mpeg_encode ERROR"));

    clean_files(mpfilename, NULL, 0);

    return (1);
}
コード例 #2
0
ファイル: main.c プロジェクト: caomw/grass
static int load_files(void)
{
    void *voidc;
    int rtype;
    register int i, rowoff, row, col, vxoff, vyoff, offset;
    int cnt, fd, size, tsiz, coff;
    int vnum;
    int y_rows, y_cols;
    char *pr, *pg, *pb;
    unsigned char *tr, *tg, *tb, *tset;
    char *mpfilename, *name;
    char *yfiles[MAXIMAGES];
    struct Colors colors;
    int ret;

    size = nrows * ncols;

    pr = G_malloc(size);
    pg = G_malloc(size);
    pb = G_malloc(size);

    tsiz = Rast_window_cols();

    tr = (unsigned char *)G_malloc(tsiz);
    tg = (unsigned char *)G_malloc(tsiz);
    tb = (unsigned char *)G_malloc(tsiz);
    tset = (unsigned char *)G_malloc(tsiz);

    for (cnt = 0; cnt < frames; cnt++) {
	if (cnt > MAXIMAGES) {
	    cnt--;
	    break;
	}

	for (i = 0; i < size; i++)
	    pr[i] = pg[i] = pb[i] = 0;

	for (vnum = 0; vnum < numviews; vnum++) {
	    if (icols == vcols) {
		vxoff = BORDER_W;
		vyoff = (irows == vrows) ? BORDER_W :
		    BORDER_W + vnum * (BORDER_W + vrows);
	    }
	    else if (irows == vrows) {
		vxoff = (icols == vcols) ? BORDER_W :
		    BORDER_W + vnum * (BORDER_W + vcols);
		vyoff = BORDER_W;
	    }
	    else {		/* 4 views */
		/* assumes we want:
		   view1        view2
		   view3        view4   
		 */
		vxoff = vnum % 2 ? BORDER_W : vcols + 2 * BORDER_W;
		vyoff = vnum > 1 ? vrows + 2 * BORDER_W : BORDER_W;
	    }

	    name = vfiles[vnum][cnt];

	    G_message(_("Reading raster map <%s>..."), name);

	    fd = Rast_open_old(name, "");

	    if (Rast_read_colors(name, "", &colors) < 0)
		G_fatal_error(_("Unable to read color table for <%s>"), name);

	    rtype = Rast_get_map_type(fd);
	    voidc = Rast_allocate_buf(rtype);

	    for (row = 0; row < vrows; row++) {
		Rast_get_row(fd, voidc, (int)(row / vscale), rtype);

		rowoff = (vyoff + row) * ncols;
		Rast_lookup_colors(voidc, tr, tg, tb,
				       tset, tsiz, &colors, rtype);

		for (col = 0; col < vcols; col++) {
		    coff = (int)(col / vscale);
		    offset = rowoff + col + vxoff;

		    if (!tset[coff])
			pr[offset] = pg[offset] = pb[offset] = (char)255;
		    else {
			pr[offset] = (char)tr[coff];
			pg[offset] = (char)tg[coff];
			pb[offset] = (char)tb[coff];
		    }
		}
	    }

	    Rast_close(fd);
	}

	yfiles[cnt] = G_tempfile();

#ifdef USE_PPM
	write_ppm(pr, pg, pb, nrows, ncols, &y_rows, &y_cols, yfiles[cnt]);
#else
	write_ycc(pr, pg, pb, nrows, ncols, &y_rows, &y_cols, yfiles[cnt]);
#endif
    }

    mpfilename = G_tempfile();
    write_params(mpfilename, yfiles, outfile, cnt, quality, y_rows, y_cols, 0);

    if (G_verbose() <= G_verbose_min())
	ret = G_spawn(encoder, encoder, mpfilename,
		      SF_REDIRECT_FILE, SF_STDOUT, SF_MODE_OUT, G_DEV_NULL,
		      SF_REDIRECT_FILE, SF_STDERR, SF_MODE_OUT, G_DEV_NULL,
		      NULL);
    else
	ret = G_spawn(encoder, encoder, mpfilename, NULL);

    if (ret != 0)
	G_warning(_("mpeg_encode ERROR"));

    clean_files(mpfilename, yfiles, cnt);

    G_free(voidc);
    G_free(tset);
    G_free(tr);
    G_free(tg);
    G_free(tb);
    G_free(pr);
    G_free(pg);
    G_free(pb);

    return (cnt);
}
コード例 #3
0
ファイル: delete_user.c プロジェクト: amnuts/Amnuts
/*
 * Delete a user
 */
void
delete_user(UR_OBJECT user, int this_user)
{
    char name[USER_NAME_LEN + 1];
    UR_OBJECT u;

    if (this_user) {
        /*
         * User structure gets destructed in disconnect_user(), need to keep a
         * copy of the name
         */
        strcpy(name, user->name);
        write_user(user, "\n~FR~LI~OLACCOUNT DELETED!\n");
        vwrite_room_except(user->room, user, "~OL~LI%s commits suicide!\n",
                user->name);
        write_syslog(SYSLOG, 1, "%s SUICIDED.\n", name);
        disconnect_user(user);
        clean_files(name);
        rem_user_node(name);
        return;
    }
    if (word_count < 2) {
        write_user(user, "Usage: nuke <user>\n");
        return;
    }
    *word[1] = toupper(*word[1]);
    if (!strcmp(word[1], user->name)) {
        write_user(user,
                "Trying to delete yourself is the eleventh sign of madness.\n");
        return;
    }
    if (get_user(word[1])) {
        /* Safety measure just in case. Will have to .kill them first */
        write_user(user,
                "You cannot delete a user who is currently logged on.\n");
        return;
    }
    u = create_user();
    if (!u) {
        vwrite_user(user, "%s: unable to create temporary user object.\n",
                syserror);
        write_syslog(SYSLOG | ERRLOG, 0,
                "ERROR: Unable to create temporary user object in delete_user().\n");
        return;
    }
    strcpy(u->name, word[1]);
    if (!load_user_details(u)) {
        write_user(user, nosuchuser);
        destruct_user(u);
        destructed = 0;
        return;
    }
    if (u->level >= user->level) {
        write_user(user,
                "You cannot delete a user of an equal or higher level than yourself.\n");
        destruct_user(u);
        destructed = 0;
        return;
    }
    clean_files(u->name);
    rem_user_node(u->name);
    vwrite_user(user, "\07~FR~OL~LIUser %s deleted!\n", u->name);
    write_syslog(SYSLOG, 1, "%s DELETED %s.\n", user->name, u->name);
    destruct_user(u);
    destructed = 0;
}