Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 93 lines (82 sloc) 3.301 kb
ca5f82c @mrash Removed legacy $Id$ tags from svn
authored
1 /*
b446bdc Broke these out from fko.h.
Damien Stuart authored
2 *****************************************************************************
3 *
4 * File: fko_state.h
5 *
6 * Author: Damien S. Stuart
7 *
8 * Purpose: Defines various states and flags for libfko operations.
9 *
0f6ca00 Updated the GPL blurb at the top of the source files. Added some missin...
Damien Stuart authored
10 * Copyright 2009-2010 Damien Stuart (dstuart@dstuart.org)
b446bdc Broke these out from fko.h.
Damien Stuart authored
11 *
12 * License (GNU Public License):
13 *
0f6ca00 Updated the GPL blurb at the top of the source files. Added some missin...
Damien Stuart authored
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
b446bdc Broke these out from fko.h.
Damien Stuart authored
18 *
0f6ca00 Updated the GPL blurb at the top of the source files. Added some missin...
Damien Stuart authored
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 * USA
b446bdc Broke these out from fko.h.
Damien Stuart authored
28 *
29 *****************************************************************************
30 */
31 #ifndef FKO_STATE_H
32 #define FKO_STATE_H 1
33
34 /* General state flag bit values.
35 */
36 typedef enum {
37 FKO_CTX_SET = 1, /* Set when ctx is initialized */
e846cdd First cut at GPG encrytion support (decryption and doc update are pendin...
Damien Stuart authored
38 FKO_DATA_MODIFIED = 1 << 1,
39 FKO_STATE_RESERVED_2 = 1 << 2,
40 STATE_RESERVED_3 = 1 << 3,
41 STATE_RESERVED_4 = 1 << 4,
42 STATE_RESERVED_5 = 1 << 5,
b446bdc Broke these out from fko.h.
Damien Stuart authored
43 FKO_SPA_MSG_TYPE_MODIFIED = 1 << 6,
44 FKO_CTX_SET_2 = 1 << 7, /* Set when ctx is initialized */
e846cdd First cut at GPG encrytion support (decryption and doc update are pendin...
Damien Stuart authored
45 STATE_RESERVED_8 = 1 << 8,
46 STATE_RESERVED_9 = 1 << 9,
47 STATE_RESERVED_10 = 1 << 10,
48 STATE_RESERVED_11 = 1 << 11,
b446bdc Broke these out from fko.h.
Damien Stuart authored
49 FKO_DIGEST_TYPE_MODIFIED = 1 << 12,
50 FKO_ENCRYPT_TYPE_MODIFIED = 1 << 13,
e846cdd First cut at GPG encrytion support (decryption and doc update are pendin...
Damien Stuart authored
51 STATE_RESERVED_14 = 1 << 14,
b446bdc Broke these out from fko.h.
Damien Stuart authored
52 FKO_BACKWARD_COMPATIBLE = 1 << 15
53 } fko_state_flags_t;
54
55 /* This is used in conjunction with the ctx->initial value as a means to
56 * determine if the ctx has been properly initialized. However, this
57 * may not work 100% of the time as it is possible (though not likely)
58 * an ctx may have values that match both the flags and the ctx->initial
59 * value.
60 */
61 #define FKO_CTX_INITIALIZED (FKO_CTX_SET|FKO_CTX_SET_2)
62
63 #define FKO_SET_CTX_INITIALIZED(ctx) \
64 (ctx->state |= (FKO_CTX_INITIALIZED))
65
66 #define FKO_CLEAR_CTX_INITIALIZED(ctx) \
67 (ctx->state &= (0xffff & ~FKO_CTX_INITIALIZED))
68
69 /* Consolidate all SPA data modified flags.
70 */
e846cdd First cut at GPG encrytion support (decryption and doc update are pendin...
Damien Stuart authored
71 #define FKO_SPA_DATA_MODIFIED ( \
72 FKO_DATA_MODIFIED | FKO_SPA_MSG_TYPE_MODIFIED \
73 | FKO_DIGEST_TYPE_MODIFIED | FKO_ENCRYPT_TYPE_MODIFIED )
b446bdc Broke these out from fko.h.
Damien Stuart authored
74
75 /* This should return true if any SPA data field has been modifed since the
76 * last encode/encrypt.
77 */
e846cdd First cut at GPG encrytion support (decryption and doc update are pendin...
Damien Stuart authored
78 #define FKO_IS_SPA_DATA_MODIFIED(ctx) (ctx->state & FKO_SPA_DATA_MODIFIED)
b446bdc Broke these out from fko.h.
Damien Stuart authored
79
80 /* Clear all SPA data modified flags. This is normally called after a
81 * succesful encode/digest/encryption cycle.
82 */
83 #define FKO_CLEAR_SPA_DATA_MODIFIED(ctx) \
e846cdd First cut at GPG encrytion support (decryption and doc update are pendin...
Damien Stuart authored
84 (ctx->state &= (0xffff & ~FKO_SPA_DATA_MODIFIED))
b446bdc Broke these out from fko.h.
Damien Stuart authored
85
86 /* Macros used for determining ctx initialization state.
87 */
9282a0f Changed to fix possible double-free bug under some circumstances.
Damien Stuart authored
88 #define CTX_INITIALIZED(ctx) (ctx != NULL && ctx->initval == FKO_CTX_INITIALIZED)
b446bdc Broke these out from fko.h.
Damien Stuart authored
89
90 #endif /* FKO_STATE_H */
91
92 /***EOF***/
Something went wrong with that request. Please try again.