]> mj.ucw.cz Git - libucw.git/commitdiff
- added prototypes of memory allocation and journal functions
authorRobert Spalek <robert@ucw.cz>
Wed, 19 Apr 2006 10:00:02 +0000 (12:00 +0200)
committerRobert Spalek <robert@ucw.cz>
Wed, 19 Apr 2006 10:00:02 +0000 (12:00 +0200)
- rearranged some declarations
- added proper copyright

lib/conf2.h

index 20daf32a7f839148c9930e8c1deace2d82956dd9..ae1d1705170257c56da85eee2422d599d81b8e02 100644 (file)
@@ -1,7 +1,8 @@
 /*
  *     UCW Library -- Reading of configuration files
  *
- *     (c) 2006 Robert Spalek <robert@ucw.cz>
+ *     (c) 2001--2006 Robert Spalek <robert@ucw.cz>
+ *     (c) 2003--2006 Martin Mares <mj@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU Lesser General Public License.
@@ -19,7 +20,6 @@ enum cf_type {
   CT_LIST                              // list with 0..many nodes
 };
 
-struct cf_section;
 typedef byte *cf_hook(void *ptr);
   /* An init- or commit-hook gets a pointer to the section or NULL if this
    * is the global section.  It returns an error message or NULL if everything
@@ -29,6 +29,7 @@ typedef byte *cf_parser(uns number, byte **pars, void *ptr);
    * way it likes into *ptr.  It returns an error message or NULL if everything
    * is all right.  */
 
+struct cf_section;
 struct cf_item {
   enum cf_type type;
   byte *name;
@@ -47,12 +48,7 @@ struct cf_section {
   struct cf_item *cfg;                 // CT_END-terminated array of items
 };
 
-#define ARRAY_ALLOC(type,len,val...) (type[]) { (type)len, ##val } + 1
-  // creates an array with an allocated space in the front for the (Pascal-like) length
-#define ARRAY_LEN(a) *(uns*)(a-1)
-  // length of the array
-
-/* Declaration of cf_items */
+/* Declaration of cf_section */
 #define CF_TYPE(s)     .size = sizeof(s),
 #define CF_INIT(f)     .init = (cf_hook*) f,
 #define CF_COMMIT(f)   .commit = (cf_hook*) f,
@@ -67,10 +63,26 @@ struct cf_section {
 #define CF_U64_ARY(n,p,c)      { .type = CT_U64, .name = n, .number = c, .ptr = CHECK_PTR_TYPE(p,u64**) },
 #define CF_DOUBLE_ARY(n,p,c)   { .type = CT_DOUBLE, .name = n, .number = c, .ptr = CHECK_PTR_TYPE(p,double**) },
 #define CF_STRING_ARY(n,p,c)   { .type = CT_STRING, .name = n, .number = c, .ptr = CHECK_PTR_TYPE(p,byte***) },
+
+#define ARRAY_ALLOC(type,len,val...) (type[]) { (type)len, ##val } + 1
+  // creates an array with an allocated space in the front for the (Pascal-like) length
+#define ARRAY_LEN(a) *(uns*)(a-1)
+  // length of the array
+
 /* Configuration items for sections, lists, and parsed items */
 struct clist;
 #define CF_PARSER(n,p,f,c)     { .type = CT_PARSER, .name = n, .number = c, .ptr = p, .ptr2.par = (cf_parser*) f },
 #define CF_SECTION(n,p,s)      { .type = CT_SECTION, .name = n, .number = 1, .ptr = p, .ptr2.sub = s },
 #define CF_LIST(n,p,s)         { .type = CT_LIST, .name = n, .number = 1, .ptr = CHECK_PTR_TYPE(p,struct clist*), .ptr2.sub = s },
 
+/* Memory allocation */
+void *cf_malloc(uns size);
+void *cf_malloc_zero(uns size);
+byte *cf_strdup(byte *s);
+byte *cf_printf(char *fmt, ...);
+
+/* Undo journal for error recovery */
+uns cf_journal_active(uns flag);
+void cf_journal_block(void *ptr, uns len);
+
 #endif