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

mqproperty.h File Reference

A file that includes the definitions and functions for manipulating properties. More...

Go to the source code of this file.

Defines

#define MQPROPERTY_FILE_EXT   "prf"
#define MQPROPERTY_READ(name, bitstring)
#define MQPROPERTY_FREE(name, bitstring)
#define GET_PARAMETER(NAME, value)

Functions

int MQProperty_saveToLocalFile (char *property_value, char *property_name)
char * MQProperty_loadFromFileAsString (char *property_name, char *filename)
int MQProperty_loadFromFile (const void *property_value, char *property_name, char *filename, int type)
int MQProperty_loadFromGlobalFile (const void *property_value, char *property_name, int type)
int MQProperty_loadFromLocalFile (const void *property_value, char *property_name, int type)
int MQProperty_load (const void *property_value, char *property_name, int type, char *function_name)
int MQProperty_setGlobalFile (char *global_property_file)
int MQProperty_setLocalFile (char *local_property_file)
void MQProperty_releasePrefs ()
char * MQProperty_findInPathOfExecutable (char *executable_name, char *properties_file)

Variables

char * MQPROPERTY_GLOBAL_PATHNAME
char * MQPROPERTY_LOCAL_PATHNAME
MQByte MQPROPERTY_LOCAL_PATHNAME_LOADED
char parameter_name [MAX_LINE_LENGTH]
char parameter_value [MAX_LINE_LENGTH]


Detailed Description

A file that includes the definitions and functions for manipulating properties.

Author:
Kyriacos C. Leptos
Date:
2004-05-04
A property is an environment variable internal to the program, usually passed to the program in a .prf file in the following form:
VARIABLE_NAME_1 VALUE_1
VARIABLE_NAME_2 VALUE_2

Define Documentation

#define GET_PARAMETER NAME,
value   ) 
 

Value:

if (!strcmp(parameter_name, NAME))                          \
{                                                           \
    sscanf(line, "%s %s", parameter_name, parameter_value); \
    value = MQString_dup(parameter_value);                  \
    found = 1;                                              \
}

#define MQPROPERTY_FREE name,
bitstring   ) 
 

Value:

if (bitstring & name ## _SET)                       \
{   bitstring &= (~(name ## _SET));                 \
    free(name);                                     \
}

#define MQPROPERTY_READ name,
bitstring   ) 
 

Value:

{                                                                               \
    char* mqstr;                                                                \
    if(MQProperty_loadFromLocalFile(&mqstr, #name, MQ_STRING))                  \
    {                                                                           \
        if(VERBOSE == 1)                                                        \
            printf("%s loaded from preferences file\n", #name);                 \
        if (bitstring & name ## _SET)   free(name);                             \
        name = MQString_dup(mqstr);                                             \
        bitstring |= name ## _SET;                                              \
    }                                                                           \
    else if(MQProperty_loadFromGlobalFile(&mqstr, #name, MQ_STRING))            \
    {                                                                           \
        if(VERBOSE == 1)                                                        \
            printf("%s loaded from global file\n", #name);                      \
        if (bitstring & name ## _SET) free(name);                               \
        name = MQString_dup(mqstr);                                             \
        bitstring |= name ## _SET;                                              \
    }                                                                           \
    else                                                                        \
    {                                                                           \
        fprintf(stderr, "MQPROPERTY_READ: Variable %s not found\n", #name);     \
        exit(MQERROR_PROPERTY_NOT_FOUND);                                       \
    }                                                                           \
}


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