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

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

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

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