Skip to content

Commit

Permalink
Initial repository (0.99 release tree)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilm0r committed Nov 6, 2005
0 parents commit b7d3cc3
Show file tree
Hide file tree
Showing 211 changed files with 66,522 additions and 0 deletions.
340 changes: 340 additions & 0 deletions COPYING

Large diffs are not rendered by default.

98 changes: 98 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
###########################
## Makefile for BitlBee ##
## ##
## Copyright 2002 Lintux ##
###########################

### DEFINITIONS

-include Makefile.settings

# Program variables
objects = account.o bitlbee.o commands.o conf.o crypting.o help.o ini.o irc.o log.o nick.o query.o set.o unix.o url.o user.o debug.o
subdirs = protocols

# Expansion of variables
subdirobjs = $(foreach dir,$(subdirs),$(dir)/$(dir).o)
CFLAGS += -Wall

all: $(OUTFILE)

uninstall: uninstall-bin uninstall-doc
@echo -e '\nmake uninstall does not remove files in '$(DESTDIR)$(ETCDIR)', you can use make uninstall-etc to do that.\n'

install: install-bin install-doc
@if ! [ -d $(DESTDIR)$(CONFIG) ]; then echo -e '\nThe configuration directory $(DESTDIR)$(CONFIG) does not exist yet, don'\''t forget to create it!'; fi
@if ! [ -e $(DESTDIR)$(ETCDIR)/bitlbee.conf ]; then echo -e '\nNo files are installed in '$(DESTDIR)$(ETCDIR)' by make install. Run make install-etc to do that.'; fi
@echo

.PHONY: install install-bin install-etc install-doc \
uninstall uninstall-bin uninstall-etc uninstall-doc \
all clean distclean tar $(subdirs)

Makefile.settings:
@echo
@echo Run ./configure to create Makefile.settings, then rerun make
@echo

clean: $(subdirs)
rm -f *.o $(OUTFILE) core utils/bitlbeed encode decode

distclean: clean $(subdirs)
rm -f Makefile.settings config.h
find . -name 'DEADJOE' -o -name '*.orig' -o -name '*.rej' -o -name '*~' | xargs rm -f

install-doc:
$(MAKE) -C doc install

uninstall-doc:
$(MAKE) -C doc uninstall

install-bin:
mkdir -p $(DESTDIR)$(BINDIR)
install -m 0755 $(OUTFILE) $(DESTDIR)$(BINDIR)/$(OUTFILE)

uninstall-bin:
rm -f $(DESTDIR)$(BINDIR)/$(OUTFILE)

install-etc:
mkdir -p $(DESTDIR)$(ETCDIR)
install -m 0644 motd.txt $(DESTDIR)$(ETCDIR)/motd.txt
install -m 0644 bitlbee.conf $(DESTDIR)$(ETCDIR)/bitlbee.conf

uninstall-etc:
rm -f $(DESTDIR)$(ETCDIR)/motd.txt
rm -f $(DESTDIR)$(ETCDIR)/bitlbee.conf
-rmdir $(DESTDIR)$(ETCDIR)

tar:
fakeroot debian/rules clean || make distclean
x=$$(basename $$(pwd)); \
cd ..; \
tar czf $$x.tar.gz --exclude=debian $$x

$(subdirs):
@$(MAKE) -C $@ $(MAKECMDGOALS)

$(objects): %.o: %.c
@echo '*' Compiling $<
@$(CC) -c $(CFLAGS) $< -o $@

$(objects): Makefile Makefile.settings config.h

$(OUTFILE): $(objects) $(subdirs)
@echo '*' Linking $(OUTFILE)
@$(CC) $(objects) $(subdirobjs) -o $(OUTFILE) $(LFLAGS) $(EFLAGS)
ifndef DEBUG
@echo '*' Stripping $(OUTFILE)
@-$(STRIP) $(OUTFILE)
endif

encode: crypting.c
$(CC) crypting.c protocols/md5.c $(CFLAGS) -o encode -DCRYPTING_MAIN $(CFLAGS) $(EFLAGS) $(LFLAGS)

decode: encode
cp encode decode

ctags:
ctags `find . -name "*.c"` `find . -name "*.h"`
156 changes: 156 additions & 0 deletions account.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
/********************************************************************\
* BitlBee -- An IRC to other IM-networks gateway *
* *
* Copyright 2002-2004 Wilmer van der Gaast and others *
\********************************************************************/

/* Account management functions */

/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License with
the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
if not, write to the Free Software Foundation, Inc., 59 Temple Place,
Suite 330, Boston, MA 02111-1307 USA
*/

#define BITLBEE_CORE
#include "bitlbee.h"
#include "account.h"

account_t *account_add( irc_t *irc, int protocol, char *user, char *pass )
{
account_t *a;

if( irc->accounts )
{
for( a = irc->accounts; a->next; a = a->next );
a = a->next = g_new0 ( account_t, 1 );
}
else
{
irc->accounts = a = g_new0 ( account_t, 1 );
}

a->protocol = protocol;
a->user = g_strdup( user );
a->pass = g_strdup( pass );
a->irc = irc;

return( a );
}

account_t *account_get( irc_t *irc, char *id )
{
account_t *a, *ret = NULL;
int nr;

if( sscanf( id, "%d", &nr ) == 1 && nr < 1000 )
{
for( a = irc->accounts; a; a = a->next )
if( ( nr-- ) == 0 )
return( a );

return( NULL );
}

for( a = irc->accounts; a; a = a->next )
{
if( g_strcasecmp( id, proto_name[a->protocol] ) == 0 )
{
if( !ret )
ret = a;
else
return( NULL ); /* We don't want to match more than one... */
}
else if( strstr( a->user, id ) )
{
if( !ret )
ret = a;
else
return( NULL );
}
}

return( ret );
}

void account_del( irc_t *irc, account_t *acc )
{
account_t *a, *l = NULL;

for( a = irc->accounts; a; a = (l=a)->next )
if( a == acc )
{
if( a->gc ) return; /* Caller should have checked, accounts still in use can't be deleted. */

if( l )
{
l->next = a->next;
}
else
{
irc->accounts = a->next;
}

g_free( a->user );
g_free( a->pass );
if( a->server ) g_free( a->server );
if( a->reconnect ) /* This prevents any reconnect still queued to happen */
cancel_auto_reconnect( a );
g_free( a );

break;
}
}

void account_on( irc_t *irc, account_t *a )
{
struct aim_user *u;

if( a->gc )
{
/* Trying to enable an already-enabled account */
return;
}

if( proto_prpl[a->protocol]->login == NULL )
{
irc_usermsg( irc, "Support for protocol %s is not included in this BitlBee", proto_name[a->protocol] );
return;
}

cancel_auto_reconnect( a );

u = g_new0 ( struct aim_user, 1 );
u->irc = irc;
u->protocol = a->protocol;
strncpy( u->username, a->user, sizeof( u->username ) - 1 );
strncpy( u->password, a->pass, sizeof( u->password ) - 1 );
if( a->server) strncpy( u->proto_opt[0], a->server, sizeof( u->proto_opt[0] ) - 1 );

a->gc = (struct gaim_connection *) u; /* Bit hackish :-/ */
a->reconnect = 0;

proto_prpl[a->protocol]->login( u );
}

void account_off( irc_t *irc, account_t *a )
{
account_offline( a->gc );
a->gc = NULL;
if( a->reconnect )
{
/* Shouldn't happen */
cancel_auto_reconnect( a );
}
}
49 changes: 49 additions & 0 deletions account.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/********************************************************************\
* BitlBee -- An IRC to other IM-networks gateway *
* *
* Copyright 2002-2004 Wilmer van der Gaast and others *
\********************************************************************/

/* Account management functions */

/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License with
the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
if not, write to the Free Software Foundation, Inc., 59 Temple Place,
Suite 330, Boston, MA 02111-1307 USA
*/

#ifndef _ACCOUNT_H
#define _ACCOUNT_H

typedef struct account
{
int protocol;
char *user;
char *pass;
char *server;

int reconnect;

struct irc *irc;
struct gaim_connection *gc;
struct account *next;
} account_t;

account_t *account_add( irc_t *irc, int protocol, char *user, char *pass );
account_t *account_get( irc_t *irc, char *id );
void account_del( irc_t *irc, account_t *acc );
void account_on( irc_t *irc, account_t *a );
void account_off( irc_t *irc, account_t *a );

#endif
Loading

0 comments on commit b7d3cc3

Please sign in to comment.