Annotation of OpenXM/rc/repl.c, Revision 1.4
1.4 ! takayama 1: /* $OpenXM: OpenXM/rc/repl.c,v 1.3 2000/01/20 02:34:49 noro 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') {
! 52: printf("export OpenXM_PSTOIMG_TYPE=gif\n");
! 53: }else{
! 54: printf("setenv OpenXM_PSTOIMG_TYPE=gif\n");
! 55: }
! 56: }else {
! 57: printf("export OpenXM_PSTOIMG_TYPE=no\n");
! 58: }
! 59: /* system("rm -f /tmp/repl_test.*"); */
! 60:
! 61:
1.2 noro 62: exit(0);
1.1 takayama 63: }
64:
65:
66:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>