[asterisk-commits] branch oej/t38passthrough r18750 - in /team/oej/t38passthrough: ./ channels/ ...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Apr 9 22:26:14 MST 2006


Author: oej
Date: Mon Apr 10 00:26:03 2006
New Revision: 18750

URL: http://svn.digium.com/view/asterisk?rev=18750&view=rev
Log:
Update to trunk after non-existing conflict...

Modified:
    team/oej/t38passthrough/   (props changed)
    team/oej/t38passthrough/channels/chan_sip.c
    team/oej/t38passthrough/doc/CODING-GUIDELINES
    team/oej/t38passthrough/formats/format_g723.c
    team/oej/t38passthrough/formats/format_g726.c
    team/oej/t38passthrough/formats/format_g729.c
    team/oej/t38passthrough/formats/format_gsm.c
    team/oej/t38passthrough/formats/format_h263.c
    team/oej/t38passthrough/formats/format_h264.c
    team/oej/t38passthrough/formats/format_ilbc.c
    team/oej/t38passthrough/formats/format_ogg_vorbis.c
    team/oej/t38passthrough/formats/format_pcm.c
    team/oej/t38passthrough/formats/format_sln.c
    team/oej/t38passthrough/formats/format_vox.c
    team/oej/t38passthrough/formats/format_wav.c
    team/oej/t38passthrough/formats/format_wav_gsm.c
    team/oej/t38passthrough/include/asterisk/frame.h
    team/oej/t38passthrough/res/res_config_pgsql.c

Propchange: team/oej/t38passthrough/
------------------------------------------------------------------------------
    automerge = http://edvina.net/training/

Propchange: team/oej/t38passthrough/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Apr 10 00:26:03 2006
@@ -1,1 +1,1 @@
-/trunk:1-18636
+/trunk:1-18749

Modified: team/oej/t38passthrough/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/channels/chan_sip.c?rev=18750&r1=18749&r2=18750&view=diff
==============================================================================
--- team/oej/t38passthrough/channels/chan_sip.c (original)
+++ team/oej/t38passthrough/channels/chan_sip.c Mon Apr 10 00:26:03 2006
@@ -157,6 +157,7 @@
 #define SIP_MAX_LINES 		64			/*!< Max amount of lines in SIP attachment (like SDP) */
 #define SIP_MAX_PACKET		4096	/*!< Also from RFC 3261 (2543), should sub headers tho */
 
+#define	INITIAL_CSEQ		101	/*!< our initial sip sequence number */
 
 static const char desc[] = "Session Initiation Protocol (SIP)";
 static const char config[] = "sip.conf";
@@ -1221,7 +1222,7 @@
 
 	if (localaddr && externip.sin_addr.s_addr &&
 	   ast_apply_ha(localaddr, &theirs)) {
-		if (externexpire && (time(NULL) >= externexpire)) {
+		if (externexpire && time(NULL) >= externexpire) {
 			struct ast_hostent ahp;
 			struct hostent *hp;
 
@@ -1523,9 +1524,9 @@
 /*! \brief Pretend to ack all packets */
 static int __sip_pretend_ack(struct sip_pvt *p)
 {
-	struct sip_pkt *cur=NULL;
-
-	while(p->packets) {
+	struct sip_pkt *cur = NULL;
+
+	while (p->packets) {
 		if (cur == p->packets) {
 			ast_log(LOG_WARNING, "Have a packet that doesn't want to give up! %s\n", sip_methods[cur->method].text);
 			return -1;
@@ -1764,7 +1765,7 @@
 	else
 		speerobjs--;
 	clear_realm_authentication(peer->auth);
-	peer->auth = (struct sip_auth *) NULL;
+	peer->auth = NULL;
 	if (peer->dnsmgr)
 		ast_dnsmgr_release(peer->dnsmgr);
 	free(peer);
@@ -1823,14 +1824,14 @@
 	if (!newpeername) {	/* Did not find peer in realtime */
 		ast_log(LOG_WARNING, "Cannot Determine peer name ip=%s\n", iabuf);
 		ast_variables_destroy(var);
-		return (struct sip_peer *) NULL;
+		return NULL;
 	}
 
 	/* Peer found in realtime, now build it in memory */
 	peer = build_peer(newpeername, var, !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS));
 	if (!peer) {
 		ast_variables_destroy(var);
-		return (struct sip_peer *) NULL;
+		return NULL;
 	}
 
 	if (ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
@@ -1945,11 +1946,9 @@
  * realtime storage (defined in extconfig.conf) */
 static struct sip_user *find_user(const char *name, int realtime)
 {
-	struct sip_user *u = NULL;
-	u = ASTOBJ_CONTAINER_FIND(&userl,name);
-	if (!u && realtime) {
+	struct sip_user *u = ASTOBJ_CONTAINER_FIND(&userl, name);
+	if (!u && realtime)
 		u = realtime_user(name);
-	}
 	return u;
 }
 
@@ -2241,7 +2240,7 @@
 
 	/* Remove link from peer to subscription of MWI */
 	if (p->relatedpeer && p->relatedpeer->mwipvt)
-		p->relatedpeer->mwipvt = (struct sip_pvt *) NULL;
+		p->relatedpeer->mwipvt = NULL;
 
 	if (dumphistory)
 		sip_dump_history(p);
@@ -3366,8 +3365,7 @@
 
 	p->branch = ast_random();	
 	make_our_tag(p->tag, sizeof(p->tag));
-	/* Start with 101 instead of 1 */
-	p->ocseq = 101;
+	p->ocseq = INITIAL_CSEQ;
 
 	if (sip_methods[intended_method].need_rtp) {
 		p->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
@@ -3594,7 +3592,7 @@
 	reg->refresh = default_expiry;
 	reg->portno = porta ? atoi(porta) : 0;
 	reg->callid_valid = FALSE;
-	reg->ocseq = 101;
+	reg->ocseq = INITIAL_CSEQ;
 	ASTOBJ_CONTAINER_LINK(&regl, reg);	/* Add the new registry entry to the list */
 	ASTOBJ_UNREF(reg,sip_registry_destroy);
 	return 0;
@@ -4257,12 +4255,9 @@
 /*! \brief Copy one header field from one request to another */
 static int copy_header(struct sip_request *req, struct sip_request *orig, char *field)
 {
-	char *tmp;
-	tmp = get_header(orig, field);
-	if (!ast_strlen_zero(tmp)) {
-		/* Add what we're responding to */
+	const char *tmp = get_header(orig, field);
+	if (!ast_strlen_zero(tmp)) /* Add what we're responding to */
 		return add_header(req, field, tmp);
-	}
 	ast_log(LOG_NOTICE, "No field '%s' present to copy\n", field);
 	return -1;
 }
@@ -4270,17 +4265,15 @@
 /*! \brief Copy all headers from one request to another */
 static int copy_all_header(struct sip_request *req, struct sip_request *orig, char *field)
 {
-	char *tmp;
 	int start = 0;
 	int copied = 0;
 	for (;;) {
-		tmp = __get_header(orig, field, &start);
-		if (!ast_strlen_zero(tmp)) {
-			/* Add what we're responding to */
-			add_header(req, field, tmp);
-			copied++;
-		} else
+		const char *tmp = __get_header(orig, field, &start);
+		if (ast_strlen_zero(tmp))
 			break;
+		/* Add what we're responding to */
+		add_header(req, field, tmp);
+		copied++;
 	}
 	return copied ? 0 : -1;
 }
@@ -4293,14 +4286,17 @@
 	Received: RFC 3261, rport RFC 3581 */
 static int copy_via_headers(struct sip_pvt *p, struct sip_request *req, struct sip_request *orig, char *field)
 {
-	char tmp[256], *oh, *end;
+	char tmp[256], *end;
 	int start = 0;
 	int copied = 0;
 	char iabuf[INET_ADDRSTRLEN];
 
 	for (;;) {
-		oh = __get_header(orig, field, &start);
-		if (!ast_strlen_zero(oh)) {
+		const char *oh = __get_header(orig, field, &start);
+		if (ast_strlen_zero(oh))
+			break;
+
+			/* XXX reindent next block */
 			if (!copied) {	/* Only check for empty rport in topmost via header */
 				char *rport;
 				char new[256];
@@ -4339,8 +4335,6 @@
 				add_header(req, field, oh);
 			}
 			copied++;
-		} else
-			break;
 	}
 	if (!copied) {
 		ast_log(LOG_NOTICE, "No header field '%s' present to copy\n", field);
@@ -4423,7 +4417,8 @@
 	if (maddr) {
 		maddr += 6;
 		hn = strspn(maddr, "0123456789.") + 1;
-		if (hn > sizeof(hostname)) hn = sizeof(hostname);
+		if (hn > sizeof(hostname))
+			hn = sizeof(hostname);
 		ast_copy_string(hostname, maddr, hn);
 	}
 	
@@ -4582,10 +4577,7 @@
 	add_header(req, "Via", p->via);
 	if (p->route) {
 		set_destination(p, p->route->hop);
-		if (is_strict)
-			add_route(req, p->route->next);
-		else
-			add_route(req, p->route);
+		add_route(req, is_strict ? p->route->next : p->route);
 	}
 
 	ot = get_header(orig, "To");
@@ -4675,9 +4667,8 @@
 {
 	char tmpdat[256];
 	struct tm tm;
-	time_t t;
-
-	time(&t);
+	time_t t = time(NULL);
+
 	gmtime_r(&t, &tm);
 	strftime(tmpdat, sizeof(tmpdat), "%a, %d %b %Y %T GMT", &tm);
 	add_header(req, "Date", tmpdat);
@@ -5602,7 +5593,7 @@
 	add_header(&req, "Allow", ALLOWED_METHODS);
 	if (p->options && p->options->addsipheaders ) {
 		struct ast_channel *ast;
-		struct varshead *headp = (struct varshead *) NULL;
+		struct varshead *headp = NULL;
 		const struct ast_var_t *current;
 
 		ast = p->owner;	/* The owner channel */
@@ -6090,12 +6081,10 @@
 		if (!ast_strlen_zero(r->authuser)) {	
 			ast_string_field_set(p, peername, r->authuser);
 			ast_string_field_set(p, authname, r->authuser);
-		} else {
-			if (!ast_strlen_zero(r->username)) {
-				ast_string_field_set(p, peername, r->username);
-				ast_string_field_set(p, authname, r->username);
-				ast_string_field_set(p, fromuser, r->username);
-			}
+		} else if (!ast_strlen_zero(r->username)) {
+			ast_string_field_set(p, peername, r->username);
+			ast_string_field_set(p, authname, r->username);
+			ast_string_field_set(p, fromuser, r->username);
 		}
 		if (!ast_strlen_zero(r->username))
 			ast_string_field_set(p, username, r->username);
@@ -6236,12 +6225,10 @@
 	} else
 		of += 4;
 	/* Get just the username part */
-	if ((c = strchr(dest, '@'))) {
+	if ((c = strchr(dest, '@')))
 		c = NULL;
-	} else if ((c = strchr(of, '@'))) {
-		*c = '\0';
-		c++;
-	}
+	else if ((c = strchr(of, '@')))
+		*c++ = '\0';
 	if (c) {
 		snprintf(referto, sizeof(referto), "<sip:%s@%s>", dest, c);
 	} else {
@@ -6485,6 +6472,7 @@
 		contact += 4;
 
 	/* Ditch arguments */
+	/* XXX this code is replicated also shortly below */
 	host = strchr(contact, ';');
 	if (host) 
 		*host = '\0';
@@ -6495,13 +6483,11 @@
 		host = contact;
 		c = NULL;
 	} else {
-		*host = '\0';
-		host++;
+		*host++ = '\0';
 	}
 	pt = strchr(host, ':');
 	if (pt) {
-		*pt = '\0';
-		pt++;
+		*pt++ = '\0';
 		port = atoi(pt);
 	} else
 		port = DEFAULT_SIP_PORT;
@@ -6570,9 +6556,8 @@
 	*/
 	if (ast_strlen_zero(c) && ast_strlen_zero(expires)) {
 		/* If we have an active registration, tell them when the registration is going to expire */
-		if ((p->expire > -1) && !ast_strlen_zero(p->fullcontact)) {
+		if (p->expire > -1 && !ast_strlen_zero(p->fullcontact))
 			pvt->expiry = ast_sched_when(sched, p->expire);
-		} 
 		return PARSE_REGISTER_QUERY;
 	} else if (!strcasecmp(c, "*") || !expiry) {	/* Unregister this peer */
 		/* This means remove all registrations and return OK */
@@ -6612,14 +6597,11 @@
 	if (!n) {
 		n = c;
 		c = NULL;
-	} else {
-		*n = '\0';
-		n++;
-	}
+	} else
+		*n++ = '\0';
 	pt = strchr(n, ':');
 	if (pt) {
-		*pt = '\0';
-		pt++;
+		*pt++ = '\0';
 		port = atoi(pt);
 	} else
 		port = DEFAULT_SIP_PORT;
@@ -6651,10 +6633,8 @@
 		expiry = max_expiry;
 	if (expiry < min_expiry)
 		expiry = min_expiry;
-	if (!ast_test_flag(&p->flags[0], SIP_REALTIME))
-		p->expire = ast_sched_add(sched, (expiry + 10) * 1000, expire_register, p);
-	else
-		p->expire = -1;
+	p->expire = ast_test_flag(&p->flags[0], SIP_REALTIME) ? -1 :
+		ast_sched_add(sched, (expiry + 10) * 1000, expire_register, p);
 	pvt->expiry = expiry;
 	snprintf(data, sizeof(data), "%s:%d:%d:%s:%s", ast_inet_ntoa(iabuf, sizeof(iabuf), p->addr.sin_addr), ntohs(p->addr.sin_port), expiry, p->username, p->fullcontact);
 	if (!ast_test_flag(&p->flags[1], SIP_PAGE2_RT_FROMCONTACT)) 
@@ -6726,7 +6706,8 @@
 	p->route_persistant = backwards;
 	
 	/* We build up head, then assign it to p->route when we're done */
-	head = NULL;  tail = head;
+	head = NULL;
+	tail = head;
 	/* 1st we pass through all the hops in any Record-Route headers */
 	for (;;) {
 		/* Each Record-Route header */
@@ -7206,14 +7187,12 @@
 	}
 
 	/* Skip any options */
-	if ((a = strchr(uri, ';'))) {
+	if ((a = strchr(uri, ';')))
 		*a = '\0';
-	}
 
 	/* Get the target domain */
 	if ((a = strchr(uri, '@'))) {
-		*a = '\0';
-		a++;
+		*a++ = '\0';
 		colon = strchr(a, ':'); /* Remove :port */
 		if (colon)
 			*colon = '\0';
@@ -7310,10 +7289,9 @@
 
 	req = outgoing_req;
 
-	if (!req) {
+	if (!req)
 		req = &sip_pvt->initreq;
-	}
-	
+
 	if (!( (p_refer_to = get_header(req, "Refer-To")) && (h_refer_to = ast_strdupa(p_refer_to)) )) {
 		ast_log(LOG_WARNING, "No Refer-To Header That's illegal\n");
 		return -1;
@@ -7419,11 +7397,11 @@
 		ast_string_field_set(sip_pvt, refer_to, refer_to);
 		if (referred_by)
 			ast_string_field_set(sip_pvt, referred_by, referred_by);
-		if (h_contact) {
+		if (h_contact)
 			ast_string_field_set(sip_pvt, refer_contact, h_contact);
-		}
 		sip_pvt->refer_call = NULL;
-		if ((chan = sip_pvt->owner) && (peer = ast_bridged_channel(sip_pvt->owner))) {
+		chan = sip_pvt->owner;
+		if (chan && (peer = ast_bridged_channel(chan)) != NULL) {
 			pbx_builtin_setvar_helper(chan, "BLINDTRANSFER", peer->name);
 			pbx_builtin_setvar_helper(peer, "BLINDTRANSFER", chan->name);
 		}
@@ -7439,16 +7417,13 @@
 static int get_also_info(struct sip_pvt *p, struct sip_request *oreq)
 {
 	char tmp[256], *c, *a;
-	struct sip_request *req;
+	struct sip_request *req = oreq;
 	
-	req = oreq;
 	if (!req)
 		req = &p->initreq;
 	ast_copy_string(tmp, get_header(req, "Also"), sizeof(tmp));
 	
 	c = get_in_brackets(tmp);
-	
-		
 	if (strncmp(c, "sip:", 4)) {
 		ast_log(LOG_WARNING, "Huh?  Not a SIP header (%s)?\n", c);
 		return -1;
@@ -7459,9 +7434,9 @@
 	if ((a = strchr(c, ';'))) 
 		*a = '\0';
 	
-	if (sip_debug_test_pvt(p)) {
+	if (sip_debug_test_pvt(p))
 		ast_verbose("Looking for %s in %s\n", c, p->context);
-	}
+
 	if (ast_exists_extension(NULL, p->context, c, 1, NULL)) {
 		/* This is an unsupervised transfer */
 		if (option_debug)
@@ -7535,7 +7510,7 @@
 	int bytes = 0;
 	int maxbytes = outputsize - 1;
 
-	if (!end || (end == input))
+	if (!end || end == input)
 		return NULL;
 
 	/* move away from "<" */
@@ -7556,17 +7531,15 @@
 		/* clear the empty characters in the begining*/
 		input = ast_skip_blanks(input);
 		/* clear the empty characters in the end */
-		while(*end && (*end < 33) && end > input)
+		while(*end && *end < 33 && end > input)
 			end--;
 		if (end >= input) {
 			bytes = (int) (end - input) + 2;
 			/* protect the output buffer */
-			if (bytes > maxbytes) {
+			if (bytes > maxbytes)
 				bytes = maxbytes;
-			}
 			ast_copy_string(output, input, bytes);
-		}
-		else
+		} else
 			return NULL;
 	}
 	return output;
@@ -7626,7 +7599,7 @@
 
 	/* Terminate URI */
 	t = uri;
-	while(*t && (*t > 32) && (*t != ';'))
+	while (*t && *t > 32 && *t != ';')
 		t++;
 	*t = '\0';
 	of = get_header(req, "From");
@@ -9124,13 +9097,10 @@
 
 	ASTOBJ_CONTAINER_TRAVERSE(&peerl, !result, do {
 		/* locking of the object is not required because only the name and flags are being compared */
-		if (!strncasecmp(word, iterator->name, wordlen)) {
-			if (flags2 && !ast_test_flag(&iterator->flags[1], flags2))
-				continue;
-			if (++which > state) {
-				result = ast_strdup(iterator->name);
-			}
-		}
+		if (!strncasecmp(word, iterator->name, wordlen) &&
+				ast_test_flag(&iterator->flags[1], flags2) &&
+				++which > state)
+			result = ast_strdup(iterator->name);
 	} while(0) );
 	return result;
 }
@@ -9352,7 +9322,6 @@
 	if (!x)
 		ast_log(LOG_DEBUG, "Call '%s' has no history\n", dialog->callid);
 	ast_log(LOG_DEBUG, "\n---------- END SIP HISTORY for '%s' \n", dialog->callid);
-	
 }
 
 
@@ -9464,9 +9433,9 @@
 	if (p)
 		port = atoi(p);
 	hp = ast_gethostbyname(arg, &ahp);
-	if (hp == NULL)  {
+	if (hp == NULL)
 		return RESULT_SHOWUSAGE;
-	}
+
 	debugaddr.sin_family = AF_INET;
 	memcpy(&debugaddr.sin_addr, hp->h_addr, sizeof(debugaddr.sin_addr));
 	debugaddr.sin_port = htons(port);
@@ -9751,7 +9720,7 @@
 	const char *username;
 	const char *secret;
 	const char *md5secret;
-	struct sip_auth *auth = (struct sip_auth *) NULL;	/* Realm authentication */
+	struct sip_auth *auth = NULL;	/* Realm authentication */
 
 	if (!ast_strlen_zero(p->domain))
 		ast_copy_string(uri, p->domain, sizeof(uri));
@@ -11522,17 +11491,14 @@
 					/* Unlock locks so ast_hangup can do its magic */
 					ast_mutex_unlock(&p->lock);
 					c->hangupcause = AST_CAUSE_CALL_REJECTED;
-					ast_hangup(c);
-					ast_mutex_lock(&p->lock);
-					c = NULL;
 				} else {
 					ast_mutex_unlock(&p->lock);
 					ast_setstate(c, AST_STATE_DOWN);
 					c->hangupcause = AST_CAUSE_NORMAL_CLEARING;
-					ast_hangup(c);
-					ast_mutex_lock(&p->lock);
-					c = NULL;
 				}
+				ast_hangup(c);
+				ast_mutex_lock(&p->lock);
+				c = NULL;
 			}
 			break;
 		case AST_STATE_RING:
@@ -12752,8 +12718,7 @@
 	ast_copy_string(tmp, dest, sizeof(tmp));
 	host = strchr(tmp, '@');
 	if (host) {
-		*host = '\0';
-		host++;
+		*host++ = '\0';
 		ext = tmp;
 	} else {
 		ext = strchr(tmp, '/');
@@ -12900,10 +12865,7 @@
 		else if (strcasecmp(v->value, "never"))
 			ast_set_flag(&flags[0], SIP_PROG_INBAND_NO);
   	} else if (!strcasecmp(v->name, "allowguest")) {
-			if (ast_true(v->value)) 
-				global_allowguest = 1;
-			else
-				global_allowguest = 0;
+		global_allowguest = ast_true(v->value) ? 1 : 0;
 	} else if (!strcasecmp(v->name, "promiscredir")) {
 		ast_set_flag(&mask[0], SIP_PROMISCREDIR);
 		ast_set2_flag(&flags[0], ast_true(v->value), SIP_PROMISCREDIR);
@@ -13120,8 +13082,7 @@
 		} else if (!strcasecmp(v->name, "setvar")) {
 			varname = ast_strdupa(v->value);
 			if (varname && (varval = strchr(varname,'='))) {
-				*varval = '\0';
-				varval++;
+				*varval++ = '\0';
 				if ((tmpvar = ast_variable_new(varname, varval))) {
 					tmpvar->next = user->chanvars;
 					user->chanvars = tmpvar;

Modified: team/oej/t38passthrough/doc/CODING-GUIDELINES
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/doc/CODING-GUIDELINES?rev=18750&r1=18749&r2=18750&view=diff
==============================================================================
--- team/oej/t38passthrough/doc/CODING-GUIDELINES (original)
+++ team/oej/t38passthrough/doc/CODING-GUIDELINES Mon Apr 10 00:26:03 2006
@@ -77,7 +77,7 @@
 Roughly, Asterisk code formatting guidelines are generally equivalent to the 
 following:
 
-# indent -i4 -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -ln90 foo.c
+# indent -i4 -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -l90 foo.c
 
 this means in verbose:
  -i4:    indent level 4

Modified: team/oej/t38passthrough/formats/format_g723.c
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/formats/format_g723.c?rev=18750&r1=18749&r2=18750&view=diff
==============================================================================
--- team/oej/t38passthrough/formats/format_g723.c (original)
+++ team/oej/t38passthrough/formats/format_g723.c Mon Apr 10 00:26:03 2006
@@ -76,7 +76,7 @@
 	s->fr.frametype = AST_FRAME_VOICE;
 	s->fr.subclass = AST_FORMAT_G723_1;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, size);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, size);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != size) {
 		ast_log(LOG_WARNING, "Short read (%d of %d bytes) (%s)!\n", res, size, strerror(errno));
 		return NULL;

Modified: team/oej/t38passthrough/formats/format_g726.c
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/formats/format_g726.c?rev=18750&r1=18749&r2=18750&view=diff
==============================================================================
--- team/oej/t38passthrough/formats/format_g726.c (original)
+++ team/oej/t38passthrough/formats/format_g726.c Mon Apr 10 00:26:03 2006
@@ -137,7 +137,7 @@
 	s->fr.frametype = AST_FRAME_VOICE;
 	s->fr.subclass = AST_FORMAT_G726;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, frame_size[fs->rate]);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, frame_size[fs->rate]);
 	s->fr.samples = 8 * FRAME_TIME;
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
 		if (res)

Modified: team/oej/t38passthrough/formats/format_g729.c
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/formats/format_g729.c?rev=18750&r1=18749&r2=18750&view=diff
==============================================================================
--- team/oej/t38passthrough/formats/format_g729.c (original)
+++ team/oej/t38passthrough/formats/format_g729.c Mon Apr 10 00:26:03 2006
@@ -62,7 +62,7 @@
 	s->fr.subclass = AST_FORMAT_G729A;
 	s->fr.mallocd = 0;
 	s->fr.samples = G729A_SAMPLES;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
 		if (res && (res != 10))	/* XXX what for ? */
 			ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));

Modified: team/oej/t38passthrough/formats/format_gsm.c
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/formats/format_gsm.c?rev=18750&r1=18749&r2=18750&view=diff
==============================================================================
--- team/oej/t38passthrough/formats/format_gsm.c (original)
+++ team/oej/t38passthrough/formats/format_gsm.c Mon Apr 10 00:26:03 2006
@@ -67,7 +67,7 @@
 
 	s->fr.frametype = AST_FRAME_VOICE;
 	s->fr.subclass = AST_FORMAT_GSM;
-	FR_SET_BUF(&(s->fr), s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE)
+	AST_FRAME_SET_BUFFER(&(s->fr), s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE)
 	s->fr.mallocd = 0;
 	if ((res = fread(s->fr.data, 1, GSM_FRAME_SIZE, s->f)) != GSM_FRAME_SIZE) {
 		if (res)

Modified: team/oej/t38passthrough/formats/format_h263.c
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/formats/format_h263.c?rev=18750&r1=18749&r2=18750&view=diff
==============================================================================
--- team/oej/t38passthrough/formats/format_h263.c (original)
+++ team/oej/t38passthrough/formats/format_h263.c Mon Apr 10 00:26:03 2006
@@ -88,7 +88,7 @@
 	s->fr.frametype = AST_FRAME_VIDEO;
 	s->fr.subclass = AST_FORMAT_H263;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
 		if (res)
 			ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));

Modified: team/oej/t38passthrough/formats/format_h264.c
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/formats/format_h264.c?rev=18750&r1=18749&r2=18750&view=diff
==============================================================================
--- team/oej/t38passthrough/formats/format_h264.c (original)
+++ team/oej/t38passthrough/formats/format_h264.c Mon Apr 10 00:26:03 2006
@@ -84,7 +84,7 @@
 	s->fr.frametype = AST_FRAME_VIDEO;
 	s->fr.subclass = AST_FORMAT_H264;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
 		if (res)
 			ast_log(LOG_WARNING, "Short read (%d of %d) (%s)!\n", res, len, strerror(errno));

Modified: team/oej/t38passthrough/formats/format_ilbc.c
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/formats/format_ilbc.c?rev=18750&r1=18749&r2=18750&view=diff
==============================================================================
--- team/oej/t38passthrough/formats/format_ilbc.c (original)
+++ team/oej/t38passthrough/formats/format_ilbc.c Mon Apr 10 00:26:03 2006
@@ -60,7 +60,7 @@
 	s->fr.frametype = AST_FRAME_VOICE;
 	s->fr.subclass = AST_FORMAT_ILBC;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, ILBC_BUF_SIZE);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, ILBC_BUF_SIZE);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
 		if (res)
 			ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));

Modified: team/oej/t38passthrough/formats/format_ogg_vorbis.c
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/formats/format_ogg_vorbis.c?rev=18750&r1=18749&r2=18750&view=diff
==============================================================================
--- team/oej/t38passthrough/formats/format_ogg_vorbis.c (original)
+++ team/oej/t38passthrough/formats/format_ogg_vorbis.c Mon Apr 10 00:26:03 2006
@@ -436,7 +436,7 @@
 	fs->fr.frametype = AST_FRAME_VOICE;
 	fs->fr.subclass = AST_FORMAT_SLINEAR;
 	fs->fr.mallocd = 0;
-	FR_SET_BUF(&fs->fr, fs->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
+	AST_FRAME_SET_BUFFER(&fs->fr, fs->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
 
 	while (samples_out != SAMPLES_MAX) {
 		float **pcm;

Modified: team/oej/t38passthrough/formats/format_pcm.c
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/formats/format_pcm.c?rev=18750&r1=18749&r2=18750&view=diff
==============================================================================
--- team/oej/t38passthrough/formats/format_pcm.c (original)
+++ team/oej/t38passthrough/formats/format_pcm.c Mon Apr 10 00:26:03 2006
@@ -95,7 +95,7 @@
 	s->fr.frametype = AST_FRAME_VOICE;
 	s->fr.subclass = s->fmt->format;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) < 1) {
 		if (res)
 			ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));

Modified: team/oej/t38passthrough/formats/format_sln.c
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/formats/format_sln.c?rev=18750&r1=18749&r2=18750&view=diff
==============================================================================
--- team/oej/t38passthrough/formats/format_sln.c (original)
+++ team/oej/t38passthrough/formats/format_sln.c Mon Apr 10 00:26:03 2006
@@ -54,7 +54,7 @@
 	s->fr.frametype = AST_FRAME_VOICE;
 	s->fr.subclass = AST_FORMAT_SLINEAR;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) < 1) {
 		if (res)
 			ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));

Modified: team/oej/t38passthrough/formats/format_vox.c
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/formats/format_vox.c?rev=18750&r1=18749&r2=18750&view=diff
==============================================================================
--- team/oej/t38passthrough/formats/format_vox.c (original)
+++ team/oej/t38passthrough/formats/format_vox.c Mon Apr 10 00:26:03 2006
@@ -56,7 +56,7 @@
 	s->fr.frametype = AST_FRAME_VOICE;
 	s->fr.subclass = AST_FORMAT_ADPCM;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) < 1) {
 		if (res)
 			ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));

Modified: team/oej/t38passthrough/formats/format_wav.c
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/formats/format_wav.c?rev=18750&r1=18749&r2=18750&view=diff
==============================================================================
--- team/oej/t38passthrough/formats/format_wav.c (original)
+++ team/oej/t38passthrough/formats/format_wav.c Mon Apr 10 00:26:03 2006
@@ -369,7 +369,7 @@
 	s->fr.frametype = AST_FRAME_VOICE;
 	s->fr.subclass = AST_FORMAT_SLINEAR;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, bytes);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, bytes);
 	
 	if ( (res = fread(s->fr.data, 1, s->fr.datalen, s->f)) <= 0 ) {
 		if (res)

Modified: team/oej/t38passthrough/formats/format_wav_gsm.c
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/formats/format_wav_gsm.c?rev=18750&r1=18749&r2=18750&view=diff
==============================================================================
--- team/oej/t38passthrough/formats/format_wav_gsm.c (original)
+++ team/oej/t38passthrough/formats/format_wav_gsm.c Mon Apr 10 00:26:03 2006
@@ -379,7 +379,7 @@
 	s->fr.offset = AST_FRIENDLY_OFFSET;
 	s->fr.samples = GSM_SAMPLES;
 	s->fr.mallocd = 0;
-	FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE);
+	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE);
 	if (fs->secondhalf) {
 		/* Just return a frame based on the second GSM frame */
 		s->fr.data = (char *)s->fr.data + GSM_FRAME_SIZE;

Modified: team/oej/t38passthrough/include/asterisk/frame.h
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/include/asterisk/frame.h?rev=18750&r1=18749&r2=18750&view=diff
==============================================================================
--- team/oej/t38passthrough/include/asterisk/frame.h (original)
+++ team/oej/t38passthrough/include/asterisk/frame.h Mon Apr 10 00:26:03 2006
@@ -111,7 +111,15 @@
 	struct ast_frame *next;			
 };
 
-#define	FR_SET_BUF(fr, _base, _ofs, _datalen)	\
+/*!
+ * Set the various field of a frame to point to a buffer.
+ * Typically you set the base address of the buffer, the offset as
+ * AST_FRIENDLY_OFFSET, and the datalen as the amount of bytes queued.
+ * The remaining things (to be done manually) is set the number of
+ * samples, which cannot be derived from the datalen unless you know
+ * the number of bits per sample.
+ */
+#define	AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen)	\
 	{					\
 	(fr)->data = (char *)_base + (_ofs);	\
 	(fr)->offset = (_ofs);			\

Modified: team/oej/t38passthrough/res/res_config_pgsql.c
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/res/res_config_pgsql.c?rev=18750&r1=18749&r2=18750&view=diff
==============================================================================
--- team/oej/t38passthrough/res/res_config_pgsql.c (original)
+++ team/oej/t38passthrough/res/res_config_pgsql.c Mon Apr 10 00:26:03 2006
@@ -24,7 +24,7 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include <libpq-fe.h>	/* PostgreSQL */
+#include <libpq-fe.h>			/* PostgreSQL */
 
 #include "asterisk.h"
 
@@ -44,16 +44,20 @@
 static char *res_config_pgsql_desc = "Postgresql RealTime Configuration Driver";
 
 AST_MUTEX_DEFINE_STATIC(pgsql_lock);
+
 #define RES_CONFIG_PGSQL_CONF "res_pgsql.conf"
-PGconn*         pgsqlConn = NULL;
+
+PGconn *pgsqlConn = NULL;
+
 #define MAX_DB_OPTION_SIZE 64
-static char   dbhost[MAX_DB_OPTION_SIZE]="";
-static char   dbuser[MAX_DB_OPTION_SIZE]="";
-static char   dbpass[MAX_DB_OPTION_SIZE]="";
-static char   dbname[MAX_DB_OPTION_SIZE]="";
-static char   dbsock[MAX_DB_OPTION_SIZE]="";
-static int    dbport=5432;
-static time_t connect_time=0;
+
+static char dbhost[MAX_DB_OPTION_SIZE] = "";
+static char dbuser[MAX_DB_OPTION_SIZE] = "";
+static char dbpass[MAX_DB_OPTION_SIZE] = "";
+static char dbname[MAX_DB_OPTION_SIZE] = "";
+static char dbsock[MAX_DB_OPTION_SIZE] = "";
+static int dbport = 5432;
+static time_t connect_time = 0;
 
 static int parse_config(void);
 static int pgsql_reconnect(const char *database);
@@ -62,12 +66,14 @@
 LOCAL_USER_DECL;
 
 static char cli_realtime_pgsql_status_usage[] =
-"Usage: realtime pgsql status\n"
-"       Shows connection information for the Postgresql RealTime driver\n";
+	"Usage: realtime pgsql status\n"
+	"       Shows connection information for the Postgresql RealTime driver\n";
 
 static struct ast_cli_entry cli_realtime_pgsql_status = {
-        { "realtime", "pgsql", "status", NULL }, realtime_pgsql_status,
-        "Shows connection information for the Postgresql RealTime driver", cli_realtime_pgsql_status_usage, NULL };
+	 { "realtime", "pgsql", "status", NULL }, realtime_pgsql_status,
+	 "Shows connection information for the Postgresql RealTime driver",
+	 cli_realtime_pgsql_status_usage, NULL
+ };
 
 static struct ast_variable *realtime_pgsql(const char *database, const char *table, va_list ap)
 {
@@ -78,9 +84,9 @@
 	char *chunk;
 	char *op;
 	const char *newparam, *newval;
-	struct ast_variable *var=NULL, *prev=NULL;
-
-	if(!table) {
+	struct ast_variable *var = NULL, *prev = NULL;
+
+	if (!table) {
 		ast_log(LOG_WARNING, "Postgresql RealTime: No table specified.\n");
 		return NULL;
 	}
@@ -88,97 +94,102 @@
 	/* Get the first parameter and first value in our list of passed paramater/value pairs */
 	newparam = va_arg(ap, const char *);
 	newval = va_arg(ap, const char *);
-	if(!newparam || !newval)  {
-		ast_log(LOG_WARNING, "Postgresql RealTime: Realtime retrieval requires at least 1 parameter and 1 value to search on.\n");
-		if (pgsqlConn)
-		  {
-		    PQfinish(pgsqlConn);
-		    pgsqlConn=NULL;
-		  };
+	if (!newparam || !newval) {
+		ast_log(LOG_WARNING,
+				"Postgresql RealTime: Realtime retrieval requires at least 1 parameter and 1 value to search on.\n");
+		if (pgsqlConn) {
+			PQfinish(pgsqlConn);
+			pgsqlConn = NULL;
+		};
 		return NULL;
 	}
 
 	/* Create the first part of the query using the first parameter/value pairs we just extracted
 	   If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
-	op = strchr(newparam, ' ')?"":" =";
-
-	snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s '%s'", table, newparam, op, newval);
-	while((newparam = va_arg(ap, const char *))) {
+	op = strchr(newparam, ' ') ? "" : " =";
+
+	snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s '%s'", table, newparam, op,
+			 newval);
+	while ((newparam = va_arg(ap, const char *))) {
 		newval = va_arg(ap, const char *);
-		if(!strchr(newparam, ' ')) op = " ="; else op = "";
-		snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s '%s'", newparam, op, newval);
+		if (!strchr(newparam, ' '))
+			op = " =";
+		else
+			op = "";
+		snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s '%s'", newparam,
+				 op, newval);
 	}
 	va_end(ap);
 
 	/* We now have our complete statement; Lets connect to the server and execute it. */
 	ast_mutex_lock(&pgsql_lock);
-	if(!pgsql_reconnect(database)) {
+	if (!pgsql_reconnect(database)) {
 		ast_mutex_unlock(&pgsql_lock);
 		return NULL;
 	}
-	
-	if(!(result=PQexec(pgsqlConn, sql))) {
-		ast_log(LOG_WARNING, "Postgresql RealTime: Failed to query database. Check debug for more info.\n");
+
+	if (!(result = PQexec(pgsqlConn, sql))) {
+		ast_log(LOG_WARNING,
+				"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
 		ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
-		ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n", PQerrorMessage(pgsqlConn));
+		ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n",
+				PQerrorMessage(pgsqlConn));
 		ast_mutex_unlock(&pgsql_lock);
 		return NULL;
-	}
-	else {
-	  ExecStatusType result_status=PQresultStatus(result);
-	  if (result_status!=PGRES_COMMAND_OK
-	      && result_status!=PGRES_TUPLES_OK
-	      && result_status!=PGRES_NONFATAL_ERROR)
-	    {
-		ast_log(LOG_WARNING, "Postgresql RealTime: Failed to query database. Check debug for more info.\n");
-		ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
-		ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n", 
-			PQresultErrorMessage(result),PQresStatus(result_status));
-		ast_mutex_unlock(&pgsql_lock);
-		return NULL;
-	    }
-	}
-	   
+	} else {
+		ExecStatusType result_status = PQresultStatus(result);
+		if (result_status != PGRES_COMMAND_OK
+			&& result_status != PGRES_TUPLES_OK
+			&& result_status != PGRES_NONFATAL_ERROR) {
+			ast_log(LOG_WARNING,
+					"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
+			ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
+			ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n",
+					PQresultErrorMessage(result), PQresStatus(result_status));
+			ast_mutex_unlock(&pgsql_lock);
+			return NULL;
+		}
+	}
+
 	ast_log(LOG_DEBUG, "1Postgresql RealTime: Result=%p Query: %s\n", result, sql);
 
-	if((num_rows=PQntuples(result))>0) {
-	  int i = 0;
-	  int rowIndex=0;
-	  int numFields = PQnfields(result);
-	  char** fieldnames=NULL;
-
-	  ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows);
-
-	  fieldnames=malloc(numFields*sizeof(char*));
-	  if (!fieldnames) {
-	    /* If I can't alloc memory at this point, why bother doing anything else? */
-	    ast_log(LOG_WARNING, "Out of memory!\n");
-	    ast_mutex_unlock(&pgsql_lock);
-	    PQclear(result);
-	    return NULL;
-	  }
-	  for(i = 0; i < numFields; i++)
-	    fieldnames[i]=PQfname(result,i);
-	  for(rowIndex = 0; rowIndex < num_rows; rowIndex++)
-	      for(i = 0; i < numFields; i++) {
-		stringp = PQgetvalue(result,rowIndex,i);
-		while(stringp) {
-		  chunk = strsep(&stringp, ";");
-		  if(chunk && !ast_strlen_zero(ast_strip(chunk))) {
-		    if(prev) {
-		      prev->next = ast_variable_new(fieldnames[i], chunk);
-		      if (prev->next) {
-			prev = prev->next;
-		      }
-		    } else {
-		      prev = var = ast_variable_new(fieldnames[i], chunk);
-		    }
-		  }
-		}
-	      }
-	  free(fieldnames);
-	} else {                                
-		ast_log(LOG_WARNING, "Postgresql RealTime: Could not find any rows in table %s.\n", table);
+	if ((num_rows = PQntuples(result)) > 0) {
+		int i = 0;
+		int rowIndex = 0;
+		int numFields = PQnfields(result);
+		char **fieldnames = NULL;
+
+		ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows);
+
+		if (!(fieldnames = ast_calloc(1, numFields * sizeof(char *)))) {
+			ast_mutex_unlock(&pgsql_lock);
+			PQclear(result);
+			return NULL;
+		}
+		for (i = 0; i < numFields; i++)
+			fieldnames[i] = PQfname(result, i);
+		for (rowIndex = 0; rowIndex < num_rows; rowIndex++) {
+			for (i = 0; i < numFields; i++) {
+				stringp = PQgetvalue(result, rowIndex, i);
+				while (stringp) {
+					chunk = strsep(&stringp, ";");
+					if (chunk && !ast_strlen_zero(ast_strip(chunk))) {
+						if (prev) {
+							prev->next = ast_variable_new(fieldnames[i], chunk);
+							if (prev->next) {
+								prev = prev->next;
+							}
+						} else {
+							prev = var = ast_variable_new(fieldnames[i], chunk);
+						}
+					}
+				}
+			}
+		}
+		free(fieldnames);
+	} else {
+		ast_log(LOG_WARNING,
+				"Postgresql RealTime: Could not find any rows in table %s.\n", table);
 	}
 
 	ast_mutex_unlock(&pgsql_lock);
@@ -198,55 +209,59 @@
 	char *op;
 	const char *newparam, *newval;
 	struct ast_realloca ra;
-	struct ast_variable *var=NULL;
+	struct ast_variable *var = NULL;
 	struct ast_config *cfg = NULL;
 	struct ast_category *cat = NULL;
 
-	if(!table) {
+	if (!table) {
 		ast_log(LOG_WARNING, "Postgresql RealTime: No table specified.\n");
 		return NULL;
 	}
-	
+
 	memset(&ra, 0, sizeof(ra));
 
-	cfg = ast_config_new();
-	if (!cfg) {
-		/* If I can't alloc memory at this point, why bother doing anything else? */
-		ast_log(LOG_WARNING, "Out of memory!\n");
-		return NULL;
-	}
+	if (!(cfg = ast_config_new()))
+		return NULL;
 
 	/* Get the first parameter and first value in our list of passed paramater/value pairs */
 	newparam = va_arg(ap, const char *);
 	newval = va_arg(ap, const char *);
-	if(!newparam || !newval)  {
-		ast_log(LOG_WARNING, "Postgresql RealTime: Realtime retrieval requires at least 1 parameter and 1 value to search on.\n");
-		if (pgsqlConn)
-		  {
-		    PQfinish(pgsqlConn);
-		    pgsqlConn=NULL;
-		  };
+	if (!newparam || !newval) {
+		ast_log(LOG_WARNING,
+				"Postgresql RealTime: Realtime retrieval requires at least 1 parameter and 1 value to search on.\n");
+		if (pgsqlConn) {
+			PQfinish(pgsqlConn);
+			pgsqlConn = NULL;
+		};
 		return NULL;
 	}
 
 	initfield = ast_strdupa(newparam);
-	if(initfield && (op = strchr(initfield, ' '))) {
+	if (initfield && (op = strchr(initfield, ' '))) {
 		*op = '\0';
 	}
 
 	/* Create the first part of the query using the first parameter/value pairs we just extracted
 	   If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
 
-	if(!strchr(newparam, ' ')) op = " ="; else op = "";
-
-	snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s '%s'", table, newparam, op, newval);
-	while((newparam = va_arg(ap, const char *))) {
+	if (!strchr(newparam, ' '))
+		op = " =";
+	else
+		op = "";
+
+	snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s '%s'", table, newparam, op,
+			 newval);
+	while ((newparam = va_arg(ap, const char *))) {
 		newval = va_arg(ap, const char *);

[... 777 lines stripped ...]


More information about the asterisk-commits mailing list