[771] in BarnOwl Developers
[D-O-H] r776 - branches/barnowl_unicode/owl
daemon@ATHENA.MIT.EDU (asedeno@MIT.EDU)
Thu Oct 29 18:09:32 2009
Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: asedeno@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Sun, 23 Dec 2007 19:48:02 -0500 (EST)
Author: asedeno
Date: 2007-12-23 19:48:01 -0500 (Sun, 23 Dec 2007)
New Revision: 776
Modified:
branches/barnowl_unicode/owl/aim.c
branches/barnowl_unicode/owl/cmd.c
branches/barnowl_unicode/owl/configure.in
branches/barnowl_unicode/owl/functions.c
branches/barnowl_unicode/owl/global.c
branches/barnowl_unicode/owl/message.c
branches/barnowl_unicode/owl/owl.c
branches/barnowl_unicode/owl/owl.h
branches/barnowl_unicode/owl/text.c
branches/barnowl_unicode/owl/util.c
branches/barnowl_unicode/owl/zcrypt.c
branches/barnowl_unicode/owl/zwrite.c
Log:
GLib/Unicode branch - adding glib dependency.
Linking BarnOwl to GLib.
Cleaning up some malloc/realloc/strdup/free code, moving to owl_*
functions for each.
Changing to GLib memory allocation functions.
Modified: branches/barnowl_unicode/owl/aim.c
===================================================================
--- branches/barnowl_unicode/owl/aim.c 2007-12-23 20:16:29 UTC (rev 775)
+++ branches/barnowl_unicode/owl/aim.c 2007-12-24 00:48:01 UTC (rev 776)
@@ -947,13 +947,13 @@
return -1;
if (modname) {
- if (!(filename = malloc(strlen(priv->aimbinarypath)+1+strlen(modname)+4+1))) {
+ if (!(filename = owl_malloc(strlen(priv->aimbinarypath)+1+strlen(modname)+4+1))) {
/* perror("memrequest: malloc"); */
return -1;
}
sprintf(filename, "%s/%s.ocm", priv->aimbinarypath, modname);
} else {
- if (!(filename = malloc(strlen(priv->aimbinarypath)+1+strlen(defaultmod)+1))) {
+ if (!(filename = owl_malloc(strlen(priv->aimbinarypath)+1+strlen(defaultmod)+1))) {
/* perror("memrequest: malloc"); */
return -1;
}
@@ -963,7 +963,7 @@
if (stat(filename, &st) == -1) {
if (!modname) {
/* perror("memrequest: stat"); */
- free(filename);
+ owl_free(filename);
return -1;
}
invalid = 1;
@@ -985,14 +985,14 @@
if (invalid) {
int i;
- free(filename); /* not needed */
+ owl_free(filename); /* not needed */
owl_function_error("getaimdata memrequest: recieved invalid request for 0x%08lx bytes at 0x%08lx (file %s)\n", len, offset, modname);
i = 8;
if (modname) {
i+=strlen(modname);
}
- if (!(buf = malloc(i))) {
+ if (!(buf = owl_malloc(i))) {
return -1;
}
@@ -1016,31 +1016,31 @@
*bufret = buf;
*buflenret = i;
} else {
- if (!(buf = malloc(len))) {
- free(filename);
+ if (!(buf = owl_malloc(len))) {
+ owl_free(filename);
return -1;
}
/* printf("memrequest: loading %ld bytes from 0x%08lx in \"%s\"...\n", len, offset, filename); */
if (!(f = fopen(filename, "r"))) {
/* perror("memrequest: fopen"); */
- free(filename);
- free(buf);
+ owl_free(filename);
+ owl_free(buf);
return -1;
}
- free(filename);
+ owl_free(filename);
if (fseek(f, offset, SEEK_SET) == -1) {
/* perror("memrequest: fseek"); */
fclose(f);
- free(buf);
+ owl_free(buf);
return -1;
}
if (fread(buf, len, 1, f) != 1) {
/* perror("memrequest: fread"); */
fclose(f);
- free(buf);
+ owl_free(buf);
return -1;
}
@@ -1075,7 +1075,7 @@
if (priv->aimbinarypath && (getaimdata(sess, &buf, &buflen, offset, len, modname) == 0)) {
aim_sendmemblock(sess, fr->conn, offset, buflen, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST);
- free(buf);
+ owl_free(buf);
} else {
owl_function_debugmsg("faimtest_memrequest: unable to use AIM binary (\"%s/%s\"), sending defaults...\n", priv->aimbinarypath, modname);
aim_sendmemblock(sess, fr->conn, offset, len, NULL, AIM_SENDMEMBLOCK_FLAG_ISREQUEST);
@@ -1341,12 +1341,12 @@
char *newbuf;
int z;
- newbuf = malloc(i+1);
+ newbuf = owl_malloc(i+1);
for (z = 0; z < i; z++)
newbuf[z] = (z % 10)+0x30;
newbuf[i] = '\0';
/* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_ACK | AIM_IMFLAGS_AWAY, newbuf); */
- free(newbuf);
+ owl_free(newbuf);
}
} else if (strstr(tmpstr, "seticqstatus")) {
aim_setextstatus(sess, AIM_ICQ_STATE_DND);
Modified: branches/barnowl_unicode/owl/cmd.c
===================================================================
--- branches/barnowl_unicode/owl/cmd.c 2007-12-23 20:16:29 UTC (rev 775)
+++ branches/barnowl_unicode/owl/cmd.c 2007-12-24 00:48:01 UTC (rev 776)
@@ -73,7 +73,7 @@
char *retval = NULL;
owl_cmd *cmd;
- tmpbuff=strdup(cmdbuff);
+ tmpbuff=owl_strdup(cmdbuff);
argv=owl_parseline(tmpbuff, &argc);
if (argc < 0) {
owl_free(tmpbuff);
Modified: branches/barnowl_unicode/owl/configure.in
===================================================================
--- branches/barnowl_unicode/owl/configure.in 2007-12-23 20:16:29 UTC (rev 775)
+++ branches/barnowl_unicode/owl/configure.in 2007-12-24 00:48:01 UTC (rev 776)
@@ -11,6 +11,8 @@
CFLAGS="$CFLAGS -Wall -g";
fi
+dnl m4_include(/usr/share/aclocal/pkg.m4)
+m4_include(pkg.m4)
dnl Check for Athena
AC_MSG_CHECKING(for /usr/athena/include)
@@ -104,6 +106,15 @@
echo Adding perl LDFLAGS ${FOO}
LDFLAGS=${LDFLAGS}\ ${FOO}
+dnl Add CFLAGS and LDFLAGS for glib-2.0
+PKG_CHECK_MODULES(GLIB,glib-2.0)
+
+echo Adding glib-2.0 CFLAGS ${GLIB_CFLAGS}
+CFLAGS=${CFLAGS}\ ${GLIB_CFLAGS}
+echo Adding glib-2.0 LDFLAGS ${GLIB_LIBS}
+LDFLAGS=${LDFLAGS}\ ${GLIB_LIBS}
+
+
dnl Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_FILE(/usr/share/terminfo, AC_DEFINE(TERMINFO, "/usr/share/terminfo", [Have terminfo]),
AC_CHECK_FILE(/usr/share/lib/terminfo, AC_DEFINE(TERMINFO, "/usr/share/lib/terminfo", [Have terminfo]),
Modified: branches/barnowl_unicode/owl/functions.c
===================================================================
--- branches/barnowl_unicode/owl/functions.c 2007-12-23 20:16:29 UTC (rev 775)
+++ branches/barnowl_unicode/owl/functions.c 2007-12-24 00:48:01 UTC (rev 776)
@@ -3024,8 +3024,8 @@
fl=owl_global_get_puntlist(&g);
/* first, create the filter */
- f=malloc(sizeof(owl_filter));
- buff=malloc(strlen(class)+strlen(inst)+strlen(recip)+100);
+ f=owl_malloc(sizeof(owl_filter));
+ buff=owl_malloc(strlen(class)+strlen(inst)+strlen(recip)+100);
strcpy(buff, "class");
if (!strcmp(class, "*")) {
strcat(buff, " .*");
@@ -3313,7 +3313,7 @@
ret=ZGetLocations(location, &numlocs);
if (ret==0) {
for (x=0; x<numlocs; x++) {
- line=malloc(strlen(location[x].host)+strlen(location[x].time)+strlen(location[x].tty)+100);
+ line=owl_malloc(strlen(location[x].host)+strlen(location[x].time)+strlen(location[x].tty)+100);
tmp=short_zuser(user);
sprintf(line, " %-10.10s %-24.24s %-12.12s %20.20s\n",
tmp,
@@ -3419,7 +3419,7 @@
if (myargc <= 0) {
_exit(127);
}
- parsed=realloc(parsed, sizeof(*parsed) * (myargc+1));
+ parsed=owl_realloc(parsed, sizeof(*parsed) * (myargc+1));
parsed[myargc] = NULL;
owl_function_debugmsg("About to exec \"%s\" with %d arguments", parsed[0], myargc);
Modified: branches/barnowl_unicode/owl/global.c
===================================================================
--- branches/barnowl_unicode/owl/global.c 2007-12-23 20:16:29 UTC (rev 775)
+++ branches/barnowl_unicode/owl/global.c 2007-12-24 00:48:01 UTC (rev 776)
@@ -517,7 +517,7 @@
for (i=0; i<argc; i++) {
len+=strlen(argv[i])+5;
}
- g->startupargs=malloc(len+5);
+ g->startupargs=owl_malloc(len+5);
strcpy(g->startupargs, "");
for (i=0; i<argc; i++) {
Modified: branches/barnowl_unicode/owl/message.c
===================================================================
--- branches/barnowl_unicode/owl/message.c 2007-12-23 20:16:29 UTC (rev 775)
+++ branches/barnowl_unicode/owl/message.c 2007-12-24 00:48:01 UTC (rev 776)
@@ -486,7 +486,7 @@
void owl_message_set_zwriteline(owl_message *m, char *line)
{
if(m->zwriteline) owl_free(m->zwriteline);
- m->zwriteline=strdup(line);
+ m->zwriteline=owl_strdup(line);
}
int owl_message_is_delete(owl_message *m)
@@ -881,7 +881,7 @@
owl_message_set_attribute(m, "isauto", "");
}
- m->zwriteline=strdup("");
+ m->zwriteline=owl_strdup("");
/* save the hostname */
owl_function_debugmsg("About to do gethostbyaddr");
@@ -963,7 +963,7 @@
owl_message_set_realm(m, owl_zephyr_get_realm());
}
- m->zwriteline=strdup("");
+ m->zwriteline=owl_strdup("");
owl_message_set_body(m, "<uninitialized>");
Modified: branches/barnowl_unicode/owl/owl.c
===================================================================
--- branches/barnowl_unicode/owl/owl.c 2007-12-23 20:16:29 UTC (rev 775)
+++ branches/barnowl_unicode/owl/owl.c 2007-12-24 00:48:01 UTC (rev 776)
@@ -47,6 +47,7 @@
#include <sys/types.h>
#include <termios.h>
#include <sys/stat.h>
+#include <locale.h>
#include "owl.h"
#if OWL_STDERR_REDIR
@@ -89,6 +90,9 @@
tty=NULL;
debug=0;
initialsubs=1;
+
+ setlocale(LC_ALL, "");
+
if (argc>0) {
argv++;
argc--;
Modified: branches/barnowl_unicode/owl/owl.h
===================================================================
--- branches/barnowl_unicode/owl/owl.h 2007-12-23 20:16:29 UTC (rev 775)
+++ branches/barnowl_unicode/owl/owl.h 2007-12-24 00:48:01 UTC (rev 776)
@@ -52,6 +52,7 @@
#include <termios.h>
#include <libfaim/aim.h>
#include "config.h"
+#include "glib.h"
#ifdef HAVE_LIBZEPHYR
#include <zephyr/zephyr.h>
#endif
Modified: branches/barnowl_unicode/owl/text.c
===================================================================
--- branches/barnowl_unicode/owl/text.c 2007-12-23 20:16:29 UTC (rev 775)
+++ branches/barnowl_unicode/owl/text.c 2007-12-24 00:48:01 UTC (rev 776)
@@ -326,7 +326,7 @@
outlen = strlen(in)+1;
tolen = strlen(to);
fromlen = strlen(from);
- out = malloc(outlen);
+ out = owl_malloc(outlen);
while (in[inpos]) {
if (!strncmp(in+inpos, from, fromlen)) {
Modified: branches/barnowl_unicode/owl/util.c
===================================================================
--- branches/barnowl_unicode/owl/util.c 2007-12-23 20:16:29 UTC (rev 775)
+++ branches/barnowl_unicode/owl/util.c 2007-12-24 00:48:01 UTC (rev 776)
@@ -445,22 +445,22 @@
void *owl_malloc(size_t size)
{
- return(malloc(size));
+ return(g_malloc(size));
}
void owl_free(void *ptr)
{
- free(ptr);
+ g_free(ptr);
}
char *owl_strdup(const char *s1)
{
- return(strdup(s1));
+ return(g_strdup(s1));
}
void *owl_realloc(void *ptr, size_t size)
{
- return(realloc(ptr, size));
+ return(g_realloc(ptr, size));
}
/* allocates memory and returns the string or null.
Modified: branches/barnowl_unicode/owl/zcrypt.c
===================================================================
--- branches/barnowl_unicode/owl/zcrypt.c 2007-12-23 20:16:29 UTC (rev 775)
+++ branches/barnowl_unicode/owl/zcrypt.c 2007-12-24 00:48:01 UTC (rev 776)
@@ -384,7 +384,7 @@
}
/* Build a space-separated string from argv from elements between start *
- * and end - 1. malloc()'s the returned string. */
+ * and end - 1. owl_malloc()'s the returned string. */
char *BuildArgString(char **argv, int start, int end) {
int len = 1;
int i;
@@ -396,7 +396,7 @@
}
/* Allocate memory */
- result = (char *)malloc(len);
+ result = (char *)owl_malloc(len);
if (result) {
/* Build the string */
char *ptr = result;
@@ -481,7 +481,7 @@
} else {
/* Prepare result to be returned */
char *temp = keyfile;
- keyfile = (char *)malloc(strlen(temp) + 1);
+ keyfile = (char *)owl_malloc(strlen(temp) + 1);
if (keyfile) {
strcpy(keyfile, temp);
} else {
@@ -610,7 +610,7 @@
printf("Type your message now. End with control-D or a dot on a line by itself.\n");
}
use_buffer = TRUE;
- if ((inptr = inbuff = (char *)malloc(MAX_RESULT)) == NULL) {
+ if ((inptr = inbuff = (char *)owl_malloc(MAX_RESULT)) == NULL) {
printf("Memory allocation error\n");
return FALSE;
}
@@ -638,7 +638,7 @@
if (!outfile) {
printf("Could not run zwrite\n");
if (freein && inbuff) {
- free(inbuff);
+ owl_free(inbuff);
}
return(FALSE);
}
@@ -684,7 +684,7 @@
if (zephyr) CloseZephyrPipe(outfile);
/* Free the input buffer, if necessary */
- if (freein && inbuff) free(inbuff);
+ if (freein && inbuff) owl_free(inbuff);
return(!error);
}
Modified: branches/barnowl_unicode/owl/zwrite.c
===================================================================
--- branches/barnowl_unicode/owl/zwrite.c 2007-12-23 20:16:29 UTC (rev 775)
+++ branches/barnowl_unicode/owl/zwrite.c 2007-12-24 00:48:01 UTC (rev 776)
@@ -94,7 +94,7 @@
myargc--;
z->message=owl_strdup("");
while (myargc) {
- z->message=realloc(z->message, strlen(z->message)+strlen(myargv[0])+5);
+ z->message=owl_realloc(z->message, strlen(z->message)+strlen(myargv[0])+5);
strcat(z->message, myargv[0]);
strcat(z->message, " ");
myargc--;
@@ -112,7 +112,7 @@
myargc--;
} else {
/* anything unattached is a recipient */
- owl_list_append_element(&(z->recips), strdup(myargv[0]));
+ owl_list_append_element(&(z->recips), owl_strdup(myargv[0]));
myargv++;
myargc--;
}
@@ -176,7 +176,7 @@
} else if (zsigzvar) {
z->zsig=owl_strdup(zsigzvar);
} else if (((pw=getpwuid(getuid()))!=NULL) && (pw->pw_gecos)) {
- z->zsig=strdup(pw->pw_gecos);
+ z->zsig=owl_strdup(pw->pw_gecos);
ptr=strchr(z->zsig, ',');
if (ptr) {
ptr[0]='\0';