1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2000-2012 Jeffrey Stedfast
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 2.1
8 * of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
22 #ifndef __GMIME_FILTER_YENC_H__
23 #define __GMIME_FILTER_YENC_H__
25 #include <gmime/gmime-filter.h>
29 #define GMIME_TYPE_FILTER_YENC (g_mime_filter_yenc_get_type ())
30 #define GMIME_FILTER_YENC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMIME_TYPE_FILTER_YENC, GMimeFilterYenc))
31 #define GMIME_FILTER_YENC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMIME_TYPE_FILTER_YENC, GMimeFilterYencClass))
32 #define GMIME_IS_FILTER_YENC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMIME_TYPE_FILTER_YENC))
33 #define GMIME_IS_FILTER_YENC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GMIME_TYPE_FILTER_YENC))
34 #define GMIME_FILTER_YENC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMIME_TYPE_FILTER_YENC, GMimeFilterYencClass))
36 typedef struct _GMimeFilterYenc GMimeFilterYenc;
37 typedef struct _GMimeFilterYencClass GMimeFilterYencClass;
41 * GMIME_YDECODE_STATE_INIT:
43 * Initial state for the g_mime_ydecode_step() function.
45 #define GMIME_YDECODE_STATE_INIT (0)
48 * GMIME_YENCODE_STATE_INIT:
50 * Initial state for the g_mime_ydecode_step() function.
52 #define GMIME_YENCODE_STATE_INIT (0)
54 /* first 8 bits are reserved for saving a byte */
57 * GMIME_YDECODE_STATE_EOLN:
59 * State bit that denotes the yEnc filter has reached an end-of-line.
61 * This state is for internal use only.
63 #define GMIME_YDECODE_STATE_EOLN (1 << 8)
66 * GMIME_YDECODE_STATE_ESCAPE:
68 * State bit that denotes the yEnc filter has reached an escape
71 * This state is for internal use only.
73 #define GMIME_YDECODE_STATE_ESCAPE (1 << 9)
75 /* bits 10 and 11 reserved for later uses? */
78 * GMIME_YDECODE_STATE_BEGIN:
80 * State bit that denotes the yEnc filter has found the =ybegin line.
82 #define GMIME_YDECODE_STATE_BEGIN (1 << 12)
85 * GMIME_YDECODE_STATE_PART:
87 * State bit that denotes the yEnc filter has found the =ypart
88 * line. (Note: not all yencoded blocks have one)
90 #define GMIME_YDECODE_STATE_PART (1 << 13)
93 * GMIME_YDECODE_STATE_DECODE:
95 * State bit that denotes yEnc filter has begun decoding the actual
96 * yencoded content and will continue to do so until an =yend line is
97 * found (or until there is nothing left to decode).
99 #define GMIME_YDECODE_STATE_DECODE (1 << 14)
102 * GMIME_YDECODE_STATE_END:
104 * State bit that denoates that g_mime_ydecode_step() has finished
107 #define GMIME_YDECODE_STATE_END (1 << 15)
110 * GMIME_YENCODE_CRC_INIT:
112 * Initial state for the crc and pcrc state variables.
114 #define GMIME_YENCODE_CRC_INIT (~0)
117 * GMIME_YENCODE_CRC_FINAL:
118 * @crc: crc or pcrc state variable
120 * Gets the final crc value from @crc.
122 #define GMIME_YENCODE_CRC_FINAL(crc) (~crc)
126 * @parent_object: parent #GMimeFilter
127 * @encode: encode vs decode
129 * @state: encode/decode state
133 * A filter for yEncoding or yDecoding a stream.
135 struct _GMimeFilterYenc {
136 GMimeFilter parent_object;
147 struct _GMimeFilterYencClass {
148 GMimeFilterClass parent_class;
153 GType g_mime_filter_yenc_get_type (void);
155 GMimeFilter *g_mime_filter_yenc_new (gboolean encode);
157 void g_mime_filter_yenc_set_state (GMimeFilterYenc *yenc, int state);
158 void g_mime_filter_yenc_set_crc (GMimeFilterYenc *yenc, guint32 crc);
160 /*int g_mime_filter_yenc_get_part (GMimeFilterYenc *yenc);*/
161 guint32 g_mime_filter_yenc_get_pcrc (GMimeFilterYenc *yenc);
162 guint32 g_mime_filter_yenc_get_crc (GMimeFilterYenc *yenc);
165 size_t g_mime_ydecode_step (const unsigned char *inbuf, size_t inlen, unsigned char *outbuf,
166 int *state, guint32 *pcrc, guint32 *crc);
167 size_t g_mime_yencode_step (const unsigned char *inbuf, size_t inlen, unsigned char *outbuf,
168 int *state, guint32 *pcrc, guint32 *crc);
169 size_t g_mime_yencode_close (const unsigned char *inbuf, size_t inlen, unsigned char *outbuf,
170 int *state, guint32 *pcrc, guint32 *crc);
174 #endif /* __GMIME_FILTER_YENC_H__ */