a9df466bc5fa7fc9b25bb5710c25fe939d50d19b
[tpg/acess2.git] / KernelLand / Modules / Interfaces / UDI / udi_lib / core / buf.c
1 /**
2  * \file buf.c
3  * \author John Hodge (thePowersGang)
4  * 
5  * Buffer Manipulation
6  */
7 #include <acess.h>
8 #include <udi.h>
9 #include <udi_internal.h>
10
11 typedef struct sUDI_BufTag
12 {
13         struct sUDI_BufTag      *Next;
14 //      udi_buf_tag_t   tag;
15         struct sUDI_BufSect     *Sect;
16 } tUDI_BufTag;
17
18 typedef struct sUDI_BufSect
19 {
20         struct sUDI_BufSect     *Next;
21         size_t  Offset;
22         size_t  Length;
23         size_t  Space;
24         // data
25 } tUDI_BufSect;
26
27 typedef struct
28 {
29         udi_buf_t       buf;
30         tUDI_BufTag     *Tags;
31         tUDI_BufSect    *Sections;
32 } tUDI_BufInt;
33
34 // === EXPORTS ===
35 EXPORT(udi_buf_copy);
36 EXPORT(udi_buf_write);
37 EXPORT(udi_buf_read);
38 EXPORT(udi_buf_free);
39
40 // === CODE ===
41 void udi_buf_copy(
42         udi_buf_copy_call_t *callback,
43         udi_cb_t        *gcb,
44         udi_buf_t       *src_buf,
45         udi_size_t      src_off,
46         udi_size_t      src_len,
47         udi_buf_t       *dst_buf,
48         udi_size_t      dst_off,
49         udi_size_t      dst_len,
50         udi_buf_path_t path_handle
51         )
52 {
53         UNIMPLEMENTED();
54 }
55
56 /**
57  * \brief Write to a buffer
58  * \param callback      Function to call once the write has completed
59  * \param gcb   Control Block
60  * \param src_mem       Source Data
61  * \param src_len       Length of source data
62  * \param dst_buf       Destination buffer
63  * \param dst_off       Destination offset in the buffer
64  * \param dst_len       Length of destination area
65  * \param path_handle   ???
66  */
67 void udi_buf_write(
68         udi_buf_write_call_t *callback,
69         udi_cb_t        *gcb,
70         const void      *src_mem,
71         udi_size_t      src_len,
72         udi_buf_t       *dst_buf,
73         udi_size_t      dst_off,
74         udi_size_t      dst_len,
75         udi_buf_path_t path_handle
76         )
77 {
78         tUDI_BufInt     *dst = (void*)dst_buf;
79         if( !dst ) {
80                 dst = NEW(tUDI_BufInt,);
81         }
82         
83         if( dst_len == 0 )
84         {
85                 // Insert / Initialise
86                 if( src_len > 0 )
87                 {
88                         Log_Warning("UDI", "TODO: udi_buf_write - insert");
89                 }
90                 // no-op
91                 else
92                 {
93                 }
94         }
95         else
96         {
97                 // Overwrite
98                 if( src_len > 0 )
99                 {
100                         Log_Warning("UDI", "TODO: udi_buf_write - overwrite");
101                 }
102                 // Delete
103                 else
104                 {
105                         Log_Warning("UDI", "TODO: udi_buf_write - delete");
106                 }
107         }
108         
109         callback(gcb, &dst->buf);
110 }
111
112 void udi_buf_read(
113         udi_buf_t       *src_buf,
114         udi_size_t      src_off,
115         udi_size_t      src_len,
116         void    *dst_mem )
117 {
118         UNIMPLEMENTED();
119 }
120
121 void udi_buf_free(udi_buf_t *buf)
122 {
123         UNIMPLEMENTED();
124 }

UCC git Repository :: git.ucc.asn.au