cfgvar.h

Go to the documentation of this file.
00001 /*
00002     cfgvar.h:
00003 
00004     Copyright (C) 2005 Istvan Varga
00005 
00006     This file is part of Csound.
00007 
00008     The Csound Library is free software; you can redistribute it
00009     and/or modify it under the terms of the GNU Lesser General Public
00010     License as published by the Free Software Foundation; either
00011     version 2.1 of the License, or (at your option) any later version.
00012 
00013     Csound is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU Lesser General Public License for more details.
00017 
00018     You should have received a copy of the GNU Lesser General Public
00019     License along with Csound; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00021     02111-1307 USA
00022 */
00023 
00024 #ifndef CSOUND_CFGVAR_H
00025 #define CSOUND_CFGVAR_H
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 
00031 /* generic header structure */
00032 
00033 typedef struct csCfgVariableHead_s {
00034     union csCfgVariable_u *nxt;       /* pointer to next structure in chain */
00035     unsigned char   *name;            /* name of the variable               */
00036     void            *p;               /* pointer to value                   */
00037     int             type;             /* type (e.g. CSOUNDCFG_INTEGER)      */
00038     int             flags;            /* bitwise OR of flags                */
00039     unsigned char   *shortDesc;       /* short description (NULL if none)   */
00040     unsigned char   *longDesc;        /* long description (NULL if none)    */
00041 } csCfgVariableHead_t;
00042 
00043 /* int type */
00044 
00045 typedef struct csCfgVariableInt_s {
00046     union csCfgVariable_u *nxt;       /* pointer to next structure in chain */
00047     unsigned char   *name;            /* name of the variable               */
00048     int             *p;               /* pointer to value                   */
00049     int             type;             /* type (CSOUNDCFG_INTEGER)           */
00050     int             flags;            /* bitwise OR of flags                */
00051     unsigned char   *shortDesc;       /* short description (NULL if none)   */
00052     unsigned char   *longDesc;        /* long description (NULL if none)    */
00053     int             min;              /* minimum allowed value              */
00054     int             max;              /* maximum allowed value              */
00055 } csCfgVariableInt_t;
00056 
00057 /* boolean type (int with a value of 0 or 1) */
00058 
00059 typedef struct csCfgVariableBoolean_s {
00060     union csCfgVariable_u *nxt;       /* pointer to next structure in chain */
00061     unsigned char   *name;            /* name of the variable               */
00062     int             *p;               /* pointer to value                   */
00063     int             type;             /* type (CSOUNDCFG_BOOLEAN)           */
00064     int             flags;            /* bitwise OR of flags                */
00065     unsigned char   *shortDesc;       /* short description (NULL if none)   */
00066     unsigned char   *longDesc;        /* long description (NULL if none)    */
00067 } csCfgVariableBoolean_t;
00068 
00069 /* float type */
00070 
00071 typedef struct csCfgVariableFloat_s {
00072     union csCfgVariable_u *nxt;       /* pointer to next structure in chain */
00073     unsigned char   *name;            /* name of the variable               */
00074     float           *p;               /* pointer to value                   */
00075     int             type;             /* type (CSOUNDCFG_FLOAT)             */
00076     int             flags;            /* bitwise OR of flags                */
00077     unsigned char   *shortDesc;       /* short description (NULL if none)   */
00078     unsigned char   *longDesc;        /* long description (NULL if none)    */
00079     float           min;              /* minimum allowed value              */
00080     float           max;              /* maximum allowed value              */
00081 } csCfgVariableFloat_t;
00082 
00083 /* double type */
00084 
00085 typedef struct csCfgVariableDouble_s {
00086     union csCfgVariable_u *nxt;       /* pointer to next structure in chain */
00087     unsigned char   *name;            /* name of the variable               */
00088     double          *p;               /* pointer to value                   */
00089     int             type;             /* type (CSOUNDCFG_DOUBLE)            */
00090     int             flags;            /* bitwise OR of flags                */
00091     unsigned char   *shortDesc;       /* short description (NULL if none)   */
00092     unsigned char   *longDesc;        /* long description (NULL if none)    */
00093     double          min;              /* minimum allowed value              */
00094     double          max;              /* maximum allowed value              */
00095 } csCfgVariableDouble_t;
00096 
00097 /* MYFLT (float or double) type */
00098 
00099 typedef struct csCfgVariableMYFLT_s {
00100     union csCfgVariable_u *nxt;       /* pointer to next structure in chain */
00101     unsigned char   *name;            /* name of the variable               */
00102     MYFLT           *p;               /* pointer to value                   */
00103     int             type;             /* type (CSOUNDCFG_MYFLT)             */
00104     int             flags;            /* bitwise OR of flags                */
00105     unsigned char   *shortDesc;       /* short description (NULL if none)   */
00106     unsigned char   *longDesc;        /* long description (NULL if none)    */
00107     MYFLT           min;              /* minimum allowed value              */
00108     MYFLT           max;              /* maximum allowed value              */
00109 } csCfgVariableMYFLT_t;
00110 
00111 /* string type */
00112 
00113 typedef struct csCfgVariableString_s {
00114     union csCfgVariable_u *nxt;       /* pointer to next structure in chain */
00115     unsigned char   *name;            /* name of the variable               */
00116     char            *p;               /* value: array of 'maxlen' chars     */
00117     int             type;             /* type (CSOUNDCFG_STRING)            */
00118     int             flags;            /* bitwise OR of flags                */
00119     unsigned char   *shortDesc;       /* short description (NULL if none)   */
00120     unsigned char   *longDesc;        /* long description (NULL if none)    */
00121     int             maxlen;           /* maximum length + 1                 */
00122 } csCfgVariableString_t;
00123 
00124 /* union of all variable types */
00125 
00126 typedef union csCfgVariable_u {
00127   csCfgVariableHead_t       h;
00128   csCfgVariableInt_t        i;
00129   csCfgVariableBoolean_t    b;
00130   csCfgVariableFloat_t      f;
00131   csCfgVariableDouble_t     d;
00132   csCfgVariableMYFLT_t      m;
00133   csCfgVariableString_t     s;
00134 } csCfgVariable_t;
00135 
00136 /* types */
00137 
00138 #define CSOUNDCFG_INTEGER   1
00139 #define CSOUNDCFG_BOOLEAN   2
00140 #define CSOUNDCFG_FLOAT     3
00141 #define CSOUNDCFG_DOUBLE    4
00142 #define CSOUNDCFG_MYFLT     5
00143 #define CSOUNDCFG_STRING    6
00144 
00145 /* flags */
00146 
00147 #define CSOUNDCFG_POWOFTWO  0x00000001
00148 
00149 /* error codes */
00150 
00151 #define CSOUNDCFG_SUCCESS           0
00152 #define CSOUNDCFG_INVALID_NAME      -1
00153 #define CSOUNDCFG_INVALID_TYPE      -2
00154 #define CSOUNDCFG_INVALID_FLAG      -3
00155 #define CSOUNDCFG_NULL_POINTER      -4
00156 #define CSOUNDCFG_TOO_HIGH          -5
00157 #define CSOUNDCFG_TOO_LOW           -6
00158 #define CSOUNDCFG_NOT_POWOFTWO      -7
00159 #define CSOUNDCFG_INVALID_BOOLEAN   -8
00160 #define CSOUNDCFG_MEMORY            -9
00161 #define CSOUNDCFG_STRING_LENGTH     -10
00162 
00163 #define CSOUNDCFG_LASTERROR         -10
00164 
00165 /* -------- interface functions -------- */
00166 
00167 /* This pragma must come before all public function declarations */
00168 #if (defined(macintosh) && defined(__MWERKS__))
00169 #  pragma export on
00170 #endif
00171 
00212 #if 0
00213   PUBLIC int
00214     csoundCreateGlobalConfigurationVariable(const char *name,
00215                                             void *p, int type, int flags,
00216                                             void *min, void *max,
00217                                             const char *shortDesc,
00218                                             const char *longDesc);
00219 #endif
00220 
00229   PUBLIC int
00230     csoundCreateConfigurationVariable(CSOUND *csound, const char *name,
00231                                       void *p, int type, int flags,
00232                                       void *min, void *max,
00233                                       const char *shortDesc,
00234                                       const char *longDesc);
00235 
00241 #if 0
00242   PUBLIC int csoundCopyGlobalConfigurationVariable(CSOUND *csound,
00243                                                    const char *name, void *p);
00244 #endif
00245 
00251 #if 0
00252   PUBLIC int csoundCopyGlobalConfigurationVariables(CSOUND *csound);
00253 #endif
00254 
00274 #if 0
00275   PUBLIC int csoundSetGlobalConfigurationVariable(const char *name,
00276                                                   void *value);
00277 #endif
00278 
00284   PUBLIC int csoundSetConfigurationVariable(CSOUND *csound, const char *name,
00285                                                             void *value);
00286 
00306 #if 0
00307   PUBLIC int csoundParseGlobalConfigurationVariable(const char *name,
00308                                                     const char *value);
00309 #endif
00310 
00317   PUBLIC int csoundParseConfigurationVariable(CSOUND *csound, const char *name,
00318                                               const char *value);
00319 
00325 #if 0
00326   PUBLIC csCfgVariable_t
00327     *csoundQueryGlobalConfigurationVariable(const char *name);
00328 #endif
00329 
00335   PUBLIC csCfgVariable_t
00336     *csoundQueryConfigurationVariable(CSOUND *csound, const char *name);
00337 
00346 #if 0
00347   PUBLIC csCfgVariable_t **csoundListGlobalConfigurationVariables(void);
00348 #endif
00349 
00359   PUBLIC csCfgVariable_t **csoundListConfigurationVariables(CSOUND *csound);
00360 
00366   PUBLIC void csoundDeleteCfgVarList(csCfgVariable_t **lst);
00367 
00375 #if 0
00376   PUBLIC int csoundDeleteGlobalConfigurationVariable(const char *name);
00377 #endif
00378 
00386   PUBLIC int csoundDeleteConfigurationVariable(CSOUND *csound,
00387                                                const char *name);
00388 
00395 #if 0
00396   PUBLIC int csoundDeleteAllGlobalConfigurationVariables(void);
00397 #endif
00398 
00403   PUBLIC const char *csoundCfgErrorCodeToString(int errcode);
00404 
00405 /* This pragma must come after all public function declarations */
00406 #if (defined(macintosh) && defined(__MWERKS__))
00407 #  pragma export off
00408 #endif
00409 
00410 #ifdef __cplusplus
00411 }
00412 #endif
00413 
00414 #endif  /* CSOUND_CFGVAR_H */
00415 

Generated on Sun Nov 9 00:04:52 2008 for Csound and CsoundAC by  doxygen 1.5.6