home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / libmime / mimepbuf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.6 KB  |  91 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. /* mimepbuf.h --- utilities for buffering a MIME part for later display.
  20.    Created: Jamie Zawinski <jwz@netscape.com>, 24-Sep-96.
  21.  */
  22.  
  23. #ifndef _MIMEPBUF_H_
  24. #define _MIMEPBUF_H_
  25.  
  26. #include "mimei.h"
  27.  
  28. /* This file provides the ability to save up the entire contents of a MIME
  29.    object (of arbitrary size), and then emit it all at once later.  The
  30.    buffering is done in an efficient way that works well for both very large
  31.    and very small objects.
  32.  
  33.    This is used in two places:
  34.  
  35.    = The implementation of multipart/alternative uses this code to do a
  36.      one-part-lookahead.  As it traverses its children, it moves forward
  37.      until it finds a part which cannot be displayed; and then it displays
  38.      the *previous* part (the last which *could* be displayed.)  This code
  39.      is used to hold the previous part until it is needed.
  40.  
  41.    = The S/MIME code (both MimeEncryptedPKCS7 and MimeMultipartSignedPKCS7)
  42.      use this code to delay presenting an object to the user until its
  43.      signature has been verified.  The signature cannot be completely verified
  44.      by the underlying crypto code until the entire object has been read;
  45.      however, it would be wrong to present a signed object to the user without
  46.      first knowing whether the signature is correct (in other words, we want
  47.      to present the "signature matches" or "signature does not match" blurb to
  48.      the user *before* we show them the object which has been signed, rather
  49.      than *after*.)
  50.  */
  51.  
  52. /* An opaque object used to represent the buffered data.
  53.  */
  54. typedef struct MimePartBufferData MimePartBufferData;
  55.  
  56. /* Create an empty part buffer object.
  57.  */
  58. extern MimePartBufferData *MimePartBufferCreate (void);
  59.  
  60. /* Assert that the buffer is now full (EOF has been reached on the current
  61.    part.)  This will free some resources, but leaves the part in the buffer.
  62.    After calling MimePartBufferReset, the buffer may be used to store a
  63.    different object.
  64.  */
  65. void MimePartBufferClose (MimePartBufferData *data);
  66.  
  67. /* Reset a part buffer object to the default state, discarding any currently-
  68.    buffered data.
  69.  */
  70. extern void MimePartBufferReset (MimePartBufferData *data);
  71.  
  72. /* Free the part buffer itself, and discard any buffered data.
  73.  */
  74. extern void MimePartBufferDestroy (MimePartBufferData *data);
  75.  
  76. /* Push a chunk of a MIME object into the buffer.
  77.  */
  78. extern int MimePartBufferWrite (MimePartBufferData *data,
  79.                                 const char *buf, int32 size);
  80.  
  81. /* Read the contents of the buffer back out.  This will invoke the provided
  82.    read_fn with successive chunks of data until the buffer has been drained.
  83.    The provided function may be called once, or multiple times.
  84.  */
  85. extern int
  86. MimePartBufferRead (MimePartBufferData *data,
  87.                     int (*read_fn) (char *buf, int32 size, void *closure),
  88.                     void *closure);
  89.  
  90. #endif /* _MIMEPBUF_H_ */
  91.