Commit 201127db authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(CHK_BOOL): New macro.

(CHK_CONNECTION): Use the "do ... while (0)" construct to make
	this macro expand to exactly one statement.
(CHK_LOGIN): Ditto.
(CONF_ZERO): Ditto.
(CHK_EXIST): Ditto.
(GET_P_STAT): Ditto.
(VOID_GET_P_STAT): Ditto.
(GET_C_STAT): Ditto.
(VOID_GET_C_STAT): Ditto.
(GET_T_STAT): Ditto.
(VOID_GET_T_STAT): Ditto.
parent ec3af8ac
/*
* $Id: manipulate.h,v 0.43 2003/08/20 10:25:00 ceder Exp $
* $Id: manipulate.h,v 0.44 2003/08/23 15:12:44 ceder Exp $
* Copyright (C) 1991-1994, 1996-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -23,7 +23,7 @@
* Please report bugs at http://bugzilla.lysator.liu.se/.
*/
/*
* $Id: manipulate.h,v 0.43 2003/08/20 10:25:00 ceder Exp $
* $Id: manipulate.h,v 0.44 2003/08/23 15:12:44 ceder Exp $
*
* manipulate.h
*
......@@ -40,46 +40,55 @@
/* person of the connected person. (NULL if not logged in) */
#define ACT_P (active_connection->person)
/* many functions can only be used if ACTPERS is logged in */
#define CHK_CONNECTION(errortype) \
{ \
do { \
if (active_connection == NULL) \
{ \
err_stat = 0; \
kom_errno = KOM_INTERNAL_ERROR; \
return errortype; \
} \
}
} while (0)
#define CHK_BOOL(val, errortype) \
do { \
if (val != 0 && val != 1) \
{ \
err_stat = 0; \
kom_errno = KOM_BAD_BOOL; \
return errortype; \
} \
} while (0)
/* many functions can only be used if ACTPERS is logged in */
#define CHK_LOGIN(errortype) \
{ \
do { \
if ( !active_connection || !ACTPERS ) \
{ \
err_stat = 0; \
kom_errno = KOM_LOGIN; \
return errortype; \
} \
}
} while (0)
/* Conference 0 does never exist. */
#define CONF_ZERO(conf, errortype) \
{ \
do { \
if ( (conf) == 0 ) \
{ \
err_stat = 0; \
kom_errno = KOM_CONF_ZERO; \
return errortype; \
} \
}
} while (0)
/* Check that a conference exists */
#define CHK_EXIST(conf, errortype) \
{ \
do { \
CONF_ZERO(conf, errortype); \
if ( !cached_conf_exists( conf )) \
{ \
......@@ -87,62 +96,62 @@
kom_errno = KOM_UNDEF_CONF; \
return errortype; \
} \
}
} while (0)
/* do a cached_get_person_stat */
#define GET_P_STAT(p_stat_p, pers_no, failure) \
{ \
do { \
if ( ((p_stat_p) = cached_get_person_stat( pers_no )) == NULL) \
{ \
return (failure); \
} \
}
} while (0)
#define VOID_GET_P_STAT(p_stat_p, pers_no) \
{ \
do { \
if ( ((p_stat_p) = cached_get_person_stat( pers_no )) == NULL) \
{ \
return; \
} \
}
} while (0)
/* do a cached_get_conf_stat */
#define GET_C_STAT(c_stat_p, conf_no, failure) \
{ \
do { \
if ( ((c_stat_p) = cached_get_conf_stat( conf_no )) == NULL) \
{ \
return (failure); \
} \
}
} while (0)
#define VOID_GET_C_STAT(c_stat_p, conf_no) \
{ \
do { \
if ( ((c_stat_p) = cached_get_conf_stat( conf_no )) == NULL) \
{ \
return; \
} \
}
} while (0)
/* do a cached_get_text_stat */
#define GET_T_STAT(t_stat_p, text_no, failure) \
{ \
do { \
if ( ((t_stat_p) = cached_get_text_stat( text_no )) == NULL) \
{ \
return (failure); \
} \
}
} while (0)
#define VOID_GET_T_STAT(t_stat_p, text_no) \
{ \
do { \
if ( ((t_stat_p) = cached_get_text_stat( text_no )) == NULL) \
{ \
return; \
} \
}
} while (0)
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment