home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / libmime / mimetext.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.2 KB  |  83 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /* mimetext.h --- definition of the MimeInlineText class (see mimei.h)
  20.    Created: Jamie Zawinski <jwz@netscape.com>, 15-May-96.
  21.  */
  22.  
  23. #ifndef _MIMETEXT_H_
  24. #define _MIMETEXT_H_
  25.  
  26. #include "mimeleaf.h"
  27.  
  28. /* The MimeInlineText class is the superclass of all handlers for the
  29.    MIME text/ content types (which convert various text formats to HTML,
  30.    in one form or another.)
  31.  
  32.    It provides two services:
  33.  
  34.      =  if ROT13 decoding is desired, the text will be rotated before
  35.         the `parse_line' method it called;
  36.  
  37.      =  text will be converted from the message's charset to the "target"
  38.         charset before the `parse_line' method is called.
  39.  
  40.    The contract with charset-conversion is that the converted data will
  41.    be such that one may interpret any octets (8-bit bytes) in the data
  42.    which are in the range of the ASCII characters (0-127) as ASCII
  43.    characters.  It is explicitly legal, for example, to scan through
  44.    the string for "<" and replace it with "<", and to search for things
  45.    that look like URLs and to wrap them with interesting HTML tags.
  46.  
  47.    The charset to which we convert will probably be UTF-8 (an encoding of
  48.    the Unicode character set, with the feature that all octets with the
  49.    high bit off have the same interpretations as ASCII.)
  50.  
  51.    #### NOTE: if it turns out that we use JIS (ISO-2022-JP) as the target
  52.         encoding, then this is not quite true; it is safe to search for the
  53.         low ASCII values (under hex 0x40, octal 0100, which is '@') but it
  54.         is NOT safe to search for values higher than that -- they may be
  55.         being used as the subsequent bytes in a multi-byte escape sequence.
  56.         It's a nice coincidence that HTML's critical characters ("<", ">",
  57.         and "&") have values under 0x40...
  58.  */
  59.  
  60. typedef struct MimeInlineTextClass MimeInlineTextClass;
  61. typedef struct MimeInlineText      MimeInlineText;
  62.  
  63. struct MimeInlineTextClass {
  64.   MimeLeafClass   leaf;
  65.   int (*rot13_line) (MimeObject *obj, char *line, int32 length);
  66.   int (*convert_line_charset) (MimeObject *obj, char *line, int32 length);
  67. };
  68.  
  69. extern MimeInlineTextClass mimeInlineTextClass;
  70.  
  71. struct MimeInlineText {
  72.   MimeLeaf leaf;            /* superclass variables */
  73.   char *charset;            /* The charset from the content-type of this
  74.                                object, or the caller-specified overrides
  75.                                or defaults.
  76.                              */
  77.   char *cbuffer;            /* Buffer used for charset conversion. */
  78.   int32 cbuffer_size;
  79.  
  80. };
  81.  
  82. #endif /* _MIMETEXT_H_ */
  83.