home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Micro R&D 1
/
MicroRD-CD-ROM-Vol1-1994.iso
/
os20
/
cli
/
cxkiller12.lha
/
CxKiller
/
CxKiller.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-12-21
|
2KB
|
109 lines
/*
** CxKiller.c : Gael Marziou
**
** A simple program to kill Commodties safely.
** Without any argument it kills all commodities.
** Arguments must be a list of Commodities.names
** Names are case sensitive.
**
** 29 Nov. 93
*/
#include <exec/libraries.h>
#include <exec/memory.h>
#include <libraries/commodities.h>
#include <dos/dos.h>
#include <clib/exec_protos.h>
#include <clib/alib_protos.h>
#include <clib/commodities_protos.h>
UBYTE *version = "$VER: CxKiller 1.2";
#ifdef __SASC
int CXBRK(void) { return(0); } /* Disable SAS_C CTRL/C handling */
int chkabort(void) { return(0); }
#include <pragmas/commodities_pragmas.h>
#include <pragmas/exec_pragmas.h>
#include <pragmas/dos_pragmas.h>
#endif
/*** private functions of "commodities.library" ***/
#pragma libcall CxBase FindBroker 6c 801
#pragma libcall CxBase CopyBrokerList ba 801
#pragma libcall CxBase FreeBrokerList c0 801
#pragma libcall CxBase BrokerCommand c6 802
CxObj *FindBroker(char *);
LONG CopyBrokerList(struct List *);
LONG FreeBrokerList(struct List *);
LONG BrokerCommand(char *, LONG id);
struct Library *CxBase;
/*** private structures & defines ***/
struct BrokerCopy {
struct Node bc_Node;
char bc_Name[CBD_NAMELEN];
char bc_Title[CBD_TITLELEN];
char bc_Descr[CBD_DESCRLEN];
LONG bc_Task;
LONG bc_Dummy1;
LONG bc_Dummy2;
UWORD bc_Flags;
};
#define COF_ACTIVE 2
__inline void
KillAllBrokers (void)
{
struct List *l;
struct Node *n, *nn;
if (l = AllocVec(sizeof(struct List),MEMF_PUBLIC)) {
NewList(l);
CopyBrokerList(l);
for (n = l->lh_Head; n && (nn = n->ln_Succ); n = nn)
BrokerCommand((char *)((struct BrokerCopy *)n)->bc_Name,CXCMD_KILL);
FreeBrokerList(l);
FreeVec(l);
}
}
__inline void
KillOneBroker (char *BrokerName)
{
BrokerCommand(BrokerName, CXCMD_KILL);
}
void
main(int argc, char *argv[])
{
unsigned char i;
/* Before bothering with anything else, open the library */
if (CxBase = OpenLibrary("commodities.library", 37L))
{
if (argc < 2)
{ /* no argument given */
KillAllBrokers();
}
else
{
for (i=1; i<argc ; i++)
{
KillOneBroker((char *)argv[i]);
}
}
}
CloseLibrary(CxBase);
}