1 /*
2  * Copyright (c) 2007 Vreixo Formoso
3  * Copyright (c) 2014 Thomas Schmitt
4  *
5  * This file is part of the libisofs project; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License version 2
7  * or later as published by the Free Software Foundation.
8  * See COPYING file for details.
9  */
10 
11 #ifndef LIBISO_BUILDER_H_
12 #define LIBISO_BUILDER_H_
13 
14 /*
15  * Definitions for IsoNode builders.
16  */
17 
18 /*
19  * Some functions here will be moved to libisofs.h when we expose
20  * Builder.
21  */
22 
23 #include "libisofs.h"
24 #include "fsource.h"
25 
26 typedef struct Iso_Node_Builder IsoNodeBuilder;
27 
28 struct Iso_Node_Builder
29 {
30 
31     /**
32      * Create a new IsoFile from an IsoFileSource. Name, permissions
33      * and other attributes are taken from src, but a regular file will
34      * always be created, even if src is another kind of file.
35      *
36      * In that case, if the implementation can't do the conversion, it
37      * should fail properly.
38      *
39      * Note that the src is never unref, so you need to free it.
40      *
41      * @return
42      *    1 on success, < 0 on error
43      */
44     int (*create_file)(IsoNodeBuilder *builder, IsoImage *image,
45                        IsoFileSource *src, IsoFile **file);
46 
47     /**
48      * Create a new IsoNode from a IsoFileSource. The type of the node to be
49      * created is determined from the type of the file source. Name,
50      * permissions and other attributes are taken from source file.
51      * But name may be overridden by parameter name if it is not NULL.
52      *
53      * Note that the src is never unref, so you need to free it.
54      *
55      * @return
56      *    1 on success, < 0 on error
57      */
58     int (*create_node)(IsoNodeBuilder *builder, IsoImage *image,
59                        IsoFileSource *src, char *name, IsoNode **node);
60 
61     /**
62      * Free implementation specific data. Should never be called by user.
63      * Use iso_node_builder_unref() instead.
64      */
65     void (*free)(IsoNodeBuilder *builder);
66 
67     int refcount;
68     void *create_file_data;
69     void *create_node_data;
70 };
71 
72 void iso_node_builder_ref(IsoNodeBuilder *builder);
73 void iso_node_builder_unref(IsoNodeBuilder *builder);
74 
75 /**
76  * Create a new basic builder ...
77  *
78  * @return
79  *     1 success, < 0 error
80  */
81 int iso_node_basic_builder_new(IsoNodeBuilder **builder);
82 
83 #endif /*LIBISO_BUILDER_H_*/
84