Annotation of OpenXM/rc/repl.c, Revision 1.6
1.6 ! takayama 1: /* $OpenXM: OpenXM/rc/repl.c,v 1.5 2001/09/18 08:29:26 takayama Exp $ */
1.1 takayama 2: #include <stdio.h>
3: #include <unistd.h>
1.3 noro 4: #include <string.h>
1.1 takayama 5:
6: #define BUFSIZE 10000
1.4 takayama 7: main(int argc,char *argv[]) {
1.1 takayama 8: char s[BUFSIZE];
9: char cwd[BUFSIZE];
1.3 noro 10: char *slash;
1.4 takayama 11: char type = 'b';
12: FILE *fp;
13:
14: if (argc >= 2) {
15: if (strcmp(argv[1],"csh")==0) {
16: type = 'c';
17: }
18: }
1.3 noro 19:
1.1 takayama 20: getcwd(cwd,BUFSIZE);
1.3 noro 21: slash = strrchr(cwd,'/');
22: *slash = 0;
1.1 takayama 23: while (fgets(s,BUFSIZE,stdin) != NULL) {
24: if (strcmp(s,"OpenXM_HOME=$HOME/OpenXM\n") == 0) {
1.3 noro 25: printf("OpenXM_HOME=%s\n",cwd);
1.1 takayama 26: }else if (strcmp(s,"setenv OpenXM_HOME $HOME/OpenXM\n") == 0) {
1.3 noro 27: printf("setenv OpenXM_HOME %s\n",cwd);
1.1 takayama 28: }else{
29: printf("%s",s);
30: }
31: }
1.4 takayama 32:
33: /* Configuring environmental variables. */
34: /* Check if pstoimg (src/asir-contrib) supports png format. */
35: fp = fopen("/tmp/repl_test.ps","w");
36: if (fp == NULL) {
37: fprintf(stderr,"Open error of /tmp/repl_test.ps\n");
38: exit(10);
39: }
40: fprintf(fp,"/Times-Roman findfont 10 scalefont setfont\n");
41: fprintf(fp," 390 290 moveto (F) show \n");
42: fprintf(fp,"showpage \n");
43: fclose(fp);
44: if (!system("pstoimg -type png /tmp/repl_test.ps -out /tmp/repl_test.png >/dev/null")) {
45: if (type == 'b') {
46: printf("export OpenXM_PSTOIMG_TYPE=png\n");
47: }else{
48: printf("setenv OpenXM_PSTOIMG_TYPE png\n");
49: }
50: }else if (!system("pstoimg -type gif /tmp/repl_test.ps -out /tmp/repl_test.gif >/dev/null")) {
51: if (type == 'b') {
1.5 takayama 52: printf("OpenXM_PSTOIMG_TYPE=gif\n");
53: printf("export OpenXM_PSTOIMG_TYPE\n");
1.4 takayama 54: }else{
55: printf("setenv OpenXM_PSTOIMG_TYPE=gif\n");
56: }
57: }else {
1.5 takayama 58: printf("OpenXM_PSTOIMG_TYPE=no\n");
59: printf("export OpenXM_PSTOIMG_TYPE\n");
1.4 takayama 60: }
1.6 ! takayama 61: system("rm -f /tmp/repl_test.*");
1.4 takayama 62:
63:
1.2 noro 64: exit(0);
1.1 takayama 65: }
66:
67:
68:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>