Changeset 2005 for Whitix/trunk

Show
Ignore:
Timestamp:
04/02/09 21:11:33 (3 years ago)
Author:
mwhitworth
Message:

Add support for function entries in IcAttributes, add IC_FUNC define.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Whitix/trunk/include/fs/icfs.h

    r1932 r2005  
    2828#define ICFS_TYPE_FUNC  3 
    2929 
     30typedef int (*IcReadFunc)(BYTE* data, unsigned long size, DWORD position); 
     31typedef int (*IcWriteFunc)(BYTE* data, unsigned long size, DWORD position); 
     32 
     33struct IcFuncEntry 
     34{ 
     35        IcReadFunc readFunc; 
     36        IcWriteFunc writeFunc; 
     37}; 
     38 
    3039#define IC_READ         0 
    3140#define IC_RW           1 
     
    3544struct IcAttribute 
    3645{ 
    37         int type, offset, perms; 
     46        int type; 
     47 
     48        IcReadFunc readFunc; 
     49        IcWriteFunc writeFunc; 
     50                 
     51        int offset; 
     52        int perms; 
     53         
    3854        const char* name; 
    3955}; 
    40  
    41 typedef int (*IcReadFunc)(BYTE* data, unsigned long size, DWORD position); 
    42 typedef int (*IcWriteFunc)(BYTE* data, unsigned long size, DWORD position); 
    4356 
    4457#define IC_INT(structure, member, permissions) \ 
     
    4962          .perms = permissions \ 
    5063        } 
    51  
     64         
     65#define IC_INT_NAME(objName, structure, member, permissions) \ 
     66        { \ 
     67          .type = ICFS_TYPE_INT, \ 
     68          .offset = OffsetOf(structure, member), \ 
     69          .name = objName, \ 
     70          .perms = permissions \ 
     71        } 
     72         
    5273#define IC_STRING(structure, member, permissions) \ 
    5374        { \ 
     
    6182        { \ 
    6283                .type = ICFS_TYPE_STR, \ 
    63                 .offset = OffsetOf(structure, member), \ 
     84                .offset = OffsetOf(structure, member) \ 
    6485                .name = objName, \ 
    6586                .perms = permissions, \ 
    6687        } 
    6788         
     89#define IC_FUNC(objName, funcRead, funcWrite) \ 
     90        { \ 
     91                .type = ICFS_TYPE_FUNC, \ 
     92                .readFunc = funcRead, \ 
     93                .writeFunc = funcWrite, \ 
     94                .name = objName, \ 
     95        } 
     96         
    6897#define IC_END() \ 
    69         { -1, -1, -1, NULL } 
     98        { -1, NULL, NULL, -1, -1, NULL } 
    7099 
    71100struct IcFsEntry 
     
    75104        { 
    76105                int* iVal; 
    77                 char* sVal; 
     106                char** sVal; 
    78107                 
     108                /* Array entries. */ 
    79109                struct 
    80110                { 
     
    83113                }; 
    84114                 
    85                 struct 
    86                 { 
    87                         IcReadFunc readFunc; 
    88                         IcWriteFunc writeFunc; 
    89                 }; 
     115                /* Function entries. */ 
     116                struct IcFuncEntry entry; 
    90117        }; 
    91118}; 
     
    96123int IcFsAddIntEntry(struct KeFsEntry* dir, char* name, int* value, DWORD permissions); 
    97124 
    98 struct IcFsEntry* IcFsAddStrEntry(struct KeFsEntry* dir, char* name, char* str, DWORD permissions); 
     125struct IcFsEntry* IcFsAddStrEntry(struct KeFsEntry* dir, char* name, char** str, DWORD permissions); 
    99126 
    100127int IcFsAddArrayEntry(struct KeFsEntry* dir, char* name, char* array, unsigned int minLen, unsigned int maxLen, unsigned int size);