Main Page | Data Structures | Directories | File List | Globals

mqproperty.h

Go to the documentation of this file.
00001 #ifndef _MQPROPERTY_H_
00002 #define _MQPROPERTY_H_
00003 
00004 /* Copyright (c) Kyriacos Leptos and the President and Fellows of Harvard University
00005    Release Date: 2004-11-01
00006    Part of the MapQuant suite library "mqbasic.lib" 
00007 */
00008 
00020 #define     MQPROPERTY_FILE_EXT          "prf"
00021 
00022 extern char*  MQPROPERTY_GLOBAL_PATHNAME; // usually set by environment variable 
00023 extern char*  MQPROPERTY_LOCAL_PATHNAME;
00024 extern MQByte MQPROPERTY_LOCAL_PATHNAME_LOADED;
00025 
00026 int         MQProperty_saveToLocalFile   (char* property_value, char* property_name);
00027 
00028 char*       MQProperty_loadFromFileAsString(char* property_name, char* filename);
00029 
00030 int         MQProperty_loadFromFile      (const void* property_value, char* property_name, char* filename, int type);
00031 int         MQProperty_loadFromGlobalFile(const void* property_value, char* property_name, int type);
00032 int         MQProperty_loadFromLocalFile (const void* property_value, char* property_name, int type);
00033 
00034 int         MQProperty_load(const void* property_value, char* property_name, int type, char* function_name);
00035 
00036 int         MQProperty_setGlobalFile(char* global_property_file);
00037 int         MQProperty_setLocalFile(char* local_property_file);
00038 
00039 void        MQProperty_releasePrefs();
00040 char*       MQProperty_findInPathOfExecutable(char* executable_name, char* properties_file);
00041 
00042 extern char parameter_name[MAX_LINE_LENGTH];
00043 extern char parameter_value[MAX_LINE_LENGTH];
00044 
00045 #define MQPROPERTY_READ(name, bitstring)                                        \
00046 {                                                                               \
00047     char* mqstr;                                                                \
00048     if(MQProperty_loadFromLocalFile(&mqstr, #name, MQ_STRING))                  \
00049     {                                                                           \
00050         if(VERBOSE == 1)                                                        \
00051             printf("%s loaded from preferences file\n", #name);                 \
00052         if (bitstring & name ## _SET)   free(name);                             \
00053         name = MQString_dup(mqstr);                                             \
00054         bitstring |= name ## _SET;                                              \
00055     }                                                                           \
00056     else if(MQProperty_loadFromGlobalFile(&mqstr, #name, MQ_STRING))            \
00057     {                                                                           \
00058         if(VERBOSE == 1)                                                        \
00059             printf("%s loaded from global file\n", #name);                      \
00060         if (bitstring & name ## _SET) free(name);                               \
00061         name = MQString_dup(mqstr);                                             \
00062         bitstring |= name ## _SET;                                              \
00063     }                                                                           \
00064     else                                                                        \
00065     {                                                                           \
00066         fprintf(stderr, "MQPROPERTY_READ: Variable %s not found\n", #name);     \
00067         exit(MQERROR_PROPERTY_NOT_FOUND);                                       \
00068     }                                                                           \
00069 }
00070 
00071 #define MQPROPERTY_FREE(name, bitstring)            \
00072 if (bitstring & name ## _SET)                       \
00073 {   bitstring &= (~(name ## _SET));                 \
00074     free(name);                                     \
00075 }
00076 
00077 #define GET_PARAMETER(NAME, value)                          \
00078 if (!strcmp(parameter_name, NAME))                          \
00079 {                                                           \
00080     sscanf(line, "%s %s", parameter_name, parameter_value); \
00081     value = MQString_dup(parameter_value);                  \
00082     found = 1;                                              \
00083 }
00084 
00085 #endif
00086 

Generated on Tue Feb 7 03:25:43 2006 for libmqbasic by  doxygen 1.4.4