Rework cset functions to remove non-standard void * arithmetic.
Fixes compiling on Irix. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@108 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
@@ -414,7 +414,7 @@ void cset_variable(char *, char *, char *, char *);
|
|||||||
int BX_get_cset_int_var(CSetList *, int);
|
int BX_get_cset_int_var(CSetList *, int);
|
||||||
void BX_set_cset_int_var(CSetList *, int, int);
|
void BX_set_cset_int_var(CSetList *, int, int);
|
||||||
char *BX_get_cset_str_var(CSetList *, int);
|
char *BX_get_cset_str_var(CSetList *, int);
|
||||||
void BX_set_cset_str_var(CSetList *, int, char *);
|
void BX_set_cset_str_var(CSetList *, int, const char *);
|
||||||
|
|
||||||
CSetList *create_csets_for_channel(char *channel);
|
CSetList *create_csets_for_channel(char *channel);
|
||||||
void remove_csets_for_channel(CSetList *);
|
void remove_csets_for_channel(CSetList *);
|
||||||
|
|||||||
@@ -466,7 +466,7 @@ extern Function_ptr *global;
|
|||||||
#define get_cset_int_var (*(int (*)(CSetList *, int))global[GET_CSET_INT_VAR])
|
#define get_cset_int_var (*(int (*)(CSetList *, int))global[GET_CSET_INT_VAR])
|
||||||
#define set_cset_int_var (*(void (*)(CSetList *, int, int))global[SET_CSET_INT_VAR])
|
#define set_cset_int_var (*(void (*)(CSetList *, int, int))global[SET_CSET_INT_VAR])
|
||||||
#define get_cset_str_var (*(char *(*)(CSetList *, int))global[GET_CSET_STR_VAR])
|
#define get_cset_str_var (*(char *(*)(CSetList *, int))global[GET_CSET_STR_VAR])
|
||||||
#define set_cset_str_var (*(void (*)(CSetList *, int, char *))global[SET_CSET_STR_VAR])
|
#define set_cset_str_var (*(void (*)(CSetList *, int, const char *))global[SET_CSET_STR_VAR])
|
||||||
|
|
||||||
#define get_dllint_var (*(int (*)(char *))global[GET_DLLINT_VAR])
|
#define get_dllint_var (*(int (*)(char *))global[GET_DLLINT_VAR])
|
||||||
#define set_dllint_var (*(void (*)(char *, unsigned int ))global[SET_DLLINT_VAR])
|
#define set_dllint_var (*(void (*)(char *, unsigned int ))global[SET_DLLINT_VAR])
|
||||||
|
|||||||
@@ -173,68 +173,44 @@ static WSetArray wset_array[] = {
|
|||||||
|
|
||||||
CSetList *cset_queue = NULL;
|
CSetList *cset_queue = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the address of the requested field within the given CSetList.
|
||||||
|
*/
|
||||||
|
static void *get_cset_var_address(CSetList *tmp, int var)
|
||||||
|
{
|
||||||
|
void *ptr = ((char *)tmp + cset_array[var].offset);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* returns the requested int from the cset struct
|
* returns the requested int from the cset struct
|
||||||
* Will work fine with either BOOL or INT type of csets.
|
* Will work fine with either BOOL or INT type of csets.
|
||||||
*/
|
*/
|
||||||
int BX_get_cset_int_var(CSetList *tmp, int var)
|
int BX_get_cset_int_var(CSetList *tmp, int var)
|
||||||
{
|
{
|
||||||
int val = *(int *)((void *)tmp + cset_array[var].offset);
|
int *ptr = get_cset_var_address(tmp, var);
|
||||||
return val;
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *BX_get_cset_str_var(CSetList *tmp, int var)
|
char *BX_get_cset_str_var(CSetList *tmp, int var)
|
||||||
{
|
{
|
||||||
char *s = *(char **) ((void *)tmp + cset_array[var].offset);
|
char **ptr = get_cset_var_address(tmp, var);
|
||||||
return s;
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* returns the requested int from the cset struct
|
|
||||||
* Will work fine with either BOOL or INT type of csets.
|
|
||||||
*/
|
|
||||||
int cset_getflag(CSetList *tmp, int var)
|
|
||||||
{
|
|
||||||
int val = *(int *)((void *)tmp + cset_array[var].flag);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* sets the requested int from the cset struct
|
|
||||||
* Will work fine with either BOOL or INT type of csets.
|
|
||||||
*/
|
|
||||||
void cset_setflag(CSetList *tmp, int var, int value)
|
|
||||||
{
|
|
||||||
int *ptr = (int *) ((void *)tmp + cset_array[var].flag);
|
|
||||||
*ptr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* returns the requested int ADDRESS from the cset struct
|
|
||||||
* Will work fine with either BOOL or INT type of csets.
|
|
||||||
*/
|
|
||||||
static void * get_cset_int_var_address(CSetList *tmp, int var)
|
|
||||||
{
|
|
||||||
void *ptr = ((void *)tmp + cset_array[var].offset);
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sets the requested int from the cset struct
|
* sets the requested int from the cset struct
|
||||||
* Will work fine with either BOOL or INT type of csets.
|
* Will work fine with either BOOL or INT type of csets.
|
||||||
*/
|
*/
|
||||||
void BX_set_cset_int_var(CSetList *tmp, int var, int value)
|
void BX_set_cset_int_var(CSetList *tmp, int var, int value)
|
||||||
{
|
{
|
||||||
int *ptr = (int *) ((void *)tmp + cset_array[var].offset);
|
int *ptr = get_cset_var_address(tmp, var);
|
||||||
*ptr = value;
|
*ptr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BX_set_cset_str_var(CSetList *tmp, int var, const char *value)
|
||||||
void BX_set_cset_str_var(CSetList *tmp, int var, char *value)
|
|
||||||
{
|
{
|
||||||
char **ptr = (char **) ((void *)tmp + cset_array[var].offset);
|
char **ptr = get_cset_var_address(tmp, var);
|
||||||
if (value)
|
if (value)
|
||||||
malloc_strcpy(ptr, value);
|
malloc_strcpy(ptr, value);
|
||||||
else
|
else
|
||||||
@@ -299,7 +275,7 @@ static void set_cset_var_value(CSetList *tmp, int var_index, char *value)
|
|||||||
{
|
{
|
||||||
case BOOL_TYPE_VAR:
|
case BOOL_TYPE_VAR:
|
||||||
if (value && *value && (value = next_arg(value, &rest))) {
|
if (value && *value && (value = next_arg(value, &rest))) {
|
||||||
if (do_boolean(value, (int *)get_cset_int_var_address(tmp, var_index)))
|
if (do_boolean(value, (int *)get_cset_var_address(tmp, var_index)))
|
||||||
{
|
{
|
||||||
say("Value must be either ON, OFF, or TOGGLE");
|
say("Value must be either ON, OFF, or TOGGLE");
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user