1 /* GNU Mailutils -- a suite of utilities for electronic mail 2 Copyright (C) 1999-2021 Free Software Foundation, Inc. 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 3 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General 15 Public License along with this library. If not, see 16 <http://www.gnu.org/licenses/>. */ 17 18 #ifndef _MAILUTILS_SYS_PROPERTY_H 19 # define _MAILUTILS_SYS_PROPERTY_H 20 21 # include <errno.h> 22 # include <stdlib.h> 23 # include <string.h> 24 25 # include <mailutils/property.h> 26 # include <mailutils/monitor.h> 27 # include <mailutils/assoc.h> 28 29 # ifdef __cplusplus 30 extern "C" { 31 # endif 32 33 #define MU_PROP_INIT 0x01 34 #define MU_PROP_FILL 0x02 35 #define MU_PROP_MODIFIED 0x04 36 37 struct _mu_property 38 { 39 size_t _prop_ref_count; /* Reference counter */ 40 int _prop_flags; /* Flags describing the state of this object */ 41 void *_prop_data; /* Implementation-specific data */ 42 void *_prop_init_data; /* Initialization data */ 43 44 /* Methods */ 45 46 /* Delayed initialization. This function must allocate _prop_data, 47 if needed, and initialize the rest of _prop_* methods. */ 48 int (*_prop_init) (struct _mu_property *); 49 /* Free memory allocated in _prop_data */ 50 void (*_prop_done) (struct _mu_property *); 51 /* Fill in the properties from an external storage */ 52 int (*_prop_fill) (struct _mu_property *); 53 /* Write the properties to an external storage */ 54 int (*_prop_save) (struct _mu_property *); 55 /* Get the value of the property named in the 2nd argument. If 3rd 56 arg is NULL, _prop_getval tests whether the given property is set. */ 57 int (*_prop_getval) (struct _mu_property *, const char *, const char **); 58 /* Set the property */ 59 int (*_prop_setval) (struct _mu_property *, const char *, const char *, int); 60 /* Unset (delete) the property */ 61 int (*_prop_unset) (struct _mu_property *, const char *); 62 /* Return iterator for this property object */ 63 int (*_prop_getitr) (struct _mu_property *, mu_iterator_t *); 64 /* Clear all properties. */ 65 int (*_prop_clear) (struct _mu_property *); 66 }; 67 68 int _mu_property_init (mu_property_t prop); 69 int _mu_property_check (mu_property_t prop); 70 71 # ifdef __cplusplus 72 } 73 # endif 74 75 #endif /* _MAILUTILS_SYS_PROPERTY_H */ 76