[BACK]Return to repl.c CVS log [TXT][DIR] Up to [local] / OpenXM / rc

Annotation of OpenXM/rc/repl.c, Revision 1.8

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>