Skip to content

Commit

Permalink
Code cleanup and miscellaneous Makefile fixen.
Browse files Browse the repository at this point in the history
  • Loading branch information
vogon committed Oct 11, 2002
1 parent e6053d5 commit 814ba45
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 137 deletions.
52 changes: 29 additions & 23 deletions libinews/IcculusNews.h
Expand Up @@ -8,6 +8,7 @@
#ifndef __HAVE_ICCULUSNEWS_H
#define __HAVE_ICCULUSNEWS_H

#define _XOPEN_SOURCE
#include <time.h>

#define Uint8 unsigned char
Expand All @@ -21,8 +22,13 @@

typedef Uint8 bool;

#define TRUE 1
#define FALSE 0
#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif

typedef struct {
Uint8 major;
Expand Down Expand Up @@ -72,67 +78,67 @@ typedef struct {
#define ERR_SERVFAIL -6 /* internal server failure */
#define ERR_STORYTOOLONG -7 /* story was longer than the server wanted it to be; truncated. */

// initialize the library
/* initialize the library */
extern int INEWS_init();

// deinitialize the library
/* deinitialize the library */
extern void INEWS_deinit();

// get the version of the library used at runtime
/* get the version of the library used at runtime */
extern INEWS_Version *INEWS_getVersion();

// get the version of the server daemon
/* get the version of the server daemon */
extern char *INEWS_getServerVersion();

// get the current remote host
/* get the current remote host */
extern char *INEWS_getHost();

// get the current remote port
/* get the current remote port */
extern int INEWS_getPort();

// get the current IcculusNews username
/* get the current IcculusNews username */
extern const char *INEWS_getUserName();

// get the current IcculusNews user ID
/* get the current IcculusNews user ID */
extern int INEWS_getUID();

// get the currently-selected IcculusNews queue ID
/* get the currently-selected IcculusNews queue ID */
extern int INEWS_getQID();

// get detailed information on a chosen queue
/* get detailed information on a chosen queue */
extern QueueInfo *INEWS_getQueueInfo(int qid);

// get detailed information on all of the queues
/* get detailed information on all of the queues */
extern QueueInfo **INEWS_getAllQueuesInfo();

// get the error number of the last error to occur
/* get the error number of the last error to occur */
extern int INEWS_getLastError();

// connect to an IcculusNews server
/* connect to an IcculusNews server */
extern int INEWS_connect(const char *hostname, Uint32 port);

// retrieve queue information from the server
/* retrieve queue information from the server */
extern int INEWS_retrQueueInfo();

// authenticate as a given user to the server
/* authenticate as a given user to the server */
extern int INEWS_auth(const char *username, const char *password);

// change the currently-selected queue
/* change the currently-selected queue */
extern int INEWS_changeQueue(int qid);

// retrieve a digest of the currently-selected queue with n articles
/* retrieve a digest of the currently-selected queue with n articles */
extern ArticleInfo **INEWS_digest(int n);

// submit an article. OMG
/* submit an article. OMG */
extern int INEWS_submitArticle(char *title, char *body);

// free the memory dynamically allocated by a call to INEWS_digest
/* free the memory dynamically allocated by a call to INEWS_digest */
extern void INEWS_freeDigest(ArticleInfo **digest);

// free the memory dynamically allocated by a call to INEWS_getAllQueuesInfo
/* free the memory dynamically allocated by a call to INEWS_getAllQueuesInfo */
extern void INEWS_freeQueuesInfo(QueueInfo **qinfo);

// disconnect from the current server
/* disconnect from the current server */
extern void INEWS_disconnect();

#endif
19 changes: 10 additions & 9 deletions libinews/Makefile
@@ -1,16 +1,17 @@
net.o: net.c
gcc-3.2 -ggdb `pkg-config --cflags glib-2.0` `pkg-config --cflags gthread-2.0` -c -o net.o net.c
utility.o: utility.c
gcc-3.2 -ggdb `pkg-config --cflags glib-2.0` `pkg-config --cflags gthread-2.0` -c -o utility.o utility.c
init.o: init.c
gcc-3.2 -ggdb `pkg-config --cflags glib-2.0` `pkg-config --cflags gthread-2.0` -c -o init.o init.c
CC = gcc-3.2
BASE_CFLAGS = -std=c99 -ggdb `pkg-config --cflags glib-2.0` `pkg-config --cflags gthread-2.0`
BASE_LDFLAGS = -ggdb -shared `pkg-config --libs glib-2.0` `pkg-config --libs gthread-2.0`

.c.o:
$(CC) $(BASE_CFLAGS) $(CFLAGS) -c $<

libinews.so.0: net.o utility.o init.o
gcc-3.2 -ggdb -shared `pkg-config --libs glib-2.0` `pkg-config --libs gthread-2.0` -o libinews.so.0 utility.o net.o init.o
$(CC) $(BASE_LDFLAGS) $(LDFLAGS) -o libinews.so.0 utility.o net.o init.o

test: libinews.so.0 test.c
gcc-3.2 -ggdb -L. -linews -o test test.c
$(CC) -ggdb -L. -linews -o test test.c

clean:
rm -f *.o *.so *.so.0 test

all: libinews.so.0 test
all: libinews.so.0
7 changes: 7 additions & 0 deletions libinews/internals.h
Expand Up @@ -12,6 +12,12 @@

#include <netinet/in.h>

/* squelch all the implicit function decl warnings */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <execinfo.h>

/* we use glib, because I'm too lazy to write
* string-mangling functions myself */
#include <glib-2.0/glib.h>
Expand Down Expand Up @@ -75,5 +81,6 @@ int __write_block(char *str);
char *__chop(char *str);
gpointer __nop_thread(gpointer foo);
void __free_queue_info_list_element(GList *ptr);
void __print_protocol_fuckery_message();

#endif

0 comments on commit 814ba45

Please sign in to comment.