home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / etc / hardware / xprestok.txt < prev    next >
Encoding:
Internet Message Format  |  2003-06-11  |  19.5 KB

  1. Subject: Xpress headers & stuff
  2. Date: Sat, 21 Jul 90 11:22:28 -0600
  3.  
  4.  
  5. Hi,
  6.   Attached find the list of Xpress tokens, and what they mean.  Some of this
  7. is figured out by taking there program apart, and others are from context.
  8. I'll also include a very primitive program, for UNIX, that decodes the
  9. headers in the datastream.  The packet boundary marker is a 0xFF.
  10.  
  11. ============================================================================
  12.  
  13.  
  14. # MAIN MENU
  15. N******* "News"
  16. S******* "Sports"
  17. W******* "Weather"
  18. L******* "Lifestyles"
  19. E******* "Entertainment"
  20. T******* "Tech Talk"
  21. M******* "Shopping"
  22. I******* "Information on X*CHANGE"
  23. X******* "Inside X*PRESS"
  24. B******* "Business Wire"
  25. F******* "Financial News"
  26.  
  27. # BUSINESS WIRE
  28. B??AG*** "Canadian Press(CP): Business Report"
  29. B??HS*** "McGraw-Hill News SNAPSHOT"
  30. B??RB*** "BUSINESS-WIRE: Company PR W.R.T. Stock"
  31. B??RP*** "PR Newswire"
  32. B??SI*** "NYSE Standard and Poors Indices"
  33.  
  34. # ENTERTAINMENT
  35. E??H**** "The Stars"
  36. E??L**** "TV Schedules"
  37. E??M**** "Movies, Books, and Music"
  38. E??S**** "TV Scope"
  39. E??W**** "What's happening"
  40.  
  41. # FINANCIAL NEWS
  42. F??CC*** "Commodity Commentary"
  43. F??CF*** "Weekly Farm Report"
  44. F??CP*** "Commodity Prices"
  45. F??F**** "Weekly Mutual Fund Commentary"
  46. F??MC*** "Money Commentary"
  47. F??ME*** "Foreign Exchange Rates"
  48. F??MM*** "Interest and Money Rates"
  49. F??MU*** "US Treasury Bills Rates"
  50. F??O**** "Financial News Headlines"
  51. F??Og*** "Selected Press Releases/Financial Reports"
  52. F??Oi*** "Daily Insider Trading Report"
  53. F??PMR** "Today's Interest Rates"
  54. F??POC** "Market Statistics"
  55. F??POM** "Just a Reminder!"
  56. F??SA*** "Hourly Dow Jones Averages"
  57. F??SC*** "New York Stock Market Commentary"
  58. F??SD*** "Daily Dividends"
  59. F??SR*** "Daily Most Active Stocks"
  60. F??TIG** "Daily Gold and Silver Prices"
  61. F??TM*** "Metals Prices"
  62.  
  63. # X*CHANGE INFORMATION
  64. I??C**** "Computers and You"
  65. I??I**** "Inside your Head"
  66. I??P**** "Pot Shots"
  67. I??R**** "Religion, Sex, and Politics"
  68. I??S**** "Students, Teachers, and Parents"
  69. I??T**** "Teen Talk"
  70. I??U**** "Using Information X*Change"
  71. I??W**** "The World Around You"
  72.  
  73. # LIFESTYLES
  74. L??C**** "Careers"
  75. L??E**** "Food"
  76. L??F**** "Family Today"
  77. L??H**** "Fitness & Fun"
  78. L??M**** "Moneywise"
  79. L??T**** "Trends & Events"
  80.  
  81. # SHOPPING
  82. M??B**** "Best Buys"
  83. M??Bg*** "Newsletter Samplers and Information"
  84. M??F**** "Fleamarket"
  85. M??S**** "Shopper's Showcase"
  86. M??Sq*** "Online catalog"
  87. M??T**** "Travel and Leisure"
  88. M??Tl*** "Ski Area Snow Reports"
  89.  
  90. # NEWS
  91. N??B**** "Business & Finance"
  92. N??E**** "Opinions & Editorial"
  93. NA****** "Headlines"
  94. NA*C**** "AP Commentary"
  95. NA*Ci*** "States News Service: Merger Information and Rumors"
  96. NA*H**** "AP Headline Stories"
  97. NA*N**** "AP News Story"
  98. NC*H**** "Canada"
  99. NC*N**** "CP Editorial"
  100. NCEN**** "CP In Depth Story"
  101. NI1***** "France"
  102. NI3***** "Republic of China, Taiwan"
  103. NI5***** "West Germany"
  104. NI6***** "Japan"
  105. NI7***** "Mexico"
  106. NI8***** "Oil Exporting Countries"
  107. NI9***** "Soviet Union"
  108. NIA***** "Other International News"
  109. NIB***** "People's Republic of China"
  110.  
  111. # SPORTS
  112. S??H**** "Sports Headlines"
  113. S??S**** "Sports General Schedules"
  114. S??T**** "Sports TV Schedules"
  115. S??F**** "Pro Football"
  116. S??F1*** "Pro Football News"
  117. S??F2*** "Pro Football NFL News"
  118. S??F3*** "Pro Football CFL News"
  119. S??D**** "Pro Baseball"
  120. S??D1*** "Pro Baseball News"
  121. S??D2*** "Pro Baseball Major League News"
  122. S??D3*** "Pro Baseball Minor League News"
  123. S??B**** "Pro Basketball"
  124. S??P**** "Pro Hockey"
  125. S??K**** "Pro Soccer"
  126. S??G**** "Pro Golf and Tennis"
  127. S??U**** "USA Collage Sports"
  128. S??C**** "Canadian Sports"
  129. S??M**** "Other Sports"
  130. S??Q**** "Sports Quiz Questions"
  131. S??A**** "Sports Quiz Answers"
  132.  
  133. # TECH TALK
  134. T??A**** "Apple Technical News"
  135. T??Ab*** "Apple Bulleten Board"
  136. T??Bb*** "IBM PC and Clone Bulleten Board"
  137. T??C**** "Commodore Technical News"
  138. T??Cb*** "Commodore Bulleten Board"
  139. T??I**** "IBM PC Technical News"
  140. T??Ib*** "IBM PC Bulleten Board"
  141. T??M**** "Other PC Technical News"
  142. T??Mb*** "Other PCs Bulleten Board"
  143. T??N**** "Technical News"
  144.  
  145. # WEATHER
  146. WI****** "International Weather"
  147. WN****** "USA National Weather"
  148. WS****** "USA State Weather"
  149. WC****** "Canadian National Weather"
  150. WR****** "Canadian Regional Weather"
  151. WSA***** "Alabama Weather"
  152. WSB***** "Alaska Weather"
  153. WSC***** "Arizona Weather"
  154. WSD***** "Arkansas Weather"
  155. WSE***** "California Weather"
  156. WSF***** "Colorado Weather"
  157. WSG***** "Connecticut Weather"
  158. WSH***** "Delaware Weather"
  159. WSI***** "District of Columbia Weather"
  160. WSJ***** "Florida Weather"
  161. WSK***** "Georgia Weather"
  162. WSL***** "Hawaii Weather"
  163. WSM***** "Idaho Weather"
  164. WSN***** "Illinois Weather"
  165. WSO***** "Indiana Weather"
  166. WSP***** "Iowa Weather"
  167. WSQ***** "Kansas Weather"
  168. WSR***** "Kentucky Weather"
  169. WSS***** "Louisiana Weather"
  170. WST***** "Maine Weather"
  171. WSU***** "Maryland Weather"
  172. WSV***** "Massachusetts Weather"
  173. WSW***** "Michigan Weather"
  174. WSX***** "Minnesota Weather"
  175. WSY***** "Mississippi Weather"
  176. WSZ***** "Missouri Weather:
  177. WSa***** "Montana Weather"
  178. WSb***** "Nebraska Weather"
  179. WSc***** "Nevada Weather"
  180. WSd***** "New Hampshire Weather"
  181. WSe***** "New Jersey Weather"
  182. WSf***** "New Mexico Weather"
  183. WSg***** "New York Weather"
  184. WSh***** "North Carolina Weather"
  185. WSi***** "North Dakota Weather"
  186. WSj***** "Ohio Weather"
  187. WSk***** "Oklahoma Weather"
  188. WSl***** "Oregon Weather"
  189. WSm***** "Pennsylvania Weather"
  190. WSn***** "Rhode Island Weather"
  191. WSo***** "South Carolina Weather"
  192. WSp***** "South Dakota Weather"
  193. WSq***** "Tennessee Weather"
  194. WSr***** "Texas Weather"
  195. WSs***** "Utah Weather"
  196. WSt***** "Vermont Weather"
  197. WSu***** "Virginia Weather"
  198. WSv***** "Washington Weather"
  199. WSw***** "West Virginia Weather"
  200. WSx***** "Wisconsin Weather"
  201. WSy***** "Wyoming Weather"
  202. WR1***** "Alberta/North West Territories Canadain Regional Weather"
  203. WR2***** "British Columbia Canadain Regional Weather"
  204. WR3***** "Mantoba/Saskatchewan Canadain Regional Weather"
  205. WR4***** "The Maritimes Canadain Regional Weather"
  206. WR5***** "Newfoundland/Labrador Canadain Regional Weather"
  207. WR6***** "Ontario/Great Lakes Canadain Regional Weather"
  208. WR7***** "Quebec Canadain Regional Weather"
  209. WR8***** "Yukon Canadain Regional Weather"
  210.  
  211. # INSIDE X*PRESS
  212. X??B**** "X*Press Bulletins"
  213. X??N**** "X*Press News"
  214. X??P**** "X*Press New Services"
  215. X??S**** "What to Watch for in X*Press"
  216. X??T**** "X*Press User Tips"
  217.  
  218. ============================================================================
  219.  
  220. This program runs against a data file that contains raw Xpress datastreams.
  221. If you can write a small PC program to read from the com line and write to
  222. the file, you ought to be all set.  Be sure to use the correct I/O routines
  223. for DOS or you might find funny EOFs.
  224.  
  225.  
  226.  
  227. /* This program is designed to parse a large file of X*Press raw data      */
  228. /* into individual articles.  These articles will then be output to        */
  229. /* stdout formated as best I can.  The headers will, for sure, be right    */
  230.  
  231. #include <stdio.h>
  232. #include <fcntl.h>
  233. #include <ctype.h>
  234. #include <signal.h>
  235. #include <time.h>
  236. #include <errno.h>
  237. #include <sys/termio.h>
  238. #include <sys/tty.h>
  239. #include <sys/types.h>
  240. #include <sys/times.h>
  241.  
  242. /* Local defines                                                           */
  243. #define SOH    0xFF                /* Start Of Header for Link level       */
  244. #define LLHLEN 6                   /* SOH,SEQ.low,SEQ.high,6 more bytes    */
  245. #define ARHLEN 23                  /* Article header length                */
  246. #define ARMLEN 8                   /* Article header minimum length        */
  247.  
  248.  
  249. /* Local global variables                                                  */
  250. char *cats = "NSWLETMIXBF";
  251.  
  252.  
  253. /* resync - This routine will read from the fd passed until it gets a SOH  */
  254. resync(fd)
  255.   FILE *fd;                        /* The file descriptor to read from     */
  256.  
  257. {
  258.   int rc = 0x03;                   /* Init to something                    */
  259.  
  260.   /* Loop through looking for SOH                                          */
  261.   while (rc!=SOH)
  262.     {
  263.     rc = getc(fd);                 /* Read the next byte from file         */
  264.     if (rc == EOF)                 /* Have we bumped into the end of file? */
  265.       {                            /* YES - Ok,the program is done         */
  266.       printf("***EOF***\n");       /* Say all done                         */
  267.       exit(0);
  268.       }
  269.     }
  270.  
  271.   /* Put the SOH back on the stream and return                             */
  272.   if (EOF == ungetc(SOH,fd))       /* Try to put the SOH back              */
  273.   {                                /* It didn't work                       */
  274.     fprintf(stderr,"resync:Unable to place SOH back in stream\n");
  275.     exit(8);
  276.   }
  277.  
  278.   return;
  279. }
  280.  
  281.  
  282.  
  283. main(argc,argv)
  284.   int argc;
  285.   char *argv[];
  286.  
  287. {
  288.   FILE *fd;                        /* Used to open '/tmp/siolog'           */
  289.   int i,j;                         /* Misc. guys                           */
  290.   unsigned short seq;              /* The sequence number for stream       */
  291.   int getseq = 1;                  /* Beginning sequence num must be set   */
  292.   int isok;                        /* Flag set if article type is known    */
  293.   int doprt;                       /* The print/noprint flag               */
  294.   unsigned char data;              /* The byte being checked               */
  295.   unsigned char s_low,s_high;      /* Sequence number low & high bytes     */
  296.   unsigned int utmp,dtmp;          /* Used for stuff likes equence numbers */
  297.   unsigned char LLHead[LLHLEN];    /* Link Layer Header                    */
  298.   unsigned char ARHead[ARHLEN];    /* Article header                       */
  299.   unsigned char outarray[17];      /* The output array we are building     */
  300.  
  301.  
  302.   /* Replace # with * in the input parms for match                         */
  303.   if (argc > 1)
  304.     {
  305.     j = strlen(argv[1]);
  306.     for (i=0;i<j;i++)
  307.       if (argv[1][i] == '#')
  308.         argv[1][i] = '*';
  309.       else
  310.         if (argv[1][i] == '@')
  311.           argv[1][i] = '?';
  312.     }
  313.  
  314.   /* Attempt to open the file and bomb if it's not there                   */
  315.   fd = fopen("/usr/spool/xpress","r");
  316.   if (!fd)                         /* Is the file available?               */
  317.     {                              /*  NO - Ok, all done then              */
  318.     fprintf(stderr,"main:Unable to open Xpress datastream file\n");
  319.     exit(8);
  320.     }
  321.  
  322.   /* Before the main loop, try to sync on a SOH                            */
  323.   resync(fd);                      /* Get to beginning of article          */
  324.  
  325.   /* The main loop                                                         */
  326.   while (!feof(fd))                /* Loop until data exhausted            */
  327.   {                                /* We are at the beginning of stream    */
  328.     if (SOH!=(data=getc(fd)))      /* We should beat a SOH character       */
  329.       {                            /* Error out if we aren't               */
  330.       fprintf(stderr,"main:Missing SOH for a new record\n");
  331.       exit(8);
  332.       }
  333.  
  334.     /* Try to the the link layer sequence number                           */
  335.     s_low = getc(fd);              /* Get the sequence number low byte     */
  336.     s_high = getc(fd);             /*   and the high byte                  */
  337.     utmp = 256 * s_high + s_low;   /* Make it into a real number           */
  338.     if (feof(fd))                  /* Did anything bad happen?             */
  339.       {                            /* Sometimes I get tired of error chking*/
  340.       printf("***EOF***\n");       /* If EOF,then all done                 */
  341.       exit(0);
  342.       }
  343.  
  344.     /* Check the sequence number for a match                               */
  345.     if (getseq)                    /* Should we get the sequence number?   */
  346.       {                            /* YES - Ok, utmp contains seq#         */
  347.       seq = utmp;                  /* Get the initial sequence number      */
  348.       getseq = 0;                  /* Reset the flag that says we got it   */
  349.       }
  350.     else
  351.       if (++seq != utmp)           /* Check for a sequence number match    */
  352.         {                          /* I'll probably have to do more here...*/
  353.         dtmp = 100;                /* See how far off we are?              */
  354.         j = 0;                     /* Total number of trys                 */
  355.         while ((dtmp > 10) && (j < 10))
  356.           {
  357.           resync(fd);              /* Find the next SOH                    */
  358.           getc(fd);                /* Get the SOH, and ignore it           */
  359.           s_low = getc(fd);        /* Get the sequence number low byte     */
  360.           s_high = getc(fd);       /*   and the high byte                  */
  361.           utmp = 256 * s_high + s_low;
  362.           if (feof(fd))            /* Did anything bad happen?             */
  363.             {                      /* Sometimes I get tired of error chking*/
  364.             printf("***EOF***\n"); /* If EOF,then all done                 */
  365.             exit(0);
  366.             }
  367.           dtmp = abs(utmp - seq);  /* Find a new offset                    */
  368.           j++;                     /* Count this iteration                 */
  369.           }
  370.         if (j == 10)               /* Did we get completely lost?          */
  371.           printf("main: Expecting seq number %u, resynced to %u\n",seq,utmp);
  372.         else
  373.           if (seq != utmp)         /* Did we find the one we wanted?       */
  374.             {                      /* Much stuff to do here                */
  375.             if (abs(utmp - seq) > 10)
  376.               printf("main: Expecting seq=%u, resynced to seq=%u\n",seq,utmp);
  377.             seq = utmp;
  378.             }
  379.         }
  380.  
  381.     /* Get the rest of the Link Level header                               */
  382.     for (i=0;i<LLHLEN;i++)         /* Get the rest of link layer header    */
  383.       {
  384.       j = getc(fd);                /* Get a single character               */
  385.       if (j == EOF)                /* Did we run out of runway?            */
  386.         {                          /* YES - All done then?                 */
  387.         printf("***EOF***\n");
  388.         exit(0);
  389.         }
  390.       LLHead[i] = (unsigned char)j; /* Save the byte we just grabbed.      */
  391.       }
  392.  
  393.     /* Fill in the article header                                          */
  394.     for (i=0;i<ARMLEN;i++)         /* Get the minimum article header length*/
  395.       {                            /* Try to move the header in            */
  396.       j = getc(fd);                /* Attempt to get a header byte         */
  397.       if (j == EOF)                /* Make sure we didn't EOF the sucker   */
  398.         {
  399.         printf("***EOF***\n");
  400.         exit(0);
  401.         }
  402.       ARHead[i] = (unsigned char)j; /* The byte we just grabbed            */
  403.       }
  404.  
  405.     /* If the article ID token is known, get the rest of the header        */
  406.     isok = strchr(cats,ARHead[0]) ? 1 : 0;
  407.     for (i=ARMLEN;i<ARHLEN;i++)    /* Loop through the rest of the header  */
  408.       if (isok)                    /* Is this a 'known' article?           */
  409.         {                          /* YES - Fill in the rest of the header */
  410.         j = getc(fd);
  411.         if (j == EOF)
  412.           {
  413.           printf("***EOF***\n");
  414.           exit(0);
  415.           }
  416.         ARHead[i] = (unsigned char)j;
  417.         }
  418.       else                         /*  NO - Lots more work to go           */
  419.         ARHead[i] = 0x00;          /* Just fill in empty header stuff      */
  420.  
  421.     /* Display the header information                                      */
  422.     data = ARHead[ARMLEN];         /* Remember the first header byte       */
  423.     ARHead[ARMLEN] = 0x00;         /* Null terminate the type              */
  424.     doprt = 1;                     /* Assume we print this one             */
  425.     if (argc > 1)
  426.       if (strcmp(ARHead,argv[1]))
  427.         doprt = 0;                 /* If we didn't match                   */
  428.     if (doprt)
  429.       {
  430.       printf("%5.5u",seq);         /* Start of header                      */
  431.       printf("%c ",(isok ? '>' : '}'));
  432.       for (i=0;i<LLHLEN;i++)       /* Print every byte of header           */
  433.         printf("%2.2X",LLHead[i]);
  434.       printf(" %8.8s ",ARHead);    /* Show article type                    */
  435.       ARHead[ARMLEN] = data;       /* Restore article header byte          */
  436.       }
  437.     if (isok && doprt)             /* Do we know about this article type?  */
  438.       {                            /* YES - Decode and print header        */
  439.       printf("%2.2X/%2.2X/%2.2X %2.2X:%2.2X:%2.2X.%2.2X ",
  440.              ARHead[ARMLEN+1],ARHead[ARMLEN+2],ARHead[ARMLEN+0],
  441.              ARHead[ARMLEN+3],ARHead[ARMLEN+4],ARHead[ARMLEN+5],
  442.              ARHead[ARMLEN+6]);
  443.       for (i=ARMLEN+7;i<ARHLEN;i++)
  444.         printf("%2.2X",ARHead[i]);
  445.       }
  446.  
  447.     /* Scan the rest of the data in this article                           */
  448.     ARHead[8] = 0x00;              /* Mark the end of the string           */
  449.     data = SOH;                    /* Assume we don't print data           */
  450.     j = 0;                         /* Number of bytes output so far        */
  451.     if (argc > 1)                  /* Are there any arguments?             */
  452.       if (!strcmp(argv[1],"ALL"))  /* Do they want everything printed?     */
  453.         data = 0x00;               /* YES - We will display the whole thing*/
  454.       else                         /* Otherwise display only matches       */
  455.         if (!strcmp(argv[1],ARHead))
  456.           data = 0x00;
  457.     if ((data != SOH) && doprt)    /* Do we need to finish the header?     */
  458.       printf("\n");                /* YES - Do it                          */
  459.     while (data != SOH)
  460.       {                            /* Loop through until eof or 1st SOH    */
  461.       data = getc(fd);             /* Get the next data byte               */
  462.       if (data == EOF)             /* Are we at the end of the line?       */
  463.         {                          /* YES - Easy to handle that then       */
  464.         printf("***EOF***\n");
  465.         exit(0);
  466.         }
  467.       if (data == SOH)             /* Have we picked up the SOH?           */
  468.         {                          /* Try to return it to the stream       */
  469.         if (EOF == ungetc(SOH,fd)) /* Try to put the SOH back              */
  470.           {                        /* It didn't work                       */
  471.           fprintf(stderr,"resync:Unable to place SOH back in stream\n");
  472.           exit(8);
  473.           }
  474.         }
  475.       else
  476.         {                          /* Ok, a good byte.  Display it         */
  477.         i = j % 16;                /* Where are we in the line?            */
  478.         outarray[i] = data;        /* Get the data byte in outarray        */
  479.         switch (i)                 /* There are enough formatting states   */
  480.           {
  481.           case 15:                 /* The last byte on a line?             */
  482.             printf(" %2.2X |",data);
  483.             for (i=0;i<16;i++)
  484.               printf("%c",(isprint(outarray[i])) ? outarray[i] : '.');
  485.             printf("|\n");
  486.             break;
  487.           case 0:                  /* The first byte on the line?          */
  488.             printf("       %4.4X: %2.2X",j,data);
  489.             break;
  490.           case 8:                  /* Is it the middle byte?               */
  491.             printf(":%2.2X",data);
  492.             break;
  493.           default:
  494.             printf(" %2.2X",data);
  495.             break;
  496.           }
  497.         j++;                       /* Count another character read         */
  498.         }                          /* else                                 */
  499.       }                            /* while                                */
  500.       if (doprt) printf("\n");
  501.       resync(fd);
  502.   }                                /* while                                */
  503. }
  504.  
  505.