home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / utilitys / 93 / makersh / output.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-10-12  |  5.3 KB  |  212 lines

  1. /*
  2.    This program may be freely
  3.   distributed , copied,and modified so long
  4. as a fee is not charged. However,
  5. I reserve all rights available to
  6. me under The Copyright Act.
  7. If you find any bugs please feel free to contact me.
  8.   David DeGeorge
  9.   Princeton,New Jersey
  10.   March 1987
  11.  
  12. USENET:  ....princeton!idacrd!dld
  13. COMPUSERVE: 74176,3210
  14. GENIE: DEGEORGE
  15. */
  16.  
  17. /*
  18.   This file contains most of
  19.   the text output routines 
  20.   for makersh
  21. */  
  22.  
  23. #include  "makersh.h"
  24.  
  25. printobj(p)
  26. OBJECT *p;
  27.  
  28. {       union ptr { BITBLK *qb;
  29.             ICONBLK *qi;
  30.         } q;
  31.     int j;
  32.     switch( p->ob_type & 0xFF){  /* mask off the low order byte
  33.                     so we are not misled by
  34.                     the extended types feature
  35.                       */
  36.     case G_STRING:
  37.         case G_BUTTON:
  38.         case G_TITLE:
  39.                  p->ob_spec = findstr(p ->ob_spec);
  40.                  break;
  41.     case G_BOXTEXT:
  42.     case G_FTEXT:
  43.     case G_FBOXTEXT:
  44.     case G_TEXT:
  45.          p->ob_spec=(p->ob_spec-(long)rheader.rsh_tedinfo)/sizeof(TEDINFO);
  46.                break;
  47.     case G_IMAGE:
  48.             q.qb = (BITBLK *)( head +(int)(p->ob_spec));
  49.          p->ob_width = q.qb->bi_wb;
  50.          p->ob_height = (q.qb -> bi_hl )/8 ;
  51.          p->ob_spec=(p->ob_spec-(long)rheader.rsh_bitblk)/sizeof(BITBLK);
  52.               break;
  53.     case G_ICON:
  54.            q.qi = (ICONBLK *)(head + (int)( p->ob_spec));
  55.            p->ob_width = q.qi ->ib_wicon/8 ;
  56.            p -> ob_height = q.qi -> ib_hicon/8 ;
  57.       p->ob_spec=(p->ob_spec-(long)rheader.rsh_iconblk)/sizeof(ICONBLK);
  58.              break;     
  59.      default:
  60.              break;
  61.             } 
  62.                       
  63.     fprintf(out,"%d,",p->ob_next);
  64.     fprintf(out,"%d,",p->ob_head);
  65.     fprintf(out,"%d,",p->ob_tail);
  66.     if ( p -> ob_type <= 32 )
  67.            fprintf(out,"%s,",types[ p->ob_type -20]);
  68.      else
  69.             fprintf(out,"0x%x,",p -> ob_type);
  70.     fprintf(out,"0x%x,",p->ob_flags);
  71.     fprintf(out,"0x%x,",p->ob_state);
  72.     fprintf(out,"%DL,",p->ob_spec);
  73.     fprintf(out,"0x%x,",p->ob_x);
  74.     fprintf(out,"0x%x,",p->ob_y);    
  75.     fprintf(out,"0x%x,",p->ob_width);
  76.     fprintf(out,"0x%x",p->ob_height);
  77. }
  78.  
  79. printbit(p)
  80. BITBLK *p;
  81. {
  82.     fprintf(out,"%DL,",p->bi_pdata);
  83.     fprintf(out,"%d,",p->bi_wb);
  84.     fprintf(out,"%d,",p->bi_hl);
  85.     fprintf(out,"0x%x,",p->bi_x);
  86.         fprintf(out,"0x%x,",p->bi_y);
  87.         fprintf(out,"0x%x",p->bi_color);
  88. }
  89.  
  90.  
  91. printicon(p)
  92. ICONBLK *p;
  93. {
  94.     fprintf(out,"%DL,",p->ib_pmask);
  95.     fprintf(out,"%DL,",p->ib_pdata);
  96.     fprintf(out,"%DL,",p->ib_ptext);    
  97.     fprintf(out,"%d,",p->ib_char);
  98.     fprintf(out,"%d,",p->ib_xchar);
  99.     fprintf(out,"%d,",p->ib_ychar);
  100.         fprintf(out,"%d,",p->ib_xicon);
  101.         fprintf(out,"%d,",p-> ib_yicon);
  102.     fprintf(out,"%d,",p->ib_wicon);
  103.     fprintf(out,"%d,",p->ib_hicon);
  104.     fprintf(out,"%d,",p->ib_xtext);
  105.         fprintf(out,"%d,",p->ib_ytext);
  106.         fprintf(out,"%d,",p->ib_wtext);        
  107.         fprintf(out,"%d,",p->ib_htext);                
  108.         fprintf(out,"%d",0);
  109.         
  110. }
  111.  
  112.   
  113.  
  114. printted(p)
  115. TEDINFO *p;
  116. {
  117.     p->te_ptext = findstr(p->te_ptext);
  118.     p->te_ptmplt = findstr(p->te_ptmplt);
  119.     p->te_pvalid = findstr(p->te_pvalid);        
  120.     fprintf(out,"%DL,",p->te_ptext);
  121.     fprintf(out,"%DL,",p->te_ptmplt);
  122.     fprintf(out,"%DL,",p->te_pvalid);
  123.     fprintf(out,"%d,",p->te_font);
  124.     fprintf(out,"%d,",p->te_junk1);
  125.     fprintf(out,"%d,",p->te_just);
  126.     fprintf(out,"%d,",p->te_color);
  127.     fprintf(out,"%d,",p->te_junk2);
  128.     fprintf(out,"%d,",p->te_thickness);
  129.     fprintf(out,"%d,",p->te_txtlen);
  130.     fprintf(out,"%d",p->te_tmplen);
  131. }
  132.  
  133. error(s,type)
  134. char *s;
  135. ERROR type;
  136. {
  137.     char mesag[80];
  138.     int but;
  139.       switch(type){
  140.           
  141.               case WARN:
  142. #ifdef GEM              
  143.                         sprintf(mesag,"[2][%s][continue|abort]",s);
  144.                         but=form_alert(1,mesag);
  145.                         if (but == 2 )leave();
  146. #else
  147.             fprintf(stderr,"%s\nPress return to continue q to exit ",s);
  148.                  if ( getchar() == 'q') exit(1);
  149. #endif                 
  150.                           return;
  151.               case NOMEM:
  152. #ifdef GEM              
  153.                      sprintf(mesag,"[3][Can't allocate mem|for %s][abort]",s);
  154.                form_alert(1,mesag);
  155.                leave();
  156. #else
  157.                fprintf(stderr,"Can't allocate memory for %s\n",s);
  158.                exit(1);
  159. #endif               
  160.               case FATAL:
  161. #ifdef GEM              
  162.                     sprintf(mesag,"[3][%s][abort]",s);
  163.                     form_alert(1,mesag);
  164.               leave();
  165. #else
  166.             fprintf(stderr,"%s.Aborting....\n",s);
  167.             exit(1);
  168. #endif
  169. #ifndef GEM
  170.           case USAGE:
  171.               fprintf(stderr,"Usage: RSC-file RSH-file\n");
  172.                      exit(1);                          
  173. #endif               
  174.                default:
  175. #ifdef GEM               
  176.              sprintf(mesag,"[2][Unknown error][continue|abort]",s);
  177.              if(but == 2)leave();
  178.              return;
  179. #else
  180.                   fprintf(stderr,"Unknown error.Aborting...\n");
  181.                 exit(1);
  182. #endif                
  183.             }    
  184. }
  185.  
  186. long
  187. makeimage(p,size)
  188. long p ;
  189. int size;       /* size is in words */
  190.                                     
  191. {       int new ;
  192.         int temp;
  193.         int *mymy;
  194.         int i,j;
  195.         if ( size == 0 )return;
  196. #ifdef GEM        
  197.         imgprog(nimages + 1);
  198. #endif        
  199.     curimage += 1;
  200.     nimages++;
  201.     mymy = ( int *)( head + (int) p);
  202.     fprintf(out,"\nint IMAG%d[]={\n",curimage);
  203.           for(i=0; i < size-1 ; i++){
  204.           fprintf(out,"0x%x,",mymy[i]);
  205.           if( i % 4 == 0)fprintf(out,"\n");
  206.         }
  207.         fprintf(out,"0x%x",mymy[size-1]);
  208.         fprintf(out,"\n};");
  209.         return((long)curimage);
  210. }
  211.  
  212.