Annotation of libaitcfg/inc/aitcfg.h, revision 1.1

1.1     ! misho       1: #ifndef __AITCFG_H
        !             2: #define __AITCFG_H
        !             3: 
        !             4: 
        !             5: struct tagPair {
        !             6:        unsigned int    uLine;
        !             7:        unsigned char   *psSection;
        !             8:        unsigned char   *psAttribute;
        !             9:        unsigned char   *psValue;
        !            10:        struct tagPair *sle_next;
        !            11: };
        !            12: 
        !            13: struct tagHead {
        !            14:        struct tagPair *slh_first;
        !            15: };
        !            16: typedef struct tagHead sl_config;
        !            17: 
        !            18: 
        !            19: /*
        !            20:  * InitConfig() Head initializing function for config
        !            21:  * @cfg = New head element for init
        !            22:  * return: 0 ok; -1 error:: new head element is null
        !            23: */
        !            24: inline int InitConfig(sl_config * __restrict cfg);
        !            25: /*
        !            26:  * CreateConfig() Create config file from memory
        !            27:  * @csConfigName = New config filename
        !            28:  * @cfg = Head list element
        !            29:  * return: 0 ok; -1 error:: can`t save new config
        !            30: */
        !            31: int CreateConfig(const char *csConfigName, sl_config * __restrict cfg);
        !            32: /*
        !            33:  * LoadConfig() Load config from file
        !            34:  * @csConfigName = Filename of config
        !            35:  * @cfg = Head list element
        !            36:  * return: 0 ok; -1 error:: can`t load config
        !            37: */
        !            38: int LoadConfig(const char *csConfigName, sl_config * __restrict cfg);
        !            39: /*
        !            40:  * UnloadConfig() Unload config from memory and free resources
        !            41:  * @cfg = Head list element
        !            42: */
        !            43: void UnloadConfig(sl_config * __restrict cfg);
        !            44: 
        !            45: 
        !            46: // cfg_GetErrno() Get error code of last operation
        !            47: inline int cfg_GetErrno();
        !            48: // cfg_GetError() Get error text of last operation
        !            49: inline const char *cfg_GetError();
        !            50: 
        !            51: 
        !            52: /*
        !            53:  * ReadConfig() Read from file and add new item to config list
        !            54:  * @f = file resource
        !            55:  * @cfg = Head list element
        !            56:  * return: 0 ok; -1 error:: can`t allocate memory
        !            57: */
        !            58: int ReadConfig(FILE *f, sl_config * __restrict cfg);
        !            59: /*
        !            60:  * WriteConfig() Write to file from items in config list
        !            61:  * @f = file resource
        !            62:  * @cfg = Head list element
        !            63:  * return: 0 ok; -1 error:: can`t write to file
        !            64: */
        !            65: int WriteConfig(FILE *f, sl_config * __restrict cfg);
        !            66: 
        !            67: 
        !            68: /*
        !            69:  * cfg_FindAttribute() Find attribute position in config list
        !            70:  * @cfg = Head list element
        !            71:  * @csSec = Config section //[{csSec}]
        !            72:  * @csAttr = Config attribute //{csAttr} = ...
        !            73:  * return: 0 not found item; -1 error: null parameters; >0 position in list
        !            74: */
        !            75: inline int cfg_FindAttribute(sl_config * __restrict cfg, const u_char *csSec, const u_char *csAttr);
        !            76: /*
        !            77:  * cfg_SetAttribute() Set item in config list or add new item if not exists
        !            78:  * @cfg = Head list element
        !            79:  * @csSec = Config section //[{csSec}], if NULL set in *default* section
        !            80:  * @csAttr = Config attribute //{csAttr} = ..., if NULL set as *any* attribute
        !            81:  * @csVal = Config value //... = {csVal} to setup
        !            82:  * return: 0 nothing changed, -1 error: not enough memory; 1 find and update item; 2 added new item
        !            83: */
        !            84: int cfg_SetAttribute(sl_config * __restrict cfg, const u_char *csSec, const u_char *csAttr, const u_char *csVal);
        !            85: /*
        !            86:  * cfg_UnsetAttribute() Unset item from config list and free resources
        !            87:  * @cfg = Head list element
        !            88:  * @csSec = Config section //[{csSec}], if NULL unset in *default* section
        !            89:  * @csAttr = Config attribute //{csAttr} = ..., if NULL unset as *any* attribute
        !            90:  * return: 0 item not found, -1 error: null parameters; >0 position in list
        !            91: */
        !            92: int cfg_UnsetAttribute(sl_config * __restrict cfg, const u_char *csSec, const u_char *csAttr);
        !            93: /*
        !            94:  * cfg_GetAttribute() Get item from config list and return his value
        !            95:  * @cfg = Head list element
        !            96:  * @csSec = Config section //[{csSec}], if NULL unset in *default* section
        !            97:  * @csAttr = Config attribute //{csAttr} = ..., if NULL unset as *any* attribute
        !            98:  * return: NULL item not found or null parameters; !=NULL value const string
        !            99: */
        !           100: inline const u_char *cfg_GetAttribute(sl_config * __restrict cfg, const u_char *csSec, const u_char *csAttr);
        !           101: 
        !           102: /*
        !           103:  * cfg_LoadAttribute() Extended get attribute, if not found item return *default value*
        !           104:  * @cfg = Head list element
        !           105:  * @csSec = Config section //[{csSec}], if NULL unset in *default* section
        !           106:  * @csAttr = Config attribute //{csAttr} = ..., if NULL unset as *any* attribute
        !           107:  * @psVal = Return buffer for item Value //... = {psVal}
        !           108:  * @ValLen = Length of buffer //{psVal} for return
        !           109:  * @csDefValue = *Default Value* for return in //{psVal}, if not found item in config list
        !           110:  * return: 0 item not found, -1 error: null parameters; >0 number of copied bytes in //{psVal}
        !           111: */
        !           112: int cfg_LoadAttribute(sl_config * __restrict cfg, const u_char *csSec, const u_char *csAttr, 
        !           113:                u_char * __restrict psVal, int ValLen, const char *csDefValue);
        !           114: 
        !           115: 
        !           116: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>