home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 3 / Meeting_Pearls_III.iso / Pearls / texmf / source / driver / util / decode.c < prev    next >
C/C++ Source or Header  |  1993-07-04  |  4KB  |  203 lines

  1. /**************************************************************************/
  2. /***        decode.c                06.06.89 (hes)    ***/
  3. /**************************************************************************/
  4.  
  5. #include "defines.h"
  6. #include <stdio.h>
  7.  
  8. #include "globals.h"
  9.  
  10. #ifdef ANSI
  11. #  include <string.h>
  12. #  include <stdlib.h>
  13. #endif
  14.  
  15.  
  16. #include "decode.i"
  17.  
  18. #ifdef AMIGA
  19. #  ifdef DISPLAY
  20. #    include "sglobals.i"
  21. #  else
  22. #    include "globals.i"
  23. #  endif
  24. #endif
  25.  
  26.  
  27. #include "version.h"    /* load versions */
  28.  
  29. #include "crypt.h"    /* load crypt Funktions */
  30.  
  31.  
  32.  
  33.  
  34. FILE *f;
  35.  
  36. void decode(char *strin, char *strout)
  37. {
  38.   DECODE(strin,strout);
  39. }
  40.  
  41. void decode2(char *strin, short *strout, int len)
  42. {
  43.   DECODE2(strin,strout,len);
  44. }
  45.  
  46.  
  47. void encode(char *strin, char *strout)
  48. {
  49.   ENCODE(strin,strout);
  50. }
  51.  
  52.  
  53. void encode2(short *strin, char *strout)
  54. {
  55.   ENCODE2(strin,strout);
  56. }
  57.  
  58.  
  59.  
  60. void print_code(char *str)
  61. {
  62. #ifdef CRYPT
  63.   int i;
  64.   long k=0;
  65.   char *kk;
  66.  
  67.   kk = (char *)(((char *)(&k))+3);
  68.   fprintf(f,"{");
  69.   for (i=0;i<strlen(str);i++) {
  70.     *kk=str[i];
  71.     fprintf(f," %ld,",k);
  72.   }
  73.   fprintf(f," 0};\n");
  74. #else
  75.   fprintf(f,"\"%s\";\n",str);
  76. #endif
  77. }
  78.  
  79. void print_code2(short *str, int len)
  80. {
  81.   int i;
  82.   
  83.   fprintf(f,"{ %d, ", (len+3)*3);
  84.   for (i=0; i<len; i++) {
  85.     fprintf(f, " %d,", str[i]);
  86.     if (i % 20 == 0 && i>0) fprintf(f, "\n\t ");
  87.   }
  88.   fprintf(f," %d};\n", 1736);
  89. }
  90.  
  91.  
  92. void print_encode(str)
  93.   char *str;
  94. {
  95.   char strout[80];
  96.  
  97.   encode(str, strout);
  98.   fprintf(f,"  \"%s\"\n",strout);
  99. }
  100.  
  101. void main(int argc,char **argv)
  102. {
  103.   char strout[200];
  104.   char file_name[80];
  105. #if defined(BETACOPYRIGHT)
  106.   short strout2[100];
  107. #endif
  108.  
  109.   if (argc != 2) {
  110.     fprintf(stderr,"Usage: %s outfile\n",argv[0]);
  111.     exit (10);
  112.   }
  113.  
  114.   (void)strcpy(file_name,argv[1]);
  115.  
  116.   fprintf(stdout,"decode: Creating file %s.\n",file_name);
  117.  
  118.   f = fopen(file_name,"w");
  119.   if (f == NULL) {
  120.     fprintf(stderr,"decode: Can't open file!\n");
  121.     exit (15);
  122.   }
  123.  
  124.   fprintf(f,"/************************************************************/\n");
  125.   fprintf(f,"/*******************  %s  *********************/\n",file_name);
  126.   fprintf(f,"/************************************************************/\n");
  127.   fprintf(f,"/**** This file is automaticaly generated from 'decode'! ****/\n");
  128.   fprintf(f,"/**** Based on the files 'version.h' and 'crypt.h'.      ****/\n");
  129.   fprintf(f,"/************************************************************/\n\n");
  130.  
  131.  
  132. #ifdef CRYPT
  133.   fprintf(f,"#define CRYPT\t\t/* encoding enabled */\n\n");
  134. #else
  135.   fprintf(f,"#undef CRYPT\t\t/* encoding disabeld */\n\n");
  136. #endif
  137.  
  138.  
  139.   decode(VERSION_FORMAT_STRING,strout); 
  140.   fprintf(f,"unsigned char VERSION_FORMAT_STRING[] =\n\t");
  141.   print_code(strout);
  142.  
  143.   fprintf(f,"int COMPILER =\t %d;\n",(int)COMPILER+CR_OFFSET);
  144.  
  145.   decode(DVIPRINT_VERSION,strout); 
  146.   fprintf(f,"\nunsigned char DVIPRINT_VERSION[] =\n\t");
  147.   print_code(strout);
  148.  
  149.   decode(SHOWDVI_VERSION,strout);
  150.   fprintf(f,"unsigned char SHOWDVI_VERSION[] =\n\t");
  151.   print_code(strout);
  152.  
  153.  
  154.   fprintf(f,"\n#ifdef DISPLAY\n");
  155.   fprintf(f,"#  define VERSION\tSHOWDVI_VERSION\n");
  156.   decode(PROGRAMTITLE_SHOW,strout);
  157.   fprintf(f,"unsigned char PROGRAMTITLE[] =\n\t");
  158.   print_code(strout);
  159.  
  160.   fprintf(f,"#else\t/* DISPLAY */\n");
  161.   fprintf(f,"#    define VERSION\tDVIPRINT_VERSION\n");
  162.   decode(PROGRAMTITLE_PRINT,strout);
  163.   fprintf(f,"unsigned char PROGRAMTITLE[] =\n\t");
  164.   print_code(strout);
  165.   fprintf(f,"#endif\t/* DISPLAY */\n\n");
  166.  
  167.   decode(PROGRAMKENNUNG,strout);
  168.   fprintf(f,"unsigned char PROGRAMKENNUNG[] =\n\t");
  169.   print_code(strout);
  170.  
  171.   decode(AUTHOR_S_FORMAT,strout);
  172.   fprintf(f,"unsigned char AUTHOR_S_FORMAT[] =\n\t");
  173.   print_code(strout);
  174.   decode(AUTHOR_D_FORMAT,strout);
  175.   fprintf(f,"unsigned char AUTHOR_D_FORMAT[] =\n\t");
  176.   print_code(strout);
  177.   decode(AUTHOR_TITLE,strout);
  178.   fprintf(f,"unsigned char AUTHOR_TITLE[] =\n\t");
  179.   print_code(strout);
  180.   decode(AUTHOR1,strout);
  181.   fprintf(f,"unsigned char AUTHOR1[] =\n\t");
  182.   print_code(strout);
  183.   //decode(AUTHOR2,strout);
  184.   //fprintf(f,"unsigned char AUTHOR2[] =\n\t");
  185.   //print_code(strout);
  186.   decode(AUTHOR3,strout);
  187.   fprintf(f,"unsigned char AUTHOR3[] =\n\t");
  188.   print_code(strout);
  189.   fprintf(f,"\n");
  190.  
  191. #if defined(BETACOPYRIGHT)
  192.   fprintf(f, "#if defined(BETACOPYRIGHT)\n");
  193.   fprintf(f, "unsigned short COPYRIGHT[] =\n\t");
  194.   decode2(COPYRIGHT, strout2, strlen(COPYRIGHT));
  195.   print_code2(strout2, strlen(COPYRIGHT));
  196.   fprintf(f,"\n");
  197.   fprintf(f,"#endif\n");
  198. #endif
  199.  
  200.   exit (0);
  201. }
  202.  
  203.