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

Brendan brendan at xiph.org
Wed Jul 2 09:39:52 PDT 2003



brendan     03/07/02 12:39:52

  Modified:    examples example.c
               include/shout shout.h
               src      shout.c
  Log:
  shout_init(), shout_shutdown() added (noone had any better ideas)
  shout_new calls shout_init just in case.

Revision  Changes    Path
1.5       +4 -0      libshout/examples/example.c

Index: example.c
===================================================================
RCS file: /usr/local/cvsroot/libshout/examples/example.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -p -u -r1.4 -r1.5
--- example.c	12 Jan 2003 21:51:49 -0000	1.4
+++ example.c	2 Jul 2003 16:39:51 -0000	1.5
@@ -12,6 +12,8 @@ int main()
         char buff[4096];
         long read, ret, total;
 
+	shout_init();
+
         if (!(shout = shout_new())) {
                 printf("Could not allocate shout_t\n");
                 return 1;
@@ -75,6 +77,8 @@ int main()
         }
 
         shout_close(shout);
+
+	shout_shutdown();
 
         return 0;
 }

<p><p>1.20      +7 -0      libshout/include/shout/shout.h

Index: shout.h
===================================================================
RCS file: /usr/local/cvsroot/libshout/include/shout/shout.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -p -u -r1.19 -r1.20
--- shout.h	24 Jun 2003 02:42:54 -0000	1.19
+++ shout.h	2 Jul 2003 16:39:51 -0000	1.20
@@ -37,6 +37,13 @@ typedef struct _util_dict shout_metadata
 extern "C" {
 #endif
 
+/* initializes the shout library. Must be called before anything else */
+void shout_init(void);
+
+/* shuts down the shout library, deallocating any global storage. Don't call
+ * anything afterwards */
+void shout_shutdown(void);
+
 /* returns a static version string.  Non-null parameters will be set to the
  * value of the library major, minor, and patch levels, respectively */
 const char *shout_version(int *major, int *minor, int *patch);

<p><p>1.42      +25 -0     libshout/src/shout.c

Index: shout.c
===================================================================
RCS file: /usr/local/cvsroot/libshout/src/shout.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -p -u -r1.41 -r1.42
--- shout.c	6 Jun 2003 19:43:12 -0000	1.41
+++ shout.c	2 Jul 2003 16:39:51 -0000	1.42
@@ -24,12 +24,37 @@ static int login_icy(shout_t *self);
 static int login_http_basic(shout_t *self);
 char *http_basic_authorization(shout_t *self);
 
+/* -- static data -- */
+static int _initialized = 0;
+
 /* -- public functions -- */
 
+void shout_init(void)
+{
+	if (_initialized)
+		return;
+
+	sock_initialize();
+	_initialized = 1;
+}
+
+void shout_shutdown(void)
+{
+	if (!_initialized)
+		return;
+
+	sock_shutdown();
+	_initialized = 0;
+}
+
 shout_t *shout_new(void)
 {
         shout_t *self;
 
+	/* in case users haven't done this explicitly. Should we error
+	 * if not initialized instead? */
+	shout_init();
+	
         if (!(self = (shout_t *)calloc(1, sizeof(shout_t)))) {
                 return NULL;
         }

<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