home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / metamail / richmail / usascii.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-21  |  2.6 KB  |  129 lines

  1. /*-------------------------------------------------------------------------
  2.  
  3.   usascii.c - Code for the US-ASCII specific parts of the richtext processor.
  4.  
  5.   Copyright (c) 1992 Rhys Weatherley
  6.  
  7.   Permission to use, copy, modify, and distribute this material
  8.   for any purpose and without fee is hereby granted, provided
  9.   that the above copyright notice and this permission notice
  10.   appear in all copies, and that the name of Rhys Weatherley not be
  11.   used in advertising or publicity pertaining to this
  12.   material without specific, prior written permission.
  13.   RHYS WEATHERLEY MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR
  14.   SUITABILITY OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED
  15.   "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  16.  
  17.   Revision History:
  18.   ================
  19.  
  20.    Version  DD/MM/YY  By  Description
  21.    -------  --------  --  --------------------------------------
  22.      1.0    21/06/92  RW  Original Version of usascii.c
  23.  
  24.   You may contact the author by:
  25.   =============================
  26.  
  27.    e-mail: rhys@cs.uq.oz.au
  28.      mail: Rhys Weatherley
  29.        5 Horizon Drive
  30.        Jamboree Heights
  31.        Queensland 4074
  32.        Australia
  33.  
  34. -------------------------------------------------------------------------*/
  35.  
  36. #include <stdio.h>
  37. #include <ctype.h>
  38. #include "richlex.h"
  39. #include "richset.h"
  40.  
  41. /*
  42.  * Initialise the US-ASCII character set processor.
  43.  */
  44. usascii_init (name)
  45. char    *name;
  46. {
  47.     if (name)
  48.     richtextencoding (RICH_ENC_US_ASCII);
  49. }
  50.  
  51. /*
  52.  * Process a command for the US-ASCII processor.
  53.  */
  54. int    usascii_command (token,negated)
  55. char    *token;
  56. int    negated;
  57. {
  58.     if (!strcmp(token,"us-ascii")) {
  59.         if (negated) {
  60.         charsetpop (&usascii_charset);
  61.     } else {
  62.         charsetpush (&usascii_charset);
  63.         richtextencoding (RICH_ENC_US_ASCII);
  64.     }
  65.     return (1);
  66.     } else {
  67.         return (0);
  68.     }
  69. }
  70.  
  71. /*
  72.  * Check for singleton US-ASCII tokens.
  73.  */
  74. int    usascii_single (token)
  75. char    *token;
  76. {
  77.     return (0);
  78. }
  79.  
  80. /*
  81.  * Determine the width of a US-ASCII character.
  82.  */
  83. int    usascii_width (ch)
  84. RCHAR    ch;
  85. {
  86.     return (1);
  87. }
  88.  
  89. /*
  90.  * Determine if the current character can be used as a folding point.
  91.  */
  92. int    usascii_fold (ch)
  93. RCHAR    ch;
  94. {
  95.     return (ch < 0x7F && isspace (ch));
  96. }
  97.  
  98. /*
  99.  * Render the given US-ASCII character.
  100.  */
  101. usascii_render (ch,param)
  102. RCHAR    ch;
  103. void    *param;
  104. {
  105.     (*RichtextPutc) ((int)ch,param);
  106. }
  107.  
  108. /*
  109.  * Enter or leave the US-ASCII encoding.
  110.  */
  111. usascii_encoding (newenc)
  112. int    newenc;
  113. {
  114.     /* Nothing to be done in this version */
  115. }
  116.  
  117. /*
  118.  * Define the US-ASCII character set processor.
  119.  */
  120. struct     charsetproc    usascii_charset =
  121.       {"us-ascii",
  122.        usascii_init,
  123.        usascii_command,
  124.        usascii_single,
  125.        usascii_width,
  126.        usascii_fold,
  127.        usascii_render,
  128.        usascii_encoding};
  129.