[xiph-cvs] cvs commit: libshout/src shout.c util.c util.h vorbis.c

Brendan brendan at xiph.org
Sun Jul 6 09:25:44 PDT 2003



brendan     03/07/06 12:25:44

  Modified:    src      shout.c util.c util.h vorbis.c
  Log:
  remove util.c functions from the global namespace (prefix with _shout_)
  
  1. There has got to be a better way. #including C files? no, gross.
  2. Thank god for tags-query-replace

Revision  Changes    Path
1.45      +21 -21    libshout/src/shout.c

Index: shout.c
===================================================================
RCS file: /usr/local/cvsroot/libshout/src/shout.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -p -u -r1.44 -r1.45
--- shout.c	5 Jul 2003 04:41:10 -0000	1.44
+++ shout.c	6 Jul 2003 16:25:44 -0000	1.45
@@ -74,7 +74,7 @@ shout_t *shout_new(void)
 
                 return NULL;
         }
-	if (!(self->audio_info = util_dict_new())) {
+	if (!(self->audio_info = _shout_util_dict_new())) {
                 shout_free(self);
 
                 return NULL;
@@ -100,7 +100,7 @@ void shout_free(shout_t *self)
         if (self->description) free(self->description);
         if (self->user) free(self->user);
         if (self->useragent) free(self->useragent);
-	if (self->audio_info) util_dict_free (self->audio_info);
+	if (self->audio_info) _shout_util_dict_free (self->audio_info);
 
         free(self);
 }
@@ -258,7 +258,7 @@ int shout_delay(shout_t *self)
   
 shout_metadata_t *shout_metadata_new(void)
 {
-	return util_dict_new();
+	return _shout_util_dict_new();
 }
 
 void shout_metadata_free(shout_metadata_t *self)
@@ -266,7 +266,7 @@ void shout_metadata_free(shout_metadata_
         if (!self)
                 return;
 
-	util_dict_free(self);
+	_shout_util_dict_free(self);
 }
 
 int shout_metadata_add(shout_metadata_t *self, const char *name, const char *value)
@@ -274,7 +274,7 @@ int shout_metadata_add(shout_metadata_t 
         if (!self || !name)
                 return SHOUTERR_INSANE;
 
-	return util_dict_set(self, name, value);
+	return _shout_util_dict_set(self, name, value);
 }
 
 /* open second socket to server, send HTTP request to change metadata.
@@ -288,7 +288,7 @@ int shout_set_metadata(shout_t *self, sh
         if (!self || !metadata)
                 return SHOUTERR_INSANE;
 
-	if (!(encvalue = util_dict_urlencode(metadata, '&')))
+	if (!(encvalue = _shout_util_dict_urlencode(metadata, '&')))
                 return SHOUTERR_MALLOC;
 
         if (!self->connected)
@@ -384,7 +384,7 @@ int shout_set_host(shout_t *self, const 
         if (self->host)
                 free(self->host);
 
-	if (!(self->host = util_strdup(host)))
+	if (!(self->host = _shout_util_strdup(host)))
                 return self->error = SHOUTERR_MALLOC;
 
         return self->error = SHOUTERR_SUCCESS;
@@ -430,7 +430,7 @@ int shout_set_password(shout_t *self, co
         if (self->password)
                 free (self->password);
 
-	if (!(self->password = util_strdup(password)))
+	if (!(self->password = _shout_util_strdup(password)))
                 return self->error = SHOUTERR_MALLOC;
 
         return self->error = SHOUTERR_SUCCESS;
@@ -488,7 +488,7 @@ int shout_set_name(shout_t *self, const 
         if (self->name)
                 free(self->name);
 
-	if (!(self->name = util_strdup(name)))
+	if (!(self->name = _shout_util_strdup(name)))
                 return self->error = SHOUTERR_MALLOC;
 
         return self->error = SHOUTERR_SUCCESS;
@@ -513,7 +513,7 @@ int shout_set_url(shout_t *self, const c
         if (self->url)
                 free(self->url);
 
-	if (!(self->url = util_strdup(url)))
+	if (!(self->url = _shout_util_strdup(url)))
                 return self->error = SHOUTERR_MALLOC;
 
         return self->error = SHOUTERR_SUCCESS;
@@ -538,7 +538,7 @@ int shout_set_genre(shout_t *self, const
         if (self->genre)
                 free(self->genre);
 
-	if (! (self->genre = util_strdup (genre)))
+	if (! (self->genre = _shout_util_strdup (genre)))
                 return self->error = SHOUTERR_MALLOC;
 
         return self->error = SHOUTERR_SUCCESS;
@@ -563,7 +563,7 @@ int shout_set_agent(shout_t *self, const
         if (self->useragent)
                 free(self->useragent);
 
-	if (! (self->useragent = util_strdup (agent)))
+	if (! (self->useragent = _shout_util_strdup (agent)))
                 return self->error = SHOUTERR_MALLOC;
 
         return self->error = SHOUTERR_SUCCESS;
@@ -589,7 +589,7 @@ int shout_set_user(shout_t *self, const 
         if (self->user)
                 free(self->user);
 
-	if (! (self->user = util_strdup (username)))
+	if (! (self->user = _shout_util_strdup (username)))
                 return self->error = SHOUTERR_MALLOC;
 
         return self->error = SHOUTERR_SUCCESS;
@@ -614,7 +614,7 @@ int shout_set_description(shout_t *self,
         if (self->description)
                 free(self->description);
 
-	if (! (self->description = util_strdup (description)))
+	if (! (self->description = _shout_util_strdup (description)))
                 return self->error = SHOUTERR_MALLOC;
 
         return self->error = SHOUTERR_SUCCESS;
@@ -639,7 +639,7 @@ int shout_set_dumpfile(shout_t *self, co
         if (self->dumpfile)
                 free(self->dumpfile);
 
-	if (! (self->dumpfile = util_strdup (dumpfile)))
+	if (! (self->dumpfile = _shout_util_strdup (dumpfile)))
                 return self->error = SHOUTERR_MALLOC;
 
         return self->error = SHOUTERR_SUCCESS;
@@ -655,12 +655,12 @@ const char *shout_get_dumpfile(shout_t *
 
 int shout_set_audio_info(shout_t *self, const char *name, const char *value)
 {
-	return self->error = util_dict_set(self->audio_info, name, value);
+	return self->error = _shout_util_dict_set(self->audio_info, name, value);
 }
 
 const char *shout_get_audio_info(shout_t *self, const char *name)
 {
-	return util_dict_get(self->audio_info, name);
+	return _shout_util_dict_get(self->audio_info, name);
 }
 
 int shout_set_public(shout_t *self, unsigned int public)
@@ -768,7 +768,7 @@ static int send_http_request(shout_t *se
         if (bitrate && !sock_write(self->socket, "ice-bitrate: %s\r\n", bitrate))
                 return SHOUTERR_SOCKET;
 #else
-	if ((ai = util_dict_urlencode(self->audio_info, ';'))) {
+	if ((ai = _shout_util_dict_urlencode(self->audio_info, ';'))) {
                 if (!sock_write(self->socket, "ice-audio-info: %s\r\n", ai)) {
                         free(ai);
                         return SHOUTERR_SOCKET;
@@ -811,7 +811,7 @@ char *http_basic_authorization(shout_t *
         if (!(in = malloc(len)))
                 return NULL;
         sprintf(in, "%s:%s", self->user, self->password);
-	out = util_base64_encode(in);
+	out = _shout_util_base64_encode(in);
         free(in);
 
         len = strlen(out) + 24;
@@ -851,7 +851,7 @@ static int login_http_basic(shout_t *sel
                 return self->error = SHOUTERR_SOCKET;
         }
 
-	if (util_read_header(self->socket, header, 4096) == 0) {
+	if (_shout_util_read_header(self->socket, header, 4096) == 0) {
                 /* either we didn't get a complete header, or we timed out */
                 return self->error = SHOUTERR_SOCKET;
         }
@@ -884,7 +884,7 @@ static int login_http_basic(shout_t *sel
                                         return self->error = SHOUTERR_SOCKET;
                                 }
 
-				if (util_read_header(self->socket, header, 4096) == 0) {
+				if (_shout_util_read_header(self->socket, header, 4096) == 0) {
                                         /* either we didn't get a complete header, or we timed out */
                                         sock_close(self->socket);
                                         return self->error = SHOUTERR_SOCKET;

<p><p>1.17      +13 -14    libshout/src/util.c

Index: util.c
===================================================================
RCS file: /usr/local/cvsroot/libshout/src/util.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -p -u -r1.16 -r1.17
--- util.c	13 Mar 2003 14:01:18 -0000	1.16
+++ util.c	6 Jul 2003 16:25:44 -0000	1.17
@@ -14,7 +14,7 @@
 #include <shout/shout.h>
 #include "util.h"
 
-char *util_strdup(const char *s)
+char *_shout_util_strdup(const char *s)
 {
         if (!s)
                 return NULL;
@@ -22,7 +22,7 @@ char *util_strdup(const char *s)
         return strdup(s);
 }
 
-int util_read_header(int sock, char *buff, unsigned long len)
+int _shout_util_read_header(int sock, char *buff, unsigned long len)
 {
         int read_bytes, ret;
         unsigned long pos;
@@ -60,7 +60,7 @@ static char base64table[65] = {
 };
 
 /* This isn't efficient, but it doesn't need to be */
-char *util_base64_encode(char *data)
+char *_shout_util_base64_encode(char *data)
 {
         int len = strlen(data);
         char *out = malloc(len*4/3 + 4);
@@ -119,7 +119,7 @@ static char safechars[256] = {
 
 /* modified from libshout1, which credits Rick Franchuk <rickf at transpect.net>.
  * Caller must free result. */
-char *util_url_encode(const char *data) {
+char *_shout_util_url_encode(const char *data) {
         const char *p;
         char *q, *dest;
         int digit;
@@ -150,12 +150,12 @@ char *util_url_encode(const char *data) 
         return dest;
 }
 
-util_dict *util_dict_new(void)
+util_dict *_shout_util_dict_new(void)
 {
         return (util_dict *)calloc(1, sizeof(util_dict));
 }
 
-void util_dict_free(util_dict *dict)
+void _shout_util_dict_free(util_dict *dict)
 {
         util_dict *next;
 
@@ -172,7 +172,7 @@ void util_dict_free(util_dict *dict)
         }
 }
 
-const char *util_dict_get(util_dict *dict, const char *key)
+const char *_shout_util_dict_get(util_dict *dict, const char *key)
 {
         while (dict) {
                 if (dict->key && !strcmp(key, dict->key))
@@ -183,7 +183,7 @@ const char *util_dict_get(util_dict *dic
         return NULL;
 }
 
-int util_dict_set(util_dict *dict, const char *key, const char *val)
+int _shout_util_dict_set(util_dict *dict, const char *key, const char *val)
 {
         util_dict *prev;
 
@@ -199,7 +199,7 @@ int util_dict_set(util_dict *dict, const
         }
 
         if (!dict) {
-		dict = util_dict_new();
+		dict = _shout_util_dict_new();
                 if (!dict)
                         return SHOUTERR_MALLOC;
                 if (prev)
@@ -211,7 +211,7 @@ int util_dict_set(util_dict *dict, const
         else if (!(dict->key = strdup(key))) {
                 if (prev)
                         prev->next = NULL;
-		util_dict_free (dict);
+		_shout_util_dict_free (dict);
 
                 return SHOUTERR_MALLOC;
         }
@@ -227,7 +227,7 @@ int util_dict_set(util_dict *dict, const
 /* given a dictionary, URL-encode each key and val and stringify them in order as
   key=val&key=val... if val is set, or just key&key if val is NULL.
   TODO: Memory management needs overhaul. */
-char *util_dict_urlencode(util_dict *dict, char delim)
+char *_shout_util_dict_urlencode(util_dict *dict, char delim)
 {
         char *res, *tmp;
         char *enc;
@@ -237,7 +237,7 @@ char *util_dict_urlencode(util_dict *dic
                 /* encode key */
                 if (!dict->key)
                         continue;
-		if (!(enc = util_url_encode(dict->key))) {
+		if (!(enc = _shout_util_url_encode(dict->key))) {
                         if (res)
                                 free(res);
                         return NULL;
@@ -264,7 +264,7 @@ char *util_dict_urlencode(util_dict *dic
                 /* encode value */
                 if (!dict->val)
                         continue;
-		if (!(enc = util_url_encode(dict->val))) {
+		if (!(enc = _shout_util_url_encode(dict->val))) {
                         free(res);
                         return NULL;
                 }
@@ -281,4 +281,3 @@ char *util_dict_urlencode(util_dict *dic
 
         return res;
 }
-

<p><p>1.8       +9 -9      libshout/src/util.h

Index: util.h
===================================================================
RCS file: /usr/local/cvsroot/libshout/src/util.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -p -u -r1.7 -r1.8
--- util.h	23 Feb 2003 00:11:32 -0000	1.7
+++ util.h	6 Jul 2003 16:25:44 -0000	1.8
@@ -11,17 +11,17 @@ typedef struct _util_dict {
   struct _util_dict *next;
 } util_dict;
 
-char *util_strdup(const char *s);
+char *_shout_util_strdup(const char *s);
 
-util_dict *util_dict_new(void);
-void util_dict_free(util_dict *dict);
+util_dict *_shout_util_dict_new(void);
+void _shout_util_dict_free(util_dict *dict);
 /* dict, key must not be NULL. */
-int util_dict_set(util_dict *dict, const char *key, const char *val);
-const char *util_dict_get(util_dict *dict, const char *key);
-char *util_dict_urlencode(util_dict *dict, char delim);
+int _shout_util_dict_set(util_dict *dict, const char *key, const char *val);
+const char *_shout_util_dict_get(util_dict *dict, const char *key);
+char *_shout_util_dict_urlencode(util_dict *dict, char delim);
 
-char *util_base64_encode(char *data);
-char *util_url_encode(const char *data);
-int util_read_header(int sock, char *buff, unsigned long len);
+char *_shout_util_base64_encode(char *data);
+char *_shout_util_url_encode(const char *data);
+int _shout_util_read_header(int sock, char *buff, unsigned long len);
 
 #endif /* __LIBSHOUT_UTIL_H__ */

<p><p>1.9       +1 -1      libshout/src/vorbis.c

Index: vorbis.c
===================================================================
RCS file: /usr/local/cvsroot/libshout/src/vorbis.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -p -u -r1.8 -r1.9
--- vorbis.c	17 May 2003 13:58:09 -0000	1.8
+++ vorbis.c	6 Jul 2003 16:25:44 -0000	1.9
@@ -97,7 +97,7 @@ static int send_vorbis(shout_t *self, co
                         vorbis_info_init(&vorbis_data->vi);
                         vorbis_comment_init(&vorbis_data->vc);
 
-            vorbis_data->initialised = 1;
+			vorbis_data->initialised = 1;
 
                         vorbis_data->headers = 1;
                 }

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list