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

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

1.9     ! maekawa     1: /* $OpenXM: OpenXM/rc/repl.c,v 1.8 2003/01/16 07:50:57 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.3       noro       30:   slash = strrchr(cwd,'/');
                     31:   *slash = 0;
1.1       takayama   32:   while (fgets(s,BUFSIZE,stdin) != NULL) {
                     33:        if (strcmp(s,"OpenXM_HOME=$HOME/OpenXM\n") == 0) {
1.3       noro       34:          printf("OpenXM_HOME=%s\n",cwd);
1.1       takayama   35:        }else if (strcmp(s,"setenv OpenXM_HOME $HOME/OpenXM\n") == 0) {
1.3       noro       36:          printf("setenv OpenXM_HOME %s\n",cwd);
1.1       takayama   37:        }else{
                     38:          printf("%s",s);
                     39:        }
                     40:   }
1.4       takayama   41:
                     42:   /* Configuring environmental variables. */
                     43:   /* Check if pstoimg (src/asir-contrib) supports png format. */
                     44:   fp = fopen("/tmp/repl_test.ps","w");
                     45:   if (fp == NULL) {
1.7       takayama   46:      fprintf(stderr,"Open error of /tmp/repl_test.ps. Use the existing file.\n");
                     47:   }else{
                     48:      fprintf(fp,"/Times-Roman findfont 10 scalefont setfont\n");
                     49:      fprintf(fp," 390 290 moveto  (F) show \n");
                     50:      fprintf(fp,"showpage \n");
                     51:      fclose(fp);
1.4       takayama   52:   }
                     53:   if (!system("pstoimg -type png /tmp/repl_test.ps -out /tmp/repl_test.png >/dev/null")) {
                     54:        if (type == 'b') {
                     55:          printf("export OpenXM_PSTOIMG_TYPE=png\n");
                     56:        }else{
                     57:          printf("setenv OpenXM_PSTOIMG_TYPE png\n");
                     58:        }
                     59:   }else if (!system("pstoimg -type gif /tmp/repl_test.ps -out /tmp/repl_test.gif >/dev/null")) {
                     60:        if (type == 'b') {
1.5       takayama   61:          printf("OpenXM_PSTOIMG_TYPE=gif\n");
                     62:       printf("export OpenXM_PSTOIMG_TYPE\n");
1.4       takayama   63:        }else{
                     64:          printf("setenv OpenXM_PSTOIMG_TYPE=gif\n");
                     65:        }
                     66:   }else {
1.5       takayama   67:        printf("OpenXM_PSTOIMG_TYPE=no\n");
                     68:        printf("export OpenXM_PSTOIMG_TYPE\n");
1.4       takayama   69:   }
1.6       takayama   70:   system("rm -f /tmp/repl_test.*");
1.4       takayama   71:
1.8       maekawa    72:
1.2       noro       73:   exit(0);
1.1       takayama   74: }

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