/* | | | | ( ! ) Gerdsooz - Release 1.2 (March 1993) \ / (A Mash Cheragh-Ali Product) --- | |--0 Copyright (c) 1996 |___| NetNative ! ! native@netnative.com ! ! P.O.Box 391403 / \ Mountain View, Ca. 94039-1403 ~~~~~ * Copyright (c) 1992-96 NetNative * * Permission to use this software is hereby granted without fee, provided * that there is no fee charged by the user. Also, no part of this software * may be modified or used in a commercial software or service without the * specific, prior written permission of NetNative. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL NETNATIVE BE LIABLE FOR ANY SPECIAL, INCIDENTAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE * POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. . | . : c | / | = , o_ > q_7 |_o q ]_,_,_w |_) . | _)_ > ( : / / / (_) / : . . | = |: | / | ! ]_ q_7_ . | _)_ > |_ o_ |_)_ |_o / / . (_) / : ( : / . ****************************************************************************/ #include #include #include #define EOL_char '\n' #define NOTEOL '\\' #define BLANK ' ' #define TAB 0x09 #define TABINDEX 98 #define EOLINDEX 99 #define FALSE 0 #define TRUE 1 #define MAXINDEX 400 #define MAXX 23 #define MAXY 28 #define LINEWIDTH 60 #define default_font "mikhi-10" #define mark1 "=begin=" #define mark2 "=end=" #ifdef __MSDOS__ #define FONT(i,j,k) font[k]->array[i][j] #else #define FONT(i,j,k) (font[i][j][k]) #endif FILE *in_file, *out_file, *font_file; char file_name[100]; int width[MAXINDEX]; #ifdef __MSDOS__ struct FontArray {char array[MAXX][MAXY];}; struct FontArray *font[MAXINDEX]; #else char font[MAXX][MAXY][MAXINDEX]; #endif char EOF_char; int type[128]; char line_out[LINEWIDTH][MAXY]; char line_tmp[LINEWIDTH][MAXY]; int line_x, word_x, save_x; int height; int full; int echo; main(argc, argv) int argc; char *argv[]; { #ifdef __MSDOS__ int i; for (i=0; i \n"); return 1; } else font_flag = TRUE; else if ((strcmp(*argv, "-i")) == 0) if ((in_file = fopen(*++argv, "r")) == NULL) { printf("<== Cannot Open Input File ==> \n"); return 1; } else { strcpy(file_name, *argv); in_flag = TRUE; } else if ((strcmp(*argv, "-o")) == 0) { out_file = fopen(*++argv, "w"); out_flag=TRUE; } else if ((strcmp(*argv, "-n")) == 0) echo=FALSE; else { printf("illegal option ==> %s\n", *argv); return(1); } } if (!font_flag) if ((font_file = fopen(default_font, "r")) == NULL) { printf("<== Cannot Open mikhi-10 Font File ==> \n"); return 1; } if (!in_flag) { in_file = stdin; echo = FALSE; } if (!out_flag) out_file = stdout; return(0); } read_font() { #define NEWCHAR 'L' char in_char; int index; int i, j, location; char in_line[100]; zeroout(); while ((in_char = getc (font_file)) != 'h') if (in_char !=EOL_char ) fgets (in_line, 20, font_file); /* go to next line */ fscanf (font_file,"%d",&height); fgets (in_line, 20, font_file); /* next line */ while ((in_char = getc (font_file)) != EOF_char) { if (in_char == NEWCHAR) { in_char = getc (font_file); if (in_char == TAB) index = TABINDEX; else index=in_char - 32; type[index]++; in_char=getc(font_file); /* get location */ location = in_char-48; index = index + location*100; fgets (in_line, 20, font_file); /* next line ??? */ for (j=0; j width[index]) width[index] = i; } } } } wrapup() { char in_char; fclose(in_file); if (echo) { putc (EOL_char, out_file); fprintf (out_file, "%s\n", mark1); in_file = fopen(file_name, "r"); while ((in_char = getc(in_file)) != EOF_char) putc (in_char, out_file); fprintf (out_file, "%s\n", mark2); fclose(in_file); } fclose(out_file); } zeroout() { int i, j, k; for (i=0; i<128; i++) type[i]=0; for (k=0; k0; i--) line_out[i-1][j] = BLANK; line_x=0; word_x=0; } write_line() { int i , j; for (j=0; j0; i--) { putc(line_out[i-1][j], out_file); line_out[i-1][j] = BLANK; } putc (EOL_char, out_file); } putc (EOL_char, out_file); line_x=0; word_x=0; full = FALSE; } add_char(index) int index; { int i , j, w; w = width[index]; for (j=0; j0; i--) line_out[line_x+w-i][j] = FONT(i-1,j,index); line_x=line_x+w; full = TRUE; } save_chars() { int i , j; save_x=line_x-word_x; for (j=0; j1 && type[index]==4) index=index+300; /* middle form */ else { index=index+100; /* end form */ attach=FALSE; } else /* begin, or separate form */ if(type[index]==4 && type[next_index]>1) { index=index+200; /* begin form */ attach=TRUE; } /* else separate form */ tmp = line_x+width[index]+1; if (tmp > LINEWIDTH) { if (word_x > 0) { save_chars(); write_line(); restore_chars(); } else write_line(); } add_char(index); /* if (index == 32) */ if (index == 0) word_x = line_x; /* index for last word */ } pres_char = next_char; } if (full) write_line(); }