Commit 898646b3 898646b30781ff92f3be33ed9dca9570e20332f4 by Alain Magloire

Put our first attempt at property.

1 parent 073f0ff7
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
20 20
21 #include <sys/types.h> 21 #include <sys/types.h>
22 #include <mailutils/stream.h> 22 #include <mailutils/stream.h>
23 #include <mailutils/property.h>
23 24
24 #ifndef __P 25 #ifndef __P
25 #ifdef __STDC__ 26 #ifdef __STDC__
...@@ -76,11 +77,14 @@ typedef struct _header * header_t; ...@@ -76,11 +77,14 @@ typedef struct _header * header_t;
76 extern int header_create __P ((header_t *, const char *, 77 extern int header_create __P ((header_t *, const char *,
77 size_t, void *)); 78 size_t, void *));
78 extern void header_destroy __P ((header_t *, void *)); 79 extern void header_destroy __P ((header_t *, void *));
79 extern void * header_get_owner __P ((header_t)); 80 extern void *header_get_owner __P ((header_t));
80 81
81 extern int header_is_modified __P ((header_t)); 82 extern int header_is_modified __P ((header_t));
82 extern int header_clear_modified __P ((header_t)); 83 extern int header_clear_modified __P ((header_t));
83 84
85 extern int header_get_property __P ((header_t, property_t *));
86 extern int header_set_property __P ((header_t, property_t, void *));
87
84 extern int header_set_value __P ((header_t, const char *, 88 extern int header_set_value __P ((header_t, const char *,
85 const char *, int)); 89 const char *, int));
86 extern int header_set_set_value __P ((header_t, int (*_set_value) 90 extern int header_set_set_value __P ((header_t, int (*_set_value)
......
...@@ -19,11 +19,13 @@ ...@@ -19,11 +19,13 @@
19 #define _MAILUTILS_MAILER_H 19 #define _MAILUTILS_MAILER_H
20 20
21 #include <sys/types.h> 21 #include <sys/types.h>
22
22 #include <mailutils/stream.h> 23 #include <mailutils/stream.h>
23 #include <mailutils/observer.h> 24 #include <mailutils/observer.h>
24 #include <mailutils/debug.h> 25 #include <mailutils/debug.h>
25 #include <mailutils/url.h> 26 #include <mailutils/url.h>
26 #include <mailutils/message.h> 27 #include <mailutils/message.h>
28 #include <mailutils/property.h>
27 29
28 #ifndef __P 30 #ifndef __P
29 # ifdef __STDC__ 31 # ifdef __STDC__
...@@ -48,6 +50,8 @@ extern int mailer_open __P ((mailer_t, int flags)); ...@@ -48,6 +50,8 @@ extern int mailer_open __P ((mailer_t, int flags));
48 extern int mailer_close __P ((mailer_t)); 50 extern int mailer_close __P ((mailer_t));
49 51
50 extern int mailer_send_message __P ((mailer_t, message_t)); 52 extern int mailer_send_message __P ((mailer_t, message_t));
53
54 extern int mailer_get_property __P ((mailer_t, property_t *));
51 /* stream settings */ 55 /* stream settings */
52 extern int mailer_get_stream __P ((mailer_t, stream_t *)); 56 extern int mailer_get_stream __P ((mailer_t, stream_t *));
53 extern int mailer_set_stream __P ((mailer_t, stream_t)); 57 extern int mailer_set_stream __P ((mailer_t, stream_t));
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
19 #define _MAILUTILS_PROPERTY_H 19 #define _MAILUTILS_PROPERTY_H
20 20
21 #include <sys/types.h> 21 #include <sys/types.h>
22 #include <mailutils/list.h>
22 23
23 #ifndef __P 24 #ifndef __P
24 # ifdef __STDC__ 25 # ifdef __STDC__
...@@ -35,31 +36,26 @@ extern "C" { ...@@ -35,31 +36,26 @@ extern "C" {
35 struct _property; 36 struct _property;
36 typedef struct _property *property_t; 37 typedef struct _property *property_t;
37 38
39 struct property_list
40 {
41 char *key;
42 int value;
43 void *private_; /* Private data. */
44 };
45
38 extern int property_create __P ((property_t *, void *)); 46 extern int property_create __P ((property_t *, void *));
39 extern void property_destroy __P ((property_t *, void *)); 47 extern void property_destroy __P ((property_t *, void *));
40 extern void *property_get_owner __P ((property_t)); 48 extern void *property_get_owner __P ((property_t));
41 49
42 extern int property_set_value __P ((property_t, const char *, const void *)); 50 extern int property_set_value __P ((property_t, const char *, int));
43 extern int property_get_value __P ((property_t, const char *, void **)); 51 extern int property_get_value __P ((property_t, const char *, int *));
44 extern int property_set_set_value __P ((property_t, int (*_set_value) 52 extern int property_add_default __P ((property_t, const char *, int *, void *));
45 __P ((property_t , const char *,
46 const void *)), void *));
47 extern int property_set_get_value __P ((property_t , int (*_get_value)
48 __P ((property_t, const char *,
49 void **)), void *owner));
50 53
51 extern int property_set __P ((property_t, const char *)); 54 extern int property_set __P ((property_t, const char *));
52 extern int property_unset __P ((property_t, const char *)); 55 extern int property_unset __P ((property_t, const char *));
53 extern int property_is_set __P ((property_t, const char *)); 56 extern int property_is_set __P ((property_t, const char *));
54 57
55 extern int property_set_int __P ((property_t, const char *, int)); 58 extern int property_get_list __P ((property_t, list_t *));
56 extern int property_get_int __P ((property_t, const char *));
57
58 extern int property_set_long __P ((property_t, const char *, long));
59 extern long property_get_long __P ((property_t, const char *));
60
61 extern int property_set_pointer __P ((property_t, const char *, void *));
62 extern void *property_get_pointer __P ((property_t, const char *));
63 59
64 #ifdef __cplusplus 60 #ifdef __cplusplus
65 } 61 }
......
...@@ -41,16 +41,9 @@ typedef struct _stream *stream_t; ...@@ -41,16 +41,9 @@ typedef struct _stream *stream_t;
41 #define MU_STREAM_APPEND 0x00000008 41 #define MU_STREAM_APPEND 0x00000008
42 #define MU_STREAM_CREAT 0x00000010 42 #define MU_STREAM_CREAT 0x00000010
43 #define MU_STREAM_NONBLOCK 0x00000020 43 #define MU_STREAM_NONBLOCK 0x00000020
44 /* Stream will be destroy on stream_destroy. */ 44 /* Stream will be destroy on stream_destroy whitout checking the owner. */
45 #define MU_STREAM_NO_CHECK 0x00000040 45 #define MU_STREAM_NO_CHECK 0x00000040
46 46
47 /* Identity of the stream. */
48 #define MU_STREAM_POP 0x00001000
49 #define MU_STREAM_IMAP 0x00002000
50 #define MU_STREAM_FILE 0x00004000
51 #define MU_STREAM_SMTP 0x00008000
52 #define MU_STREAM_SENDMAIL 0x00010000
53
54 extern int stream_create __P ((stream_t *, int flags, void *owner)); 47 extern int stream_create __P ((stream_t *, int flags, void *owner));
55 extern void stream_destroy __P ((stream_t *, void *owner)); 48 extern void stream_destroy __P ((stream_t *, void *owner));
56 extern int stream_set_destroy __P ((stream_t, void (*_destroy) __P ((stream_t)), void *owner)); 49 extern int stream_set_destroy __P ((stream_t, void (*_destroy) __P ((stream_t)), void *owner));
......