Пример #1
0
static void
PutEpsFile(char *s, double scale, double baseline, int full_path)
{
	char *png, *emf, *pict;
	diagnostics(2, "PutEpsFile filename = <%s>", s);
     
	if (1) {
		png = eps_to_png(s);
	    scale *= 72.0 / g_dots_per_inch;
		if (png) {
			PutPngFile(png, scale, baseline, TRUE);
			my_unlink(png);
			free(png);
		}
	}
	        
	if (0) {
		pict = eps_to_pict(s);
		if (pict) {
			PutPictFile(pict, scale, baseline, TRUE);
			my_unlink(pict);  
			free(pict);
		}
	}

	if (0) {
		emf = eps_to_emf(s);
		if (emf) {
			PutEmfFile(emf, scale, baseline, TRUE);
			my_unlink(emf);
			free(emf);
		}
	}
}
Пример #2
0
static void
PutGifFile(char *s, double scale, double baseline, int full_path)
/******************************************************************************
 purpose   : Insert GIF file (from g_home_dir) into RTF file as a PNG image
 ******************************************************************************/
{
	char *cmd, *gif, *png, *tmp_png;
	size_t cmd_len;
	
	diagnostics(1, "filename = <%s>", s);
	png = strdup_new_extension(s, ".gif", ".png");
	if (png == NULL) {
		png = strdup_new_extension(s, ".GIF", ".png");
		if (png == NULL) return;
	}
	
	tmp_png = strdup_tmp_path(png);
	gif = strdup_together(g_home_dir,s);
	
	cmd_len = strlen(gif)+strlen(tmp_png)+10;
	cmd = (char *) malloc(cmd_len);
	snprintf(cmd, cmd_len, "convert %s %s", gif, tmp_png);	
	diagnostics(2, "system graphics command = [%s]", cmd);
	system(cmd);
	
	PutPngFile(tmp_png, scale, baseline, TRUE);
	my_unlink(tmp_png);

	free(tmp_png);
	free(cmd);
	free(gif);
	free(png);
}
Пример #3
0
/* hard links are also tested a bunch in test_rename */
void test_link(char *workdir) {
    char file1[1024], file2[1024], file3[1024];
    struct stat sb;

    printf("Testing link\n");

    sprintf(file1, "%s/original", workdir);
    sprintf(file2, "%s/link", workdir);

    my_create(file1);
    my_stat(file1, &sb);
    my_link(file1, file2);
    verify_inum(file2, &sb);
    my_unlink(file2);
    verify_inum(file1, &sb);

    /* Test deletion of the original file after a hard link has been
       created */
    my_link(file1, file2);
    my_unlink(file1);
    verify_inum(file2, &sb);
    /* Make sure the original file really isn't accessible */
    verify_no_exist(file1);
    my_unlink(file2);
    verify_no_exist(file2);

    /* Try renaming a hard link */
    my_create(file1);
    my_stat(file1, &sb);
    my_link(file1, file2);
    sprintf(file3, "%s/file3", workdir);
    my_rename(file2, file3);
    verify_inum(file3, &sb);
    verify_no_exist(file2);

    my_unlink(file3);
    verify_no_exist(file3);

    my_unlink(file1);

}
Пример #4
0
void
PutPdfFile(char *s, double scale, double baseline, int full_path)
{
	char *png;
	diagnostics(2, "PutPdfFile filename = <%s>", s);
     
	png = pdf_to_png(s);
	scale *= 72.0 / g_dots_per_inch;
	if (png) {
		PutPngFile(png, scale, baseline, TRUE);
		my_unlink(png);
		free(png);
	}	
}
Пример #5
0
Файл: chat.c Проект: wyat/kbs
void set_rec(chatcontext * pthis, const char *arg)
{                               /* set recorder */
    char fname[STRLEN];
    time_t now;

    now = time(0);
    /*        if(!HAS_PERM(getCurrentUser(),PERM_SYSOP))
       return; */

    /*sprintf(fname, "tmp/%s.chat", getCurrentUser()->userid);*/
    sethomefile(fname,getCurrentUser()->userid,"chatrec");

    if (!pthis->rec) {
        if ((pthis->rec = fopen(fname, "a")) == NULL)
            return;
        printchatline(pthis, "\033[5m\033[32mRecord Start ...\033[m");
        move(0, 0);
        clrtoeol();
        prints
        ("\033[44m\033[33m 房间: \033[36m%-10s  \033[33m话题:\033[36m%-51s\033[31m%2s\033[m",
         pthis->chatroom, pthis->topic, (pthis->rec) ? "录" : "  ");
        fprintf(pthis->rec,
                "发信人: %s (%s) 房间: %s\n话  题: %s\x1b[m\n\n",
                getCurrentUser()->userid, getCurrentUser()->username,
                pthis->chatroom, pthis->topic);
        fprintf(pthis->rec, "本段由 %s", getCurrentUser()->userid);
        fprintf(pthis->rec, "所录下,时间: %s", ctime(&now));
        bbslog("user", "start record room %s", pthis->chatroom);
    } else {
        move(0, 0);
        clrtoeol();
        prints
        ("\033[44m\033[33m 房间: \033[36m%-10s  \033[33m话题:\033[36m%-51s\033[31m%2s\033[m",
         pthis->chatroom, pthis->topic, (pthis->rec) ? "录" : "  ");
        fprintf(pthis->rec,
                "发信人: %s (%s) 房间: %s\n话  题: %s\x1b[m\n\n",
                getCurrentUser()->userid, getCurrentUser()->username,
                pthis->chatroom, pthis->topic);
        printchatline(pthis, "\033[5m\033[32mRecord Stop ...\033[m");
        fprintf(pthis->rec, "结束时间:%s\n", ctime(&now));
        fclose(pthis->rec);
        pthis->rec = NULL;
        mail_file(getCurrentUser()->userid, fname, getCurrentUser()->userid,
                  "录音结果", 1, NULL);
        my_unlink(fname);
        bbslog("user", "stop record room %s", pthis->chatroom);
    }
}
Пример #6
0
Файл: tmpl.c Проект: zhouqt/kbs
/* completely destroy a template, caller guarantees permission */
static void deepfree(struct a_template *ptemp, const char *board)
{
    char filepath[STRLEN];

    if (ptemp->tmpl->filename[0]) {
        setbfile(filepath, board, ptemp->tmpl->filename);
        if (dashf(filepath))
            my_unlink(filepath);
    }

    if (ptemp->tmpl) {
        free(ptemp->tmpl);
        ptemp->tmpl = NULL;
    }
    if (ptemp->cont) {
        free(ptemp->cont);
        ptemp->cont = NULL;
    }
}
Пример #7
0
void test_rename(char *workdir) {
    char file1[1024], file2[1024], link[1024],
         subdir[1024], newdir[1024];
    struct stat sb1, sb2;
    int fd;

    printf("testing rename\n");

    sprintf(file1, "%s/file1", workdir);
    sprintf(file2, "%s/file2", workdir);

    /* test stat first.. since we need it to test rename */
    my_stat(file1, &sb1);

    /* Not much to look at, really..  how about making sure that
       the modification time of the file is not in the future.
       allow ten seconds of slack */
    if (sb1.st_mtime > time(NULL) + 10) {
        printf("Modification time of %s is in the future!\n",
               file1);
        exit(1);
    }

    my_rename(file1, file2);

    /* try repeat */
    if (!rename(file1, file2)) {
        printf("repeat rename(%s,%s) worked.. but it shouldn't have\n",
               file1, file2);
        exit(1);
    }


    /* inode number of file2 should be the same as it was for file1 */
    verify_inum(file2, &sb1);


    /* rename back */
    my_rename(file2, file1);

    verify_inum(file1, &sb1);

    /* Make a subdir, which will be renamed */
    sprintf(subdir, "%s/rename_this_dir", workdir);

    my_mkdir(subdir);
    my_stat(subdir, &sb2);

    /* Test moving a file into a subdir */
    sprintf(file2, "%s/file1", subdir);
    my_rename(file1, file2);
    verify_inum(file2, &sb1);

    /* Add in a hard link to spice things up */
    sprintf(link, "%s/link", subdir);
    my_link(file2, link);

    sprintf(newdir, "%s/newdirname", workdir);
    my_rename(subdir, newdir);
    verify_inum(newdir, &sb2);
    sprintf(file2, "%s/file1", newdir);
    verify_inum(file2, &sb1);
    sprintf(link, "%s/newdirname/link", workdir);
    verify_inum(link, &sb1);

    /* Test moving up in the tree */
    my_rename(file2,file1);
    verify_inum(file1, &sb1);

    my_unlink(link);

    my_rmdir(newdir);

}