home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.wwiv.com
/
ftp.wwiv.com.zip
/
ftp.wwiv.com
/
pub
/
CEREBRUM
/
WAT9609.ZIP
/
SRC
/
WATTCPD.C
< prev
Wrap
Text File
|
1994-11-28
|
1KB
|
53 lines
#include <stdlib.h>
#include <wattcp.h>
extern void (*wattcpd)(void);
#define MAXD = 50;
static void (**backd)(void) = NULL;
word lastd; /* could be made static? */
static void dowattcpd( void )
{
void (**p)(void) = backd;
int count = lastd;
do {
if ( *p ) (**p)();
} while ( count-- );
}
int addwattcpd( void (*p)(void) )
{
int i;
if ( wattcpd == NULL ) {
backd = calloc( MAXD, sizeof( void (*)()));
if ( backd ) wattcpd = dowattcpd;
}
for ( i = 0; i < MAXD ; ++i ) {
if ( backd[i] == NULL ) {
backd[i] = p;
break;
}
}
if ( i < MAXD ) {
if ( lastd <= i ) lastd = i+1;
return( 0 );
}
return( -1 );
}
int delwattcpd( void (*p)(void) )
{
int i, j;
for ( i = 0; i < MAXD; ++i )
if ( backd[i] == p ) {
backd[i] = NULL;
break;
}
for ( j = i+1 ; j < lastd ; ++j )
if ( backd[j] ) i = j;
lastd = i+1;
}