[asterisk-commits] branch oej/aum - r7401 in /team/oej/aum: include/asterisk/ res/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Dec 8 17:09:35 CST 2005


Author: oej
Date: Thu Dec  8 17:09:32 2005
New Revision: 7401

URL: http://svn.digium.com/view/asterisk?rev=7401&view=rev
Log:
Fixing compilation problems

Modified:
    team/oej/aum/include/asterisk/aum.h
    team/oej/aum/include/asterisk/linkedlists.h
    team/oej/aum/res/Makefile
    team/oej/aum/res/res_aum.c

Modified: team/oej/aum/include/asterisk/aum.h
URL: http://svn.digium.com/view/asterisk/team/oej/aum/include/asterisk/aum.h?rev=7401&r1=7400&r2=7401&view=diff
==============================================================================
--- team/oej/aum/include/asterisk/aum.h (original)
+++ team/oej/aum/include/asterisk/aum.h Thu Dec  8 17:09:32 2005
@@ -239,7 +239,7 @@
 enum aum_group_flags {
 	AUM_GROUP_FLAG_REALTIME = (1 << 0),	/*!< Group loaded from realtime */
 	AUM_GROUP_FLAG_DISABLED = (1 << 1),	/*!< Group disabled */
-}
+};
 
 
 /*! \brief Declaration of grouplist structure for inclusion in objects */
@@ -303,7 +303,6 @@
 	struct ast_variable *chanvars;
 	char *description;			/*!< Description */
 	struct aum_user_grouplist members;	/*!< Members list */
-	char language[MAX_LANGUAGE];	/*!< Default language */
 	char registrar[20];		/*!< Who added this object? */
 };
 

Modified: team/oej/aum/include/asterisk/linkedlists.h
URL: http://svn.digium.com/view/asterisk/team/oej/aum/include/asterisk/linkedlists.h?rev=7401&r1=7400&r2=7401&view=diff
==============================================================================
--- team/oej/aum/include/asterisk/linkedlists.h (original)
+++ team/oej/aum/include/asterisk/linkedlists.h Thu Dec  8 17:09:32 2005
@@ -413,26 +413,6 @@
 		cur;							\
 	})
 
-/*!
-  \brief Removes and returns the tail entry from a list.
-  \param head This is a pointer to the list head structure
-  \param field This is the name of the field (declared using AST_LIST_ENTRY())
-  used to link entries of this list together.
-
-  Removes the tail entry from the list, and returns a pointer to it.
-  This macro is safe to call on an empty list.
- */
-#define AST_LIST_REMOVE_TAIL(head, field) ({				\
-		typeof((head)->first) cur = (head)->last;		\
-		if (cur) {						\
-			(head)->last = cur->field.prev;		\
-			(head)->last->field.next = NULL;				\
-			if ((head)->first == cur)			\
-				(head)->first = NULL;			\
-		}							\
-		cur;							\
-	})
-
 
 /*!
   \brief Removes a specific entry from a list.

Modified: team/oej/aum/res/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/aum/res/Makefile?rev=7401&r1=7400&r2=7401&view=diff
==============================================================================
--- team/oej/aum/res/Makefile (original)
+++ team/oej/aum/res/Makefile Thu Dec  8 17:09:32 2005
@@ -11,7 +11,7 @@
 # the GNU General Public License
 #
 
-MODS=res_indications.so res_monitor.so res_adsi.so res_agi.so res_features.so
+MODS=res_indications.so res_monitor.so res_adsi.so res_agi.so res_features.so res_aum.so
 
 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/odbcinst.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/odbcinst.h),)
   ifneq (${OSARCH},FreeBSD)

Modified: team/oej/aum/res/res_aum.c
URL: http://svn.digium.com/view/asterisk/team/oej/aum/res/res_aum.c?rev=7401&r1=7400&r2=7401&view=diff
==============================================================================
--- team/oej/aum/res/res_aum.c (original)
+++ team/oej/aum/res/res_aum.c Thu Dec  8 17:09:32 2005
@@ -50,8 +50,10 @@
 #include "asterisk/logger.h"
 #include "asterisk/config.h"
 #include "asterisk/channel.h"
+#include "asterisk/callerid.h"
 #include "asterisk/astobj.h"
 #include "asterisk/pbx.h"
+#include "asterisk/acl.h"
 #include "asterisk/options.h"
 #include "asterisk/module.h"
 #include "asterisk/app.h"
@@ -265,14 +267,14 @@
 } aum_userlist;
 
 /*! \brief the realtime user cache */
-static struct aum_usercache_struct {
-	AST_LIST_ENTRY(aum_usercache) list;
+struct aum_usercache_struct {
 	struct aum_user *user;
+	AST_LIST_ENTRY(aum_usercache_struct) list;
 };
 
 static int aum_usercache_count = 0;
 static int aum_usercache_max = 50;
-static AST_LIST_HEAD_STATIC(aum_usercache_struct, aum_usercache);
+static AST_LIST_HEAD_STATIC(aum_usercache, aum_usercache_struct);
 
 /*! brief Different config options for address formats */
 static struct aum_address_config_struct aum_address_config[] = {
@@ -371,7 +373,6 @@
 static int cli_aum_show_users(int fd, int argc, char *argv[])
 {
 	int numusers = 0;
-	int numgroups = 0;
 
 	if (argc != 3)
 		return RESULT_SHOWUSAGE;
@@ -381,9 +382,8 @@
 	
 	ASTOBJ_CONTAINER_TRAVERSE(&aum_userlist, 1, {
 		ASTOBJ_RDLOCK(iterator);
-		if (!ast_test_flag(iterator, AST_USER_FLAG_REALTIME)) {
+		if (!ast_test_flag(iterator, AUM_USER_FLAG_REALTIME)) {
 			ast_cli(fd, " %-20.20s: %-10.10s %-15.15s %-10.10s %s\n", iterator->name, iterator->first_name, iterator->last_name, iterator->numuserid, ast_test_flag(iterator, AUM_USER_FLAG_DISABLED) ? "* DISABLED *" : "");
-	if (ast_test_flag(user, AUM_USER_FLAG_DISABLED))
 			numusers ++;
 		}
 		ASTOBJ_UNLOCK(iterator);
@@ -856,7 +856,7 @@
 	if (type==AUM_CONTEXT_NONE && option == AUM_CNF_NONE)
 		return newcontext;
 
-	if (type == AUM_CONTEXT_NONE)
+	if (type == AUM_CONTEXT_NONE) {
 		switch (option) {
 		case AUM_CNF_DISACONTEXT:
 			type = AUM_CONTEXT_DISA;
@@ -871,6 +871,7 @@
 			type = AUM_CONTEXT_NONE;
 			break;
 		}
+	}
 
 	newcontext = aum_allocate(sizeof(struct aum_context));
 	if (!newcontext)
@@ -889,27 +890,28 @@
 static void aum_rtcache_freeall(void) {
 	struct aum_usercache_struct *temp;
 
-	AST_LIST_LOCK(aum_usercache);
+	AST_LIST_LOCK(&aum_usercache);
 
 	if (!AST_LIST_EMPTY(&aum_usercache) ) {
 		AST_LIST_LOCK(&aum_usercache);
-		while ((temp = AST_LIST_REMOVE_HEAD(&aum_usercache, list)))
+		while ((temp = AST_LIST_REMOVE_HEAD(&aum_usercache, list))) {
 			aum_destroy_user(temp->user);
 			free(temp);
+		}
 		AST_LIST_UNLOCK(&aum_usercache);
 	}
 }
 
-/*! \brief Add realtime user to top of the cache 
-	If the cache is full, the user at the bottom of the cache is
+/*! \brief Add realtime user to top of the cache  (actually, the end of the list)
+	If the cache is full, the user at the top of the cache is
 	simply removed from memory
-	\param user AUM user to add to the top 
+	\param user AUM user to add to the bottom
 */
 static void aum_rtcache_add(struct aum_user *user) {
 	struct aum_usercache_struct *temp;
 	struct aum_usercache_struct *aums;
 
-	aums = aum_allocate(sizeof(aum_usercache_struct);
+	aums = aum_allocate(sizeof(struct aum_usercache_struct));
 	if (!aums)
 		return;		/* Allocation error */
 	
@@ -919,7 +921,7 @@
 	if (aum_usercache_count == aum_usercache_max) {
 		/* Remove user from cache and delete */
 		AST_LIST_LOCK(&aum_usercache);
-		temp = AST_LIST_REMOVE_TAIL(&aum_usercache, list);
+		temp = AST_LIST_REMOVE_HEAD(&aum_usercache, list);
 		AST_LIST_UNLOCK(&aum_usercache);
 		aum_destroy_user(temp->user);
 		free(temp);
@@ -928,33 +930,33 @@
 
 	/* Move it into the list */
 	AST_LIST_LOCK(&aum_usercache);
-	AST_LIST_INSERT_HEAD(&aum_usercache, aums, list);
+	AST_LIST_INSERT_TAIL(&aum_usercache, aums, list);
 	AST_LIST_UNLOCK(&aum_usercache);
 	aum_usercache_count++;
 
 	return;
 }
 
-/*! \brief Add realtime user to top of the cache 
+/*! \brief Move realtime cache object to bottom of cache (we remove from top)
 	Called when a user object is accessed
 */
 static void aum_rtcache_movetotop(struct aum_user *user) {
 	struct aum_usercache_struct *temp;
-	struct aum_usercache_struct *top_of_the_class = (struct aum_usercache_struct) NULL;
+	struct aum_usercache_struct *top_of_the_class = (struct aum_usercache_struct *) NULL;
 
 	/* Find user in cache */
-	AST_LIST_TRAVERSE_SAFE_BEGIN(aum_usercache, temp, list) {
+	AST_LIST_TRAVERSE_SAFE_BEGIN(&aum_usercache, temp, list) {
 		if (temp->user == user) {
 			top_of_the_class = temp;
 			/* Remove from current position in list */
-			AST_LIST_LOCK(aum_usercache);
-			AST_LIST_REMOVE_CURRENT();
-		}
-	}
+			AST_LIST_LOCK(&aum_usercache);
+			AST_LIST_REMOVE_CURRENT(&aum_usercache, list);
+		}
+	};
 	/* Add her to top */
 	if (top_of_the_class) {
-		AST_LIST_INSERT_HEAD(aum_usercache, top_of_the_class, list);
-		AST_LIST_UNLOCK(aum_usercache);
+		AST_LIST_INSERT_TAIL(&aum_usercache, top_of_the_class, list);
+		AST_LIST_UNLOCK(&aum_usercache);
 	}
 
 	/* Return */
@@ -975,6 +977,7 @@
 	struct aum_address *address;
 	struct aum_context *context;
 	enum aum_config_options option;
+	char *varname = NULL, *varval = NULL;
 
 	/* Check if username exists already */
 	if (find_aum_user(username)) {
@@ -1040,32 +1043,32 @@
 				ast_log(LOG_ERROR, "Context %s not added for user %s\n", x->value, username);
 			break;
 		case AUM_CNF_DEFEXTEN:
-			ast_copy_string(&user->default_exten, x->value, sizeof(&user->default_exten);
+			ast_copy_string(user->default_exten, x->value, sizeof(user->default_exten));
 			break;
 		case AUM_CNF_CID:
-			ast_callerid_split(v->value, user->cid_name, sizeof(user->cid_name), user->cid_num, sizeof(user->cid_num));
+			ast_callerid_split(x->value, user->cid_name, sizeof(user->cid_name), user->cid_num, sizeof(user->cid_num));
 			break;
 		case AUM_CNF_CALLERPRES:
-			user->calling_pres = ast_parse_caller_presentation(v->value);
-			if (user->callingpres == -1)
-				user->calling_pres = atoi(v->value);
+			user->calling_pres = ast_parse_caller_presentation(x->value);
+			if (user->calling_pres == -1)
+				user->calling_pres = atoi(x->value);
 				
 			break;
 		case AUM_CNF_TIMEZONE:
 			break;
 		case AUM_CNF_CALLGROUP:
-			user->callgroup = ast_get_group(v->value);
+			user->callgroup = ast_get_group(x->value);
 			break;
 		case AUM_CNF_PICKUPGROUP:
-			user->pickupgroup = ast_get_group(v->value);
+			user->pickupgroup = ast_get_group(x->value);
 			break;
 		case AUM_CNF_ACCOUNTCODE:
-			ast_copy_string(&user->accountcode, x->value, sizeof(&user->accountcode);
+			ast_copy_string(user->accountcode, x->value, sizeof(user->accountcode));
 			break;
 		case AUM_CNF_MANAGERACCESS:
 			break;
 		case AUM_CNF_SECRET:
-			ast_copy_string(&user->secret, x->value, sizeof(&user->secret);
+			ast_copy_string(user->secret, x->value, sizeof(user->secret));
 			break;
 		case AUM_CNF_PIN:
 			ast_copy_string(user->pincode, x->value, sizeof(user->pincode));
@@ -1091,7 +1094,7 @@
 			break;
 		case AUM_CNF_CHANVAR:
 			/* Set peer channel variable */
-			varname = ast_strdupa(v->value);
+			varname = ast_strdupa(x->value);
 			if (varname && (varval = strchr(varname,'='))) {
 				struct ast_variable *tmpvar;
 				*varval = '\0';
@@ -1108,7 +1111,7 @@
 		case AUM_CNF_PERMIT:
 		case AUM_CNF_DENY:
 			// ACL
-			user->acl = ast_append_ha(v->name, v->value, user->acl);
+			user->acl = ast_append_ha(x->name, x->value, user->acl);
 			break;
 		case AUM_CNF_NUMID:
 			ast_copy_string(user->numuserid, x->value, sizeof(user->numuserid));
@@ -1136,7 +1139,7 @@
 	}
 	ASTOBJ_CONTAINER_LINK(&aum_userlist, user);
 	if (realtime) 
-		aum_realtime_cacheadd(user);
+		aum_rtcache_add(user);
 
 	aum_static_users++;
 	//ASTOBJ_UNMARK(user);
@@ -1232,14 +1235,29 @@
 	
 */
 static struct aum_user *aum_user_realtime_loadbyfield(char *field, char *value)
+{
 	struct aum_user *user = (struct aum_user *) NULL;
-	struct ast_variable *var;
+	struct ast_variable *var, *text;
+	char *username = value;
 	
 	var = ast_load_realtime("aumusers", field, value, NULL);
 	if (!var)
 		return (struct aum_user *) NULL;
 
 	/* User found in realtime, now build it in memory */
+	/* Find username */
+	if (strcasecmp(field, "name")) {
+		text = var;
+		while (text) {
+			if (!strcasecmp("name", text->name)) {
+				username = text->value;
+				break;
+			}
+			text = text->next;
+		}
+	
+	}
+
 	user = aum_build_user(username, var, 1);
 	if (user) {
 		ASTOBJ_CONTAINER_LINK(&aum_userlist, user);
@@ -1305,8 +1323,8 @@
 		}
 	};
 
-	if (ast_test_flag(user, AST_USER_FLAG_REALTIME))
-		aum_rtcache_movetotop(struct aum_user *user);
+	if (ast_test_flag(user, AUM_USER_FLAG_REALTIME))
+		aum_rtcache_movetotop(user);
 }
 
 /*! \brief Destroy AUM group object */
@@ -1441,20 +1459,20 @@
 		}
 		x = x->next;
 	}
-/* Load groups names */
+	/* Load group names */
 	ast_log(LOG_DEBUG, "===== Starting to read [groups] section\n");
 	v = ast_variable_browse(cfg, "groups");
 	ast_log(LOG_DEBUG, "- Found group section \n");
 	while (v) {
-		ast_log(LOG_DEBUG, "- Found new group: %s=%s\n", v->name, v->value);
+		ast_log(LOG_DEBUG, "- Found new group: %s=%s\n", x->name, x->value);
 		if (!strcmp(v->name, "group")) {
 			/* get the group */
 			x = ast_variable_browse(cfg, v->value);
 			if (x) {
-				ast_log(LOG_DEBUG, "- Trying to build new group: %s\n", v->value);
-				group = aum_build_group(v->value, x, 0);	/* Build the group */
+				ast_log(LOG_DEBUG, "- Trying to build new group: %s\n", x->value);
+				group = aum_build_group(x->value, x, 0);	/* Build the group */
 				if (group) {
-					ast_log(LOG_VERBOSE, "- Built new group:%s\n", v->value);
+					ast_log(LOG_VERBOSE, "- Built new group:%s\n", x->value);
 					ASTOBJ_CONTAINER_LINK(&aum_grouplist, group);
 				}
 			}
@@ -1610,11 +1628,10 @@
 	/* Search among static and cached realtime users */
 	res = ASTOBJ_CONTAINER_FIND(&aum_userlist, userid);	
 	if (!res && aum_real_users_enabled) {
-		res = aum_user_realtime_load(username);
-	} else if (res && ast_test_flag(user, AST_USER_FLAG_REALTIME))
+		res = aum_user_realtime_load(userid);
+	} else if (res && ast_test_flag(user, AUM_USER_FLAG_REALTIME))
 		/* Move user to top of cache */
-		aum_rtcache_movetotop(struct aum_user *user);
-	}
+		aum_rtcache_movetotop(user);
 	return res;
 }
 



More information about the asterisk-commits mailing list