Remove old examples

This commit is contained in:
Carsten Sonne Larsen 2021-02-28 22:31:38 +01:00
parent ce2af04331
commit f46a8b9e66
26 changed files with 0 additions and 18401 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +0,0 @@
#define VERSION 4
#define REVISION 53
#define DATE "12.12.2015"
#define VERS "AddNetInterface 4.53"
#define VSTRING "AddNetInterface 4.53 (12.12.2015)\r\n"
#define VERSTAG "\0$VER: AddNetInterface 4.53 (12.12.2015)"

View File

@ -1,953 +0,0 @@
/*
* $Id: AddNetRoute.c,v 1.11 2007-08-26 12:30:15 obarthel Exp $
*
* :ts=4
*
* Copyright © 2001-2007 by Olaf Barthel. All Rights Reserved.
*/
#include <libraries/bsdsocket.h>
#include <exec/execbase.h>
#include <exec/memory.h>
#include <dos/dosextens.h>
#include <dos/dostags.h>
#include <dos/dosasl.h>
#include <dos/rdargs.h>
#include <dos/stdio.h>
#include <libraries/locale.h>
/****************************************************************************/
#if defined(__amigaos4__)
#include <dos/obsolete.h>
#endif /* __amigaos4__ */
/****************************************************************************/
#if !defined(__amigaos4__)
#define NO_INLINE_STDARG
#endif /* __amigaos4__ */
#define __NOLIBBASE__
#define __NOGLOBALIFACE__
#define __USE_INLINE__
/****************************************************************************/
#include <proto/bsdsocket.h>
#include <proto/locale.h>
#include <proto/exec.h>
#include <proto/dos.h>
/****************************************************************************/
#include <string.h>
#include <stdarg.h>
/****************************************************************************/
#include "AddNetRoute_rev.h"
/****************************************************************************/
#include "macros.h"
/****************************************************************************/
#ifndef AbsExecBase
#define AbsExecBase (*(struct ExecBase **)4)
#endif /* AbsExecBase */
/****************************************************************************/
typedef LONG * NUMBER;
typedef LONG SWITCH;
typedef STRPTR KEY;
/****************************************************************************/
struct CommandContext
{
struct Library * cc_SysBase;
struct Library * cc_DOSBase;
struct Library * cc_LocaleBase;
struct Library * cc_SocketBase;
#if defined(__amigaos4__)
/************************************************************************/
struct ExecIFace * cc_IExec;
struct DOSIFace * cc_IDOS;
struct LocaleIFace * cc_ILocale;
struct SocketIFace * cc_ISocket;
/************************************************************************/
#endif /* __amigaos4__ */
struct Catalog * cc_Catalog;
UBYTE cc_ProgramName[256];
struct TagItem * cc_Tags;
LONG cc_NumTags;
LONG cc_MaxTags;
};
/****************************************************************************/
#if defined(__amigaos4__)
/****************************************************************************/
#define DECLARE_SYSBASE(cc) \
struct ExecIFace * IExec = cc->cc_IExec; \
struct Library * SysBase = cc->cc_SysBase
#define DECLARE_DOSBASE(cc) \
struct DOSIFace * IDOS = cc->cc_IDOS; \
struct Library * DOSBase = cc->cc_DOSBase
#define DECLARE_LOCALEBASE(cc) \
struct LocaleIFace * ILocale = cc->cc_ILocale; \
struct Library * LocaleBase = cc->cc_LocaleBase
#define DECLARE_SOCKETBASE(cc) \
struct SocketIFace * ISocket = cc->cc_ISocket; \
struct Library * SocketBase = cc->cc_SocketBase
/****************************************************************************/
#else
/****************************************************************************/
#define DECLARE_SYSBASE(cc) \
struct Library * SysBase = cc->cc_SysBase
#define DECLARE_DOSBASE(cc) \
struct Library * DOSBase = cc->cc_DOSBase
#define DECLARE_LOCALEBASE(cc) \
struct Library * LocaleBase = cc->cc_LocaleBase
#define DECLARE_SOCKETBASE(cc) \
struct Library * SocketBase = cc->cc_SocketBase
/****************************************************************************/
#endif /* __amigaos4__ */
/****************************************************************************/
LONG _start(VOID);
/****************************************************************************/
STATIC VOID close_libs(struct CommandContext *cc);
STATIC LONG open_libs(struct CommandContext *cc, struct Library *SysBase);
STATIC LONG cmd(struct CommandContext *cc);
STATIC LONG add_tag(struct CommandContext *cc, Tag tag, ULONG data);
STATIC LONG Local_Printf(struct CommandContext *cc, STRPTR format, ...);
STATIC LONG VARARGS68K Local_ErrorPrintf(struct CommandContext *cc, STRPTR format, ...);
STATIC STRPTR get_builtin_str(LONG id);
STATIC STRPTR get_str(struct CommandContext *cc, LONG id);
STATIC LONG VARARGS68K Local_SocketBaseTags(struct CommandContext *cc, ...);
/****************************************************************************/
/****** ROADSHOW/ADDNETROUTE **************************************************
*
* NAME
* AddNetRoute - Add message routing paths.
*
* FORMAT
* AddNetRoute [QUIET] [DESTINATION=<IP>] [HOSTDESTINATION=<IP>]
* [NETDESTINATION=<IP>] [GATEWAY=<IP>] [DEFAULTGATEWAY=<IP>]
*
* TEMPLATE
* QUIET/S,DST=DESTINATION/K,HOSTDST=HOSTDESTINATION/K,
* NETDST=NETDESTINATION/K,VIA=GATEWAY/K,DEFAULT=DEFAULTGATEWAY/K
*
* PATH
* C:ADDNETROUTE
*
* FUNCTION
* ADDNETROUTE allows to define routes to hosts or networks via an
* interface.
*
* OPTIONS
* QUIET/S
* This option causes the program not to emit any error messages
* or progress reports. Also, if the program encounters an error
* it will flag this as failure code 5 which can be looked at
* using the "if warn" shell script command. If this option is
* not in effect, failure codes will be more severe and all sorts
* of progress information will be displayed.
*
* DST=DESTINATION/K
* The destination address of a route (or in other words, where
* the route to be added leads to). This must be an IP address
* or a symbolic name. Some routes may require you to specify
* a gateway address through which the route has to pass.
* Depending upon the address you specify, the protocol stack
* will attempt to figure out whether the destination is
* supposed to be a host or a network.
*
* HOSTDST=HOSTDESTINATION/K
* Same as the "DST=DESTINATION/K" parameter, except that the
* destination is assumed to be a host (rather than a network).
*
* NETDST=NETDESTINATION/K
* Same as the "DST=DESTINATION/K" parameter, except that the
* destination is assumed to be a network (rather than a host).
*
* VIA=GATEWAY/K
* This parameter complements the route destination address;
* it indicates the address to which a message should be sent
* for it to be passed to the destination. This must be an IP
* address or a symbolic name.
*
* DEFAULT=DEFAULTGATEWAY/K
* This parameter selects the default gateway address (which
* must be specified as an IP address or a symbolic host name)
* all messages are sent to which don't have any particular
* other routes associated with them.
* Another, perhaps less misleading name for "default gateway
* address" is "default route".
*
* NOTES
* The command is similar to the Unix "route" command.
*
* If you use the "DEFAULT=DEFAULTGATEWAY/K" parameter, all
* other destination addresses you may have specified will be
* ignored. Only one of "DESTINATION", "HOSTDESTINATION" or
* "NETDESTINATION" will be used; choose only one. Before you add
* a new default gateway you should delete the old one or you'll
* get an error message instead.
*
* EXAMPLES
* Define a route to the host 192.168.10.12 through a
* gateway at 192.168.1.1
*
* 1> ADDNETROUTE HOSTDESTINATION 192.168.10.12 VIA 192.168.1.1
*
* SEE ALSO
* DeleteNetRoute
*
******************************************************************************
*/
LONG
_start(VOID)
{
struct Library *SysBase = (struct Library *)AbsExecBase;
#if defined(__amigaos4__)
struct ExecIFace * IExec = (struct ExecIFace *)((struct ExecBase *)SysBase)->MainInterface;
#endif /* __amigaos4__ */
struct CommandContext _cc,*cc = &_cc;
LONG result = RETURN_FAIL;
struct Process * pr;
LONG error;
memset(cc,0,sizeof(*cc));
pr = (struct Process *)FindTask(NULL);
if(pr->pr_CLI == ZERO)
{
struct MsgPort * mp = &pr->pr_MsgPort;
struct Message * mn;
WaitPort(mp);
mn = GetMsg(mp);
Forbid();
ReplyMsg(mn);
goto out;
}
error = open_libs(cc,SysBase);
if(error == OK)
{
DECLARE_LOCALEBASE(cc);
if(cc->cc_LocaleBase != NULL)
cc->cc_Catalog = OpenCatalogA(NULL,"roadshow.catalog",NULL);
result = cmd(cc);
if(cc->cc_Tags != NULL)
FreeVec(cc->cc_Tags);
if(cc->cc_Catalog != NULL)
CloseCatalog(cc->cc_Catalog);
}
else
{
pr->pr_Result2 = error;
}
close_libs(cc);
out:
return(result);
}
/****************************************************************************/
STATIC VOID
close_libs(struct CommandContext * cc)
{
DECLARE_SYSBASE(cc);
#if defined(__amigaos4__)
{
if(cc->cc_IDOS != NULL)
DropInterface((struct Interface *)cc->cc_IDOS);
if(cc->cc_ILocale != NULL)
DropInterface((struct Interface *)cc->cc_ILocale);
if(cc->cc_ISocket != NULL)
DropInterface((struct Interface *)cc->cc_ISocket);
}
#endif /* __amigaos4__ */
if(cc->cc_SocketBase != NULL)
CloseLibrary(cc->cc_SocketBase);
if(cc->cc_LocaleBase != NULL)
CloseLibrary(cc->cc_LocaleBase);
if(cc->cc_DOSBase != NULL)
CloseLibrary(cc->cc_DOSBase);
}
/****************************************************************************/
STATIC LONG
open_libs(struct CommandContext * cc,struct Library *SysBase)
{
#if defined(__amigaos4__)
struct ExecIFace * IExec = (struct ExecIFace *)((struct ExecBase *)SysBase)->MainInterface;
#endif /* __amigaos4__ */
LONG error;
cc->cc_SysBase = SysBase;
#if defined(__amigaos4__)
{
cc->cc_IExec = IExec;
}
#endif /* __amigaos4__ */
cc->cc_DOSBase = OpenLibrary("dos.library",36);
#if defined(__amigaos4__)
{
if(cc->cc_DOSBase != NULL)
{
cc->cc_IDOS = (struct DOSIFace *)GetInterface(cc->cc_DOSBase, "main", 1, 0);
if(cc->cc_IDOS == NULL)
{
CloseLibrary(cc->cc_DOSBase);
cc->cc_DOSBase = NULL;
}
}
}
#endif /* __amigaos4__ */
if(cc->cc_DOSBase == NULL)
{
error = ERROR_INVALID_RESIDENT_LIBRARY;
goto out;
}
cc->cc_LocaleBase = OpenLibrary("locale.library",38);
#if defined(__amigaos4__)
{
if(cc->cc_LocaleBase != NULL)
{
cc->cc_ILocale = (struct LocaleIFace *)GetInterface(cc->cc_LocaleBase, "main", 1, 0);
if(cc->cc_ILocale == NULL)
{
CloseLibrary(cc->cc_LocaleBase);
cc->cc_LocaleBase = NULL;
}
}
}
#endif /* __amigaos4__ */
/* The following may be necessary to flush out an inoperable
bsdsocket.library which reached the end of the shutdown
process. */
#if 1
{
struct ExecBase * ex = (struct ExecBase *)SysBase;
struct Library * lib;
Forbid();
lib = (struct Library *)FindName(&ex->LibList,"bsdsocket.library");
if(lib != NULL)
RemLibrary(lib);
Permit();
}
#endif
cc->cc_SocketBase = OpenLibrary("bsdsocket.library",4);
#if defined(__amigaos4__)
{
if(cc->cc_SocketBase != NULL)
{
cc->cc_ISocket = (struct SocketIFace *)GetInterface(cc->cc_SocketBase, "main", 1, 0);
if(cc->cc_ISocket == NULL)
{
CloseLibrary(cc->cc_SocketBase);
cc->cc_SocketBase = NULL;
}
}
}
#endif /* __amigaos4__ */
error = OK;
out:
return(error);
}
/****************************************************************************/
#define CATCOMP_ARRAY
#define ADDNETROUTE_CATALOG_STRINGS
#include "roadshow.h"
/****************************************************************************/
STATIC LONG
cmd(struct CommandContext * cc)
{
struct
{
SWITCH Quiet;
KEY Destination;
KEY DestinationHost;
KEY DestinationNet;
KEY Gateway;
KEY DefaultGateway;
} args;
STRPTR args_template =
"QUIET/S,"
"DST=DESTINATION/K,"
"HOSTDST=HOSTDESTINATION/K,"
"NETDST=NETDESTINATION/K,"
"VIA=GATEWAY/K,"
"DEFAULT=DEFAULTGATEWAY/K"
VERSTAG;
DECLARE_DOSBASE(cc);
DECLARE_SOCKETBASE(cc);
LONG result = RETURN_FAIL;
LONG have_routing_api = FALSE;
struct RDArgs * rda;
LONG error;
BOOL quiet = FALSE;
GetProgramName(cc->cc_ProgramName,sizeof(cc->cc_ProgramName));
memset(&args,0,sizeof(args));
rda = ReadArgs(args_template,(LONG *)&args,NULL);
if(rda == NULL)
{
PrintFault(IoErr(),cc->cc_ProgramName);
goto out;
}
quiet = (BOOL)(args.Quiet != 0);
if(SocketBase == NULL)
{
if(NOT quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_ADDNETROUTE_CANNOT_OPEN_BSDSOCKET_TXT),
cc->cc_ProgramName);
}
goto out;
}
if(Local_SocketBaseTags(cc,
SBTM_GETREF(SBTC_HAVE_ROUTING_API),&have_routing_api,
TAG_END) != 0)
{
have_routing_api = FALSE;
}
if(NOT have_routing_api)
{
if(NOT quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_ADDNETROUTE_BSDSOCKET_HAS_NO_ROUTE_API_TXT),
cc->cc_ProgramName, SocketBase->lib_Node.ln_Name, SocketBase->lib_Version, SocketBase->lib_Revision);
}
goto out;
}
if(args.DefaultGateway != NULL)
{
error = add_tag(cc,RTA_DefaultGateway,(ULONG)args.DefaultGateway);
if(error != OK)
{
if(NOT quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_ADDNETROUTE_NO_MEMORY_FOR_DEFAULT_GATEWAY_TXT),
cc->cc_ProgramName,args.DefaultGateway);
}
goto out;
}
if(NOT quiet)
{
if(args.Destination != NULL)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_ADDNETROUTE_DESTINATION_IGNORED_TXT),
cc->cc_ProgramName,args.Destination);
}
if(args.DestinationHost != NULL)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_ADDNETROUTE_HOSTDESTINATION_IGNORED_TXT),
cc->cc_ProgramName,args.DestinationHost);
}
if(args.DestinationNet != NULL)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_ADDNETROUTE_NETDESTINATION_IGNORED_TXT),
cc->cc_ProgramName,args.DestinationNet);
}
if(args.Gateway != NULL)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_ADDNETROUTE_GATEWAY_IGNORED_TXT),
cc->cc_ProgramName,args.Gateway);
}
}
}
else if (args.Gateway != NULL)
{
STRPTR dst;
if(args.Destination != NULL)
dst = args.Destination;
else if (args.DestinationHost != NULL)
dst = args.DestinationHost;
else if (args.DestinationNet != NULL)
dst = args.DestinationNet;
else
dst = NULL;
if(dst == NULL)
{
if(NOT quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_ADDNETROUTE_GATEWAY_NEEDS_DESTINATION_TXT),
cc->cc_ProgramName,args.Gateway);
}
goto out;
}
error = add_tag(cc,RTA_Gateway,(ULONG)args.Gateway);
if(error != OK)
{
if(NOT quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_ADDNETROUTE_NOT_ENOUGH_MEMORY_FOR_GATEWAY_TXT),
cc->cc_ProgramName,args.Gateway);
}
goto out;
}
}
else
{
PrintFault(ERROR_REQUIRED_ARG_MISSING,cc->cc_ProgramName);
goto out;
}
if(args.Destination != NULL)
{
error = add_tag(cc,RTA_Destination,(ULONG)args.Destination);
if(error != OK)
{
if(NOT quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_ADDNETROUTE_NOT_ENOUGH_MEMORY_FOR_ROUTE_TXT),
cc->cc_ProgramName,args.Destination);
}
goto out;
}
if(NOT quiet && args.DestinationHost != NULL)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_ADDNETROUTE_HOSTDESTINATION_IGNORED_TXT),
cc->cc_ProgramName,args.DestinationHost);
}
if(NOT quiet && args.DestinationNet != NULL)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_ADDNETROUTE_NETDESTINATION_IGNORED_TXT),
cc->cc_ProgramName,args.DestinationNet);
}
}
else if (args.DestinationHost != NULL)
{
error = add_tag(cc,RTA_DestinationHost,(ULONG)args.DestinationHost);
if(error != OK)
{
if(NOT quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_ADDNETROUTE_NOT_ENOUGH_MEMORY_FOR_ROUTE_TO_HOST_TXT),
cc->cc_ProgramName,args.Destination);
}
goto out;
}
if(NOT quiet && args.DestinationNet != NULL)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_ADDNETROUTE_NETDESTINATION_IGNORED_TXT),
cc->cc_ProgramName,args.DestinationNet);
}
}
else if (args.DestinationNet != NULL)
{
error = add_tag(cc,RTA_DestinationNet,(ULONG)args.DestinationNet);
if(error != OK)
{
if(NOT quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_ADDNETROUTE_NOT_ENOUGH_MEMORY_FOR_ROUTE_TO_NET_TXT),
cc->cc_ProgramName,args.Destination);
}
goto out;
}
}
if(cc->cc_NumTags > 0)
{
error = add_tag(cc,TAG_END,0);
if(error != OK)
{
if(NOT quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_ADDNETROUTE_NOT_ENOUGH_MEMORY_TO_ADD_ROUTE_TXT),
cc->cc_ProgramName);
}
goto out;
}
if(AddRouteTagList(cc->cc_Tags) != OK)
{
if(NOT quiet)
{
LONG errno = 0;
LONG code;
Local_SocketBaseTags(cc,
SBTM_GETREF(SBTC_ERRNO),&errno,
TAG_END);
code = errno;
if(Local_SocketBaseTags(cc,
SBTM_GETREF(SBTC_ERRNOSTRPTR),&code,
TAG_END) != 0)
{
code = 0;
}
Local_ErrorPrintf(cc,get_str(cc,MSG_ADDNETROUTE_COULD_NOT_ADD_ROUTE_TXT),
cc->cc_ProgramName);
if(code > 0 && errno > 0)
Local_ErrorPrintf(cc," (%s)",code);
Local_ErrorPrintf(cc,".\n");
}
goto out;
}
if(NOT quiet)
{
STRPTR prefix = "";
Local_Printf(cc,get_str(cc,MSG_ADDNETROUTE_ROUTE_ADDED_TXT),
cc->cc_ProgramName);
if(args.DefaultGateway != NULL)
{
Local_Printf(cc,get_str(cc,MSG_ADDNETROUTE_DEFAULT_GATEWAY_TXT),prefix,args.DefaultGateway);
prefix = ", ";
}
if(args.Destination != NULL)
{
Local_Printf(cc,get_str(cc,MSG_ADDNETROUTE_DESTINATION_TXT),prefix,args.Destination);
prefix = ", ";
}
if(args.DestinationHost != NULL)
{
Local_Printf(cc,get_str(cc,MSG_ADDNETROUTE_DESTINATION_HOST_TXT),prefix,args.DestinationHost);
prefix = ", ";
}
if(args.DestinationNet != NULL)
Local_Printf(cc,get_str(cc,MSG_ADDNETROUTE_DESTINATION_NET_TXT),prefix,args.DestinationNet);
if(args.Gateway != NULL)
Local_Printf(cc,get_str(cc,MSG_ADDNETROUTE_VIA_GATEWAY_TXT),prefix,args.Gateway);
Local_Printf(cc,").\n");
}
}
result = RETURN_OK;
out:
if(quiet && result != RETURN_OK)
result = RETURN_WARN;
if(rda != NULL)
FreeArgs(rda);
return(result);
}
/****************************************************************************/
STATIC LONG
add_tag(struct CommandContext * cc,Tag tag,ULONG data)
{
DECLARE_SYSBASE(cc);
LONG error = OK;
LONG which = -1;
LONG i;
for(i = 0 ; i < cc->cc_NumTags ; i++)
{
if(cc->cc_Tags[i].ti_Tag == tag)
{
which = i;
break;
}
}
if(which == -1 && cc->cc_NumTags + 1 >= cc->cc_MaxTags)
{
struct TagItem * new_tags;
new_tags = AllocVec(sizeof(*new_tags) * (cc->cc_MaxTags+10),MEMF_ANY|MEMF_PUBLIC);
if(new_tags == NULL)
{
error = ERROR_NO_FREE_STORE;
goto out;
}
if(cc->cc_Tags != NULL)
CopyMem(cc->cc_Tags,new_tags,sizeof(*new_tags) * cc->cc_NumTags);
FreeVec(cc->cc_Tags);
cc->cc_Tags = new_tags;
cc->cc_MaxTags += 10;
}
if(which == -1)
which = cc->cc_NumTags++;
cc->cc_Tags[which].ti_Tag = tag;
cc->cc_Tags[which].ti_Data = data;
out:
return(error);
}
/****************************************************************************/
STATIC LONG VARARGS68K
Local_Printf(struct CommandContext * cc,STRPTR format,...)
{
DECLARE_DOSBASE(cc);
va_list args;
LONG result;
#if defined(__amigaos4__)
{
va_startlinear(args,format);
result = VPrintf(format,va_getlinearva(args,APTR));
va_end(args);
}
#else
{
va_start(args,format);
result = VPrintf(format,args);
va_end(args);
}
#endif /* __amigaos4__ */
return(result);
}
/****************************************************************************/
STATIC LONG VARARGS68K
Local_ErrorPrintf(struct CommandContext * cc,STRPTR format,...)
{
DECLARE_DOSBASE(cc);
DECLARE_SYSBASE(cc);
va_list args;
LONG result;
BPTR fh;
#if defined(__amigaos4__)
{
fh = ErrorOutput();
}
#else
{
struct Process * this_process = (struct Process *)FindTask(NULL);
fh = this_process->pr_CES;
}
#endif /* __amigaos4__ */
if(fh == ZERO)
fh = Output();
#if defined(__amigaos4__)
{
va_startlinear(args,format);
result = VFPrintf(fh,format,va_getlinearva(args,APTR));
va_end(args);
}
#else
{
va_start(args,format);
result = VFPrintf(fh,format,args);
va_end(args);
}
#endif /* __amigaos4__ */
return(result);
}
/****************************************************************************/
/* This looks up a locale string ID in the builtin database; adapted
from CygnusEd because I couldn't find my own implementation for this
application... */
STATIC STRPTR
get_builtin_str(LONG id)
{
LONG top,middle,bottom;
STRPTR builtin_string;
/* The search area is all those message between bottom and top, inclusive. */
bottom = 0;
top = NUM_ENTRIES(CatCompArray) - 1;
/* Binary search through the CatCompArray to find the requested string.
Note that this assumes that the strings are sorted. Catcomp defaults
to creating sorted arrays, but it does _not_ force it. If in the .cd
file you specify out of order string numbers this routine will fail. */
while(bottom != top)
{
middle = (bottom + top) / 2;
if(CatCompArray[middle].cca_ID >= id)
top = middle;
else
bottom = middle + 1;
}
/* The only time this error message should occur is if you've passed
a garbage number OR if the CatCompArray is not sorted. */
if(CatCompArray[bottom].cca_ID == id)
builtin_string = (STRPTR)CatCompArray[bottom].cca_Str;
else
builtin_string = "";
return(builtin_string);
}
STATIC STRPTR
get_str(struct CommandContext * cc, LONG id)
{
STRPTR builtin_string;
STRPTR result;
builtin_string = get_builtin_str(id);
if(cc->cc_Catalog != NULL)
{
DECLARE_LOCALEBASE(cc);
result = (STRPTR)GetCatalogStr(cc->cc_Catalog,id,builtin_string);
}
else
{
result = builtin_string;
}
return(result);
}
/****************************************************************************/
STATIC LONG VARARGS68K
Local_SocketBaseTags(struct CommandContext * cc,...)
{
DECLARE_SOCKETBASE(cc);
va_list args;
LONG result;
#if defined(__amigaos4__)
{
va_startlinear(args,cc);
result = SocketBaseTagList(va_getlinearva(args,struct TagItem *));
va_end(args);
}
#else
{
va_start(args,cc);
result = SocketBaseTagList((struct TagItem *)args);
va_end(args);
}
#endif /* __amigaos4__ */
return(result);
}

View File

@ -1,6 +0,0 @@
#define VERSION 4
#define REVISION 8
#define DATE "11.3.2009"
#define VERS "AddNetRoute 4.8"
#define VSTRING "AddNetRoute 4.8 (11.3.2009)\r\n"
#define VERSTAG "\0$VER: AddNetRoute 4.8 (11.3.2009)"

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +0,0 @@
#define VERSION 4
#define REVISION 37
#define DATE "26.1.2017"
#define VERS "ConfigureNetInterface 4.37"
#define VSTRING "ConfigureNetInterface 4.37 (26.1.2017)\r\n"
#define VERSTAG "\0$VER: ConfigureNetInterface 4.37 (26.1.2017)"

View File

@ -1,732 +0,0 @@
/*
* $Id: DeleteNetRoute.c,v 1.11 2007-08-26 12:30:15 obarthel Exp $
*
* :ts=4
*
* Copyright © 2001-2007 by Olaf Barthel. All Rights Reserved.
*/
#include <libraries/bsdsocket.h>
#include <exec/execbase.h>
#include <exec/memory.h>
#include <dos/dosextens.h>
#include <dos/dostags.h>
#include <dos/dosasl.h>
#include <dos/rdargs.h>
#include <dos/stdio.h>
#include <libraries/locale.h>
/****************************************************************************/
#if defined(__amigaos4__)
#include <dos/obsolete.h>
#endif /* __amigaos4__ */
/****************************************************************************/
#if !defined(__amigaos4__)
#define NO_INLINE_STDARG
#endif /* __amigaos4__ */
#define __NOLIBBASE__
#define __NOGLOBALIFACE__
#define __USE_INLINE__
/****************************************************************************/
#include <proto/bsdsocket.h>
#include <proto/locale.h>
#include <proto/exec.h>
#include <proto/dos.h>
/****************************************************************************/
#include <string.h>
#include <stdarg.h>
/****************************************************************************/
#include "macros.h"
/****************************************************************************/
#include "DeleteNetRoute_rev.h"
/****************************************************************************/
#ifndef AbsExecBase
#define AbsExecBase (*(struct ExecBase **)4)
#endif /* AbsExecBase */
/****************************************************************************/
typedef LONG * NUMBER;
typedef LONG SWITCH;
typedef STRPTR KEY;
/****************************************************************************/
struct CommandContext
{
struct Library * cc_SysBase;
struct Library * cc_DOSBase;
struct Library * cc_SocketBase;
struct Library * cc_LocaleBase;
#if defined(__amigaos4__)
/************************************************************************/
struct ExecIFace * cc_IExec;
struct DOSIFace * cc_IDOS;
struct SocketIFace * cc_ISocket;
struct LocaleIFace * cc_ILocale;
/************************************************************************/
#endif /* __amigaos4__ */
struct Catalog * cc_Catalog;
UBYTE cc_ProgramName[256];
};
/****************************************************************************/
#if defined(__amigaos4__)
/****************************************************************************/
#define DECLARE_SYSBASE(cc) \
struct ExecIFace * IExec = cc->cc_IExec; \
struct Library * SysBase = cc->cc_SysBase
#define DECLARE_DOSBASE(cc) \
struct DOSIFace * IDOS = cc->cc_IDOS; \
struct Library * DOSBase = cc->cc_DOSBase
#define DECLARE_LOCALEBASE(cc) \
struct LocaleIFace * ILocale = cc->cc_ILocale; \
struct Library * LocaleBase = cc->cc_LocaleBase
#define DECLARE_SOCKETBASE(cc) \
struct SocketIFace * ISocket = cc->cc_ISocket; \
struct Library * SocketBase = cc->cc_SocketBase
/****************************************************************************/
#else
/****************************************************************************/
#define DECLARE_SYSBASE(cc) \
struct Library * SysBase = cc->cc_SysBase
#define DECLARE_DOSBASE(cc) \
struct Library * DOSBase = cc->cc_DOSBase
#define DECLARE_LOCALEBASE(cc) \
struct Library * LocaleBase = cc->cc_LocaleBase
#define DECLARE_SOCKETBASE(cc) \
struct Library * SocketBase = cc->cc_SocketBase
/****************************************************************************/
#endif /* __amigaos4__ */
/****************************************************************************/
LONG _start(VOID);
/****************************************************************************/
STATIC VOID close_libs(struct CommandContext *cc);
STATIC LONG open_libs(struct CommandContext *cc, struct Library *SysBase);
STATIC LONG cmd(struct CommandContext *cc);
STATIC LONG VARARGS68K Local_Printf(struct CommandContext *cc, STRPTR format, ...);
STATIC LONG VARARGS68K Local_ErrorPrintf(struct CommandContext *cc, STRPTR format, ...);
STATIC STRPTR get_builtin_str(LONG id);
STATIC STRPTR get_str(struct CommandContext *cc, LONG id);
STATIC LONG VARARGS68K Local_SocketBaseTags(struct CommandContext *cc, ...);
STATIC LONG VARARGS68K Local_DeleteRouteTags(struct CommandContext *cc, ...);
/****************************************************************************/
/****** ROADSHOW/DELETENETROUTE ************************************************
*
* NAME
* DeleteNetRoute - Delete a message routing path currently in use.
*
* FORMAT
* DeleteNetRoute [QUIET] [DESTINATION=<ip>] [DEFAULTGATEWAY=<ip>]
*
* TEMPLATE
* QUIET/S,DST=DESTINATION/K,DEFAULT=DEFAULTGATEWAY/K
*
* PATH
* C:DELETENETROUTE
*
* FUNCTION
* The commands removes a route that was defined in your network.
*
* OPTIONS
* QUIET/S
* This option causes the program not to emit any error messages
* or progress reports. Also, if the program encounters an error
* it will flag this as failure code 5 which can be looked at
* using the "if warn" shell script command. If this option is
* not in effect, failure codes will be more severe and all sorts
* of progress information will be displayed.
*
* DST=DESTINATION/K
* The destination address of a route (or in other words, where
* the route to be added leads to) that should be deleted. This
* must be an IP address or a symbolic name.
*
* DEFAULT=DEFAULTGATEWAY/K
* The default gateway address to be deleted. This must be an
* IP address or a symbolic name.
*
* NOTES
* This command is similar to the Unix "route" command.
*
* You can try to delete a route that doesn't exist, but it will
* get you an error message instead of failing gracefully.
*
* SEE ALSO
* AddNetRoute
******************************************************************************
*/
LONG
_start(VOID)
{
struct Library *SysBase = (struct Library *)AbsExecBase;
#if defined(__amigaos4__)
struct ExecIFace * IExec = (struct ExecIFace *)((struct ExecBase *)SysBase)->MainInterface;
#endif /* __amigaos4__ */
struct CommandContext _cc,*cc = &_cc;
LONG result = RETURN_FAIL;
struct Process * pr;
LONG error;
memset(cc,0,sizeof(*cc));
pr = (struct Process *)FindTask(NULL);
if(pr->pr_CLI == ZERO)
{
struct MsgPort * mp = &pr->pr_MsgPort;
struct Message * mn;
WaitPort(mp);
mn = GetMsg(mp);
Forbid();
ReplyMsg(mn);
goto out;
}
error = open_libs(cc,SysBase);
if(error == OK)
{
DECLARE_LOCALEBASE(cc);
if(cc->cc_LocaleBase != NULL)
cc->cc_Catalog = OpenCatalogA(NULL,"roadshow.catalog",NULL);
result = cmd(cc);
if(cc->cc_Catalog != NULL)
CloseCatalog(cc->cc_Catalog);
}
else
{
pr->pr_Result2 = error;
}
close_libs(cc);
out:
return(result);
}
/****************************************************************************/
STATIC VOID
close_libs(struct CommandContext * cc)
{
DECLARE_SYSBASE(cc);
#if defined(__amigaos4__)
{
if(cc->cc_IDOS != NULL)
DropInterface((struct Interface *)cc->cc_IDOS);
if(cc->cc_ILocale != NULL)
DropInterface((struct Interface *)cc->cc_ILocale);
if(cc->cc_ISocket != NULL)
DropInterface((struct Interface *)cc->cc_ISocket);
}
#endif /* __amigaos4__ */
if(cc->cc_SocketBase != NULL)
CloseLibrary(cc->cc_SocketBase);
if(cc->cc_LocaleBase != NULL)
CloseLibrary(cc->cc_LocaleBase);
if(cc->cc_DOSBase != NULL)
CloseLibrary(cc->cc_DOSBase);
}
/****************************************************************************/
STATIC LONG
open_libs(struct CommandContext * cc,struct Library *SysBase)
{
#if defined(__amigaos4__)
struct ExecIFace * IExec = (struct ExecIFace *)((struct ExecBase *)SysBase)->MainInterface;
#endif /* __amigaos4__ */
LONG error;
cc->cc_SysBase = SysBase;
#if defined(__amigaos4__)
{
cc->cc_IExec = IExec;
}
#endif /* __amigaos4__ */
cc->cc_DOSBase = OpenLibrary("dos.library",36);
#if defined(__amigaos4__)
{
if(cc->cc_DOSBase != NULL)
{
cc->cc_IDOS = (struct DOSIFace *)GetInterface(cc->cc_DOSBase, "main", 1, 0);
if(cc->cc_IDOS == NULL)
{
CloseLibrary(cc->cc_DOSBase);
cc->cc_DOSBase = NULL;
}
}
}
#endif /* __amigaos4__ */
if(cc->cc_DOSBase == NULL)
{
error = ERROR_INVALID_RESIDENT_LIBRARY;
goto out;
}
cc->cc_LocaleBase = OpenLibrary("locale.library",38);
#if defined(__amigaos4__)
{
if(cc->cc_LocaleBase != NULL)
{
cc->cc_ILocale = (struct LocaleIFace *)GetInterface(cc->cc_LocaleBase, "main", 1, 0);
if(cc->cc_ILocale == NULL)
{
CloseLibrary(cc->cc_LocaleBase);
cc->cc_LocaleBase = NULL;
}
}
}
#endif /* __amigaos4__ */
/* The following may be necessary to flush out an inoperable
bsdsocket.library which reached the end of the shutdown
process. */
#if 1
{
struct ExecBase * ex = (struct ExecBase *)SysBase;
struct Library * lib;
Forbid();
lib = (struct Library *)FindName(&ex->LibList,"bsdsocket.library");
if(lib != NULL)
RemLibrary(lib);
Permit();
}
#endif
cc->cc_SocketBase = OpenLibrary("bsdsocket.library",4);
#if defined(__amigaos4__)
{
if(cc->cc_SocketBase != NULL)
{
cc->cc_ISocket = (struct SocketIFace *)GetInterface(cc->cc_SocketBase, "main", 1, 0);
if(cc->cc_ISocket == NULL)
{
CloseLibrary(cc->cc_SocketBase);
cc->cc_SocketBase = NULL;
}
}
}
#endif /* __amigaos4__ */
error = OK;
out:
return(error);
}
/****************************************************************************/
#define CATCOMP_ARRAY
#define DELETENETROUTE_CATALOG_STRINGS
#include "roadshow.h"
/****************************************************************************/
STATIC LONG
cmd(struct CommandContext * cc)
{
struct
{
SWITCH Quiet;
KEY Destination;
KEY DefaultGateway;
} args;
STRPTR args_template =
"QUIET/S,"
"DST=DESTINATION/K,"
"DEFAULT=DEFAULTGATEWAY/K"
VERSTAG;
DECLARE_DOSBASE(cc);
DECLARE_SOCKETBASE(cc);
LONG result = RETURN_FAIL;
LONG have_routing_api = FALSE;
struct RDArgs * rda;
BOOL quiet = FALSE;
GetProgramName(cc->cc_ProgramName,sizeof(cc->cc_ProgramName));
memset(&args,0,sizeof(args));
rda = ReadArgs(args_template,(LONG *)&args,NULL);
if(rda == NULL)
{
PrintFault(IoErr(),cc->cc_ProgramName);
goto out;
}
quiet = (BOOL)(args.Quiet != 0);
if(SocketBase == NULL)
{
if(NOT quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_DELETENETROUTE_CANNOT_OPEN_BSDSOCKET_TXT),
cc->cc_ProgramName);
}
goto out;
}
if(Local_SocketBaseTags(cc,
SBTM_GETREF(SBTC_HAVE_ROUTING_API),&have_routing_api,
TAG_END) != 0)
{
have_routing_api = FALSE;
}
if(NOT have_routing_api)
{
if(NOT quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_DELETENETROUTE_BSDSOCKET_HAS_NO_ROUTE_API_TXT),
cc->cc_ProgramName, SocketBase->lib_Node.ln_Name, SocketBase->lib_Version, SocketBase->lib_Revision);
}
goto out;
}
if(args.Destination == NULL && args.DefaultGateway == NULL)
{
if(NOT quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_DELETENETROUTE_NEED_EITHER_DESTINATION_OR_DEFAULT_TXT),
cc->cc_ProgramName);
}
goto out;
}
if(args.DefaultGateway != NULL && args.Destination != NULL)
{
if(NOT quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_DELETENETROUTE_DESTINATION_IGNORED_TXT),
cc->cc_ProgramName,args.Destination);
}
args.Destination = NULL;
}
if(Local_DeleteRouteTags(cc,
(args.Destination != NULL) ? RTA_Destination : TAG_IGNORE, args.Destination,
(args.DefaultGateway != NULL) ? RTA_DefaultGateway : TAG_IGNORE, args.DefaultGateway,
TAG_END) != OK)
{
if(NOT quiet)
{
LONG errno = 0;
LONG code;
Local_SocketBaseTags(cc,
SBTM_GETREF(SBTC_ERRNO),&errno,
TAG_END);
code = errno;
if(Local_SocketBaseTags(cc,
SBTM_GETREF(SBTC_ERRNOSTRPTR),&code,
TAG_END) != 0)
{
code = 0;
}
if(args.DefaultGateway != NULL)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_DELETENETROUTE_ROUTE_TO_DEFAULT_GATEWAY_NOT_DELETED_TXT),
cc->cc_ProgramName,args.DefaultGateway);
}
else
{
Local_ErrorPrintf(cc,get_str(cc,MSG_DELETENETROUTE_ROUTE_NOT_DELETED_TXT),
cc->cc_ProgramName,args.Destination);
}
if(code > 0 && errno > 0)
Local_ErrorPrintf(cc," (%s)",code);
Local_ErrorPrintf(cc,".\n");
}
goto out;
}
if(NOT quiet)
{
LONG message_code;
if(args.DefaultGateway != NULL)
message_code = MSG_DELETENETROUTE_ROUTE_TO_DEFAULT_DELETED_TXT;
else
message_code = MSG_DELETENETROUTE_ROUTE_DELETED_TXT;
Local_Printf(cc,get_str(cc,message_code),
cc->cc_ProgramName,args.DefaultGateway);
}
result = RETURN_OK;
out:
if(quiet && result != RETURN_OK)
result = RETURN_WARN;
if(rda != NULL)
FreeArgs(rda);
return(result);
}
/****************************************************************************/
STATIC LONG VARARGS68K
Local_Printf(struct CommandContext * cc,STRPTR format,...)
{
DECLARE_DOSBASE(cc);
va_list args;
LONG result;
#if defined(__amigaos4__)
{
va_startlinear(args,format);
result = VPrintf(format,va_getlinearva(args,APTR));
va_end(args);
}
#else
{
va_start(args,format);
result = VPrintf(format,args);
va_end(args);
}
#endif /* __amigaos4__ */
return(result);
}
/****************************************************************************/
STATIC LONG VARARGS68K
Local_ErrorPrintf(struct CommandContext * cc,STRPTR format,...)
{
DECLARE_DOSBASE(cc);
DECLARE_SYSBASE(cc);
va_list args;
LONG result;
BPTR fh;
#if defined(__amigaos4__)
{
fh = ErrorOutput();
}
#else
{
struct Process * this_process = (struct Process *)FindTask(NULL);
fh = this_process->pr_CES;
}
#endif /* __amigaos4__ */
if(fh == ZERO)
fh = Output();
#if defined(__amigaos4__)
{
va_startlinear(args,format);
result = VFPrintf(fh,format,va_getlinearva(args,APTR));
va_end(args);
}
#else
{
va_start(args,format);
result = VFPrintf(fh,format,args);
va_end(args);
}
#endif /* __amigaos4__ */
return(result);
}
/****************************************************************************/
/* This looks up a locale string ID in the builtin database; adapted
from CygnusEd because I couldn't find my own implementation for this
application... */
STATIC STRPTR
get_builtin_str(LONG id)
{
LONG top,middle,bottom;
STRPTR builtin_string;
/* The search area is all those message between bottom and top, inclusive. */
bottom = 0;
top = NUM_ENTRIES(CatCompArray) - 1;
/* Binary search through the CatCompArray to find the requested string.
Note that this assumes that the strings are sorted. Catcomp defaults
to creating sorted arrays, but it does _not_ force it. If in the .cd
file you specify out of order string numbers this routine will fail.*/
while(bottom != top)
{
middle = (bottom + top) / 2;
if(CatCompArray[middle].cca_ID >= id)
top = middle;
else
bottom = middle + 1;
}
/* The only time this error message should occur is if you've passed
a garbage number OR if the CatCompArray is not sorted. */
if(CatCompArray[bottom].cca_ID == id)
builtin_string = (STRPTR)CatCompArray[bottom].cca_Str;
else
builtin_string = "";
return(builtin_string);
}
STATIC STRPTR
get_str(struct CommandContext * cc, LONG id)
{
STRPTR builtin_string;
STRPTR result;
builtin_string = get_builtin_str(id);
if(cc->cc_Catalog != NULL)
{
DECLARE_LOCALEBASE(cc);
result = (STRPTR)GetCatalogStr(cc->cc_Catalog,id,builtin_string);
}
else
{
result = builtin_string;
}
return(result);
}
/****************************************************************************/
STATIC LONG VARARGS68K
Local_SocketBaseTags(struct CommandContext * cc,...)
{
DECLARE_SOCKETBASE(cc);
va_list args;
LONG result;
#if defined(__amigaos4__)
{
va_startlinear(args,cc);
result = SocketBaseTagList(va_getlinearva(args,struct TagItem *));
va_end(args);
}
#else
{
va_start(args,cc);
result = SocketBaseTagList((struct TagItem *)args);
va_end(args);
}
#endif /* __amigaos4__ */
return(result);
}
STATIC LONG VARARGS68K
Local_DeleteRouteTags(struct CommandContext * cc,...)
{
DECLARE_SOCKETBASE(cc);
va_list args;
LONG result;
#if defined(__amigaos4__)
{
va_startlinear(args,cc);
result = DeleteRouteTagList(va_getlinearva(args,struct TagItem *));
va_end(args);
}
#else
{
va_start(args,cc);
result = DeleteRouteTagList((struct TagItem *)args);
va_end(args);
}
#endif /* __amigaos4__ */
return(result);
}

View File

@ -1,6 +0,0 @@
#define VERSION 4
#define REVISION 8
#define DATE "11.3.2009"
#define VERS "DeleteNetRoute 4.8"
#define VSTRING "DeleteNetRoute 4.8 (11.3.2009)\r\n"
#define VERSTAG "\0$VER: DeleteNetRoute 4.8 (11.3.2009)"

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +0,0 @@
#define VERSION 4
#define REVISION 9
#define DATE "11.3.2009"
#define VERS "GetNetStatus 4.9"
#define VSTRING "GetNetStatus 4.9 (11.3.2009)\r\n"
#define VERSTAG "\0$VER: GetNetStatus 4.9 (11.3.2009)"

View File

@ -1,755 +0,0 @@
/*
* $Id: NetShutdown.c,v 1.15 2007-08-26 12:30:16 obarthel Exp $
*
* :ts=4
*
* Copyright © 2001-2007 by Olaf Barthel. All Rights Reserved.
*/
#include <libraries/bsdsocket.h>
#include <exec/execbase.h>
#include <exec/memory.h>
#include <devices/timer.h>
#include <dos/dosextens.h>
#include <dos/dostags.h>
#include <dos/dosasl.h>
#include <dos/rdargs.h>
#include <dos/stdio.h>
#include <libraries/locale.h>
/****************************************************************************/
#if defined(__amigaos4__)
#include <dos/obsolete.h>
#endif /* __amigaos4__ */
/****************************************************************************/
#if !defined(__amigaos4__)
#define NO_INLINE_STDARG
#endif /* __amigaos4__ */
#define __NOLIBBASE__
#define __NOGLOBALIFACE__
#define __USE_INLINE__
/****************************************************************************/
#include <proto/locale.h>
#include <proto/exec.h>
#include <proto/dos.h>
/****************************************************************************/
#include <string.h>
#include <stdarg.h>
/****************************************************************************/
#include "macros.h"
/****************************************************************************/
#include "NetShutdown_rev.h"
/****************************************************************************/
#ifndef AbsExecBase
#define AbsExecBase (*(struct ExecBase **)4)
#endif /* AbsExecBase */
/****************************************************************************/
typedef LONG * NUMBER;
typedef LONG SWITCH;
typedef STRPTR KEY;
/****************************************************************************/
struct CommandContext
{
struct Library * cc_SysBase;
struct Library * cc_DOSBase;
struct Library * cc_LocaleBase;
#if defined(__amigaos4__)
/************************************************************************/
struct ExecIFace * cc_IExec;
struct DOSIFace * cc_IDOS;
struct LocaleIFace * cc_ILocale;
/************************************************************************/
#endif /* __amigaos4__ */
struct Catalog * cc_Catalog;
UBYTE cc_ProgramName[256];
};
/****************************************************************************/
#if defined(__amigaos4__)
/****************************************************************************/
#define DECLARE_SYSBASE(cc) \
struct ExecIFace * IExec = cc->cc_IExec; \
struct Library * SysBase = cc->cc_SysBase
#define DECLARE_DOSBASE(cc) \
struct DOSIFace * IDOS = cc->cc_IDOS; \
struct Library * DOSBase = cc->cc_DOSBase
#define DECLARE_LOCALEBASE(cc) \
struct LocaleIFace * ILocale = cc->cc_ILocale; \
struct Library * LocaleBase = cc->cc_LocaleBase
/****************************************************************************/
#else
/****************************************************************************/
#define DECLARE_SYSBASE(cc) \
struct Library * SysBase = cc->cc_SysBase
#define DECLARE_DOSBASE(cc) \
struct Library * DOSBase = cc->cc_DOSBase
#define DECLARE_LOCALEBASE(cc) \
struct Library * LocaleBase = cc->cc_LocaleBase
/****************************************************************************/
#endif /* __amigaos4__ */
/****************************************************************************/
LONG _start(VOID);
/****************************************************************************/
STATIC VOID close_libs(struct CommandContext *cc);
STATIC LONG open_libs(struct CommandContext *cc, struct Library *SysBase);
STATIC LONG cmd(struct CommandContext *cc);
STATIC LONG VARARGS68K Local_Printf(struct CommandContext *cc, STRPTR format, ...);
STATIC LONG VARARGS68K Local_ErrorPrintf(struct CommandContext *cc, STRPTR format, ...);
STATIC STRPTR get_builtin_str(LONG id);
STATIC STRPTR get_str(struct CommandContext *cc, LONG id);
/****************************************************************************/
/****** ROADSHOW/NETSHUTDOWN **************************************************
*
* NAME
* NetShutdown - Attempt to shut down the network in an orderly fashion.
*
* FORMAT
* NetShutdown [TIMEOUT=<secs>] [QUIET]
*
* TEMPLATE
* TIMEOUT/N,QUIET/S
*
* FUNCTION
* The command will stop all running interfaces.
*
* OPTIONS
* TIMEOUT/N
* How many seconds this command should wait until it gives up. By
* default, it will wait up to 5 seconds for the network to shut
* down once it has triggered the shutdown process.
*
* QUIET/S
* Use this parameter to stop the command from reporting what it
* is currently doing.
*
* NOTES
* The "NetShutdown" command will trigger the shutdown process of the
* network. This process cannot be stopped once it has started. However,
* this command can make an attempt to wait until the shutdown has
* completed. Normally, the shutdown should be finished in a fraction of
* a second, but at times when other clients still hang onto the network
* resources, the shutdown can fail to complete quite so quickly. In that
* case, the "NetShutdown" command will tell you that it could not
* complete its task within the allocated time frame (within five
* seconds, or whatever timeout you specified). The shutdown, however,
* will proceed and may conclude at a later time.
*
* When this command starts up it begins by checking if the network is
* currently operational. If this is not the case, it will exit
* immediately, printing a message to this effect.
*
* SEE ALSO
* AddNetInterface
* ShowNetStatus
*******************************************************************************
*/
LONG
_start(VOID)
{
struct Library *SysBase = (struct Library *)AbsExecBase;
#if defined(__amigaos4__)
struct ExecIFace * IExec = (struct ExecIFace *)((struct ExecBase *)SysBase)->MainInterface;
#endif /* __amigaos4__ */
struct CommandContext _cc,*cc = &_cc;
LONG result = RETURN_FAIL;
struct Process * pr;
LONG error;
memset(cc,0,sizeof(*cc));
pr = (struct Process *)FindTask(NULL);
if(pr->pr_CLI == ZERO)
{
struct MsgPort * mp = &pr->pr_MsgPort;
struct Message * mn;
WaitPort(mp);
mn = GetMsg(mp);
Forbid();
ReplyMsg(mn);
goto out;
}
error = open_libs(cc,SysBase);
if(error == OK)
{
DECLARE_LOCALEBASE(cc);
if(cc->cc_LocaleBase != NULL)
cc->cc_Catalog = OpenCatalogA(NULL,"roadshow.catalog",NULL);
result = cmd(cc);
if(cc->cc_Catalog != NULL)
CloseCatalog(cc->cc_Catalog);
}
else
{
pr->pr_Result2 = error;
}
close_libs(cc);
out:
return(result);
}
/****************************************************************************/
STATIC VOID
close_libs(struct CommandContext * cc)
{
DECLARE_SYSBASE(cc);
#if defined(__amigaos4__)
{
if(cc->cc_IDOS != NULL)
DropInterface((struct Interface *)cc->cc_IDOS);
if(cc->cc_ILocale != NULL)
DropInterface((struct Interface *)cc->cc_ILocale);
}
#endif /* __amigaos4__ */
if(cc->cc_LocaleBase != NULL)
CloseLibrary(cc->cc_LocaleBase);
if(cc->cc_DOSBase != NULL)
CloseLibrary(cc->cc_DOSBase);
}
/****************************************************************************/
STATIC LONG
open_libs(struct CommandContext * cc,struct Library *SysBase)
{
#if defined(__amigaos4__)
struct ExecIFace * IExec = (struct ExecIFace *)((struct ExecBase *)SysBase)->MainInterface;
#endif /* __amigaos4__ */
LONG error;
cc->cc_SysBase = SysBase;
#if defined(__amigaos4__)
{
cc->cc_IExec = IExec;
}
#endif /* __amigaos4__ */
cc->cc_DOSBase = OpenLibrary("dos.library",36);
#if defined(__amigaos4__)
{
if(cc->cc_DOSBase != NULL)
{
cc->cc_IDOS = (struct DOSIFace *)GetInterface(cc->cc_DOSBase, "main", 1, 0);
if(cc->cc_IDOS == NULL)
{
CloseLibrary(cc->cc_DOSBase);
cc->cc_DOSBase = NULL;
}
}
}
#endif /* __amigaos4__ */
if(cc->cc_DOSBase == NULL)
{
error = ERROR_INVALID_RESIDENT_LIBRARY;
goto out;
}
cc->cc_LocaleBase = OpenLibrary("locale.library",38);
#if defined(__amigaos4__)
{
if(cc->cc_LocaleBase != NULL)
{
cc->cc_ILocale = (struct LocaleIFace *)GetInterface(cc->cc_LocaleBase, "main", 1, 0);
if(cc->cc_ILocale == NULL)
{
CloseLibrary(cc->cc_LocaleBase);
cc->cc_LocaleBase = NULL;
}
}
}
#endif /* __amigaos4__ */
error = OK;
out:
return(error);
}
/****************************************************************************/
#define CATCOMP_ARRAY
#define NETSHUTDOWN_CATALOG_STRINGS
#include "roadshow.h"
/****************************************************************************/
STATIC LONG
cmd(struct CommandContext * cc)
{
struct
{
NUMBER Timeout;
SWITCH Quiet;
} args;
STRPTR args_template =
"TIMEOUT/N,"
"QUIET/S"
VERSTAG;
DECLARE_SYSBASE(cc);
DECLARE_DOSBASE(cc);
struct MsgPort * timer_port = NULL;
struct timerequest * timer_request = NULL;
BOOL timer_ticking = FALSE;
LONG result = RETURN_FAIL;
struct RDArgs * rda;
struct MsgPort * reply_port = NULL;
LONG timeout;
ULONG reply_mask;
ULONG timer_mask;
ULONG signals;
struct NetControlPort * control_port;
struct NetShutdownMessage * shutdown_message = NULL;
struct NetShutdownMessage * recall_message = NULL;
LONG client_count = 0;
BOOL network_in_use;
GetProgramName(cc->cc_ProgramName,sizeof(cc->cc_ProgramName));
memset(&args,0,sizeof(args));
rda = ReadArgs(args_template,(LONG *)&args,NULL);
if(rda == NULL)
{
PrintFault(IoErr(),cc->cc_ProgramName);
goto out;
}
/* We wait for up to 5 seconds for the network to shut down. */
timeout = 5;
if(args.Timeout != NULL)
{
/* The user can override the timeout, but the minimum wait time
is exactly one second. */
timeout = (*args.Timeout);
if(timeout < 1)
{
if(NOT args.Quiet)
PrintFault(ERROR_BAD_NUMBER,cc->cc_ProgramName);
goto out;
}
}
shutdown_message = AllocVec(sizeof(*shutdown_message),MEMF_ANY|MEMF_PUBLIC|MEMF_CLEAR);
recall_message = AllocVec(sizeof(*shutdown_message),MEMF_ANY|MEMF_PUBLIC|MEMF_CLEAR);
if(shutdown_message == NULL || recall_message == NULL)
{
if(NOT args.Quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_NETSHUTDOWN_NO_MEMORY_TXT),
cc->cc_ProgramName);
}
goto out;
}
reply_port = CreateMsgPort();
if(reply_port == NULL)
{
if(NOT args.Quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_NETSHUTDOWN_NO_MSGPORT_TXT),
cc->cc_ProgramName);
}
goto out;
}
shutdown_message->nsm_Message.mn_ReplyPort = reply_port;
shutdown_message->nsm_Message.mn_Length = sizeof(*shutdown_message);
shutdown_message->nsm_Command = NSMC_Shutdown;
shutdown_message->nsm_Data = &client_count;
shutdown_message->nsm_Length = sizeof(client_count);
recall_message->nsm_Message.mn_ReplyPort = reply_port;
recall_message->nsm_Message.mn_Length = sizeof(*recall_message);
recall_message->nsm_Command = NSMC_Cancel;
recall_message->nsm_Data = shutdown_message;
recall_message->nsm_Length = sizeof(shutdown_message);
timer_port = CreateMsgPort();
if(timer_port == NULL)
{
if(NOT args.Quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_NETSHUTDOWN_NO_MSGPORT_TXT),
cc->cc_ProgramName);
}
goto out;
}
timer_request = (struct timerequest *)CreateIORequest(timer_port,sizeof(*timer_request));
if(timer_request == NULL)
{
if(NOT args.Quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_NETSHUTDOWN_NO_TIMER_REQUEST_TXT),
cc->cc_ProgramName);
}
goto out;
}
if(OpenDevice(TIMERNAME,UNIT_VBLANK,(struct IORequest *)timer_request,0) != OK)
{
if(NOT args.Quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_NETSHUTDOWN_NO_TIMER_DEVICE_TXT),
cc->cc_ProgramName,TIMERNAME);
}
goto out;
}
/* Try to send the shutdown message. */
Forbid();
control_port = (struct NetControlPort *)FindPort(NETWORK_CONTROLLER_PORT_NAME);
if(control_port != NULL && control_port->ncp_Magic == NCPM_Cookie)
{
network_in_use = TRUE;
PutMsg(&control_port->ncp_Port,(struct Message *)shutdown_message);
}
else
{
network_in_use = FALSE;
}
Permit();
if(NOT network_in_use)
{
if(NOT args.Quiet)
Local_ErrorPrintf(cc,get_str(cc,MSG_NETSHUTDOWN_NETWORK_NOT_IN_USE_TXT),cc->cc_ProgramName);
result = RETURN_WARN;
goto out;
}
reply_mask = (1UL << reply_port->mp_SigBit);
timer_mask = (1UL << timer_port->mp_SigBit);
/* Get the timeout rolling... */
timer_request->tr_node.io_Command = TR_ADDREQUEST;
timer_request->tr_time.tv_secs = timeout;
timer_request->tr_time.tv_micro = 0;
SendIO((struct IORequest *)timer_request);
timer_ticking = TRUE;
if(NOT args.Quiet)
{
Local_Printf(cc,get_str(cc,MSG_NETSHUTDOWN_TRYING_TO_SHUT_DOWN_TXT));
Flush(Output());
}
/* Wait for one of three events: the 'all clear' signal from the network
controller, the user not wanting to wait any longer and the timer to
elapse. */
signals = Wait(SIGBREAKF_CTRL_C | reply_mask | timer_mask);
/* Did we get the 'all clear' signal? */
if(signals & reply_mask)
{
struct ExecBase * ExecBase = (struct ExecBase *)SysBase;
struct Library * lib;
/* Pick up the message that is waiting. */
GetMsg(reply_port);
/* Flush the library from memory. */
Forbid();
lib = (struct Library *)FindName(&ExecBase->LibList,"bsdsocket.library");
if(lib != NULL)
RemLibrary(lib);
Permit();
if(NOT args.Quiet)
Local_Printf(cc,get_str(cc,MSG_NETSHUTDOWN_SHUTDOWN_DONE_TXT));
result = RETURN_OK;
}
else
{
/* OK, so we need to recall the shutdown message before we bow out. */
Forbid();
/* Look for the controller port again since it may have gone away
while we were printing messages to the console, etc. above. */
control_port = (struct NetControlPort *)FindPort(NETWORK_CONTROLLER_PORT_NAME);
if(control_port != NULL && control_port->ncp_Magic != NCPM_Cookie)
PutMsg(&control_port->ncp_Port,(struct Message *)recall_message);
Permit();
/* Wait for the two messages to return. This is indicated by the
message node types changing from NT_MESSAGE to NT_REPLYMSG, or
the message type never even changing to NT_MESSAGE (if the
message is never sent). */
while(shutdown_message->nsm_Message.mn_Node.ln_Type == NT_MESSAGE ||
recall_message->nsm_Message.mn_Node.ln_Type == NT_MESSAGE)
{
WaitPort(reply_port);
while(TRUE)
{
if(GetMsg(reply_port) == NULL)
break;
}
}
result = RETURN_WARN;
if(NOT args.Quiet)
{
LONG message_code;
if(signals & SIGBREAKF_CTRL_C)
message_code = MSG_NETSHUTDOWN_SHUTDOWN_ABORTED_TXT;
else
message_code = MSG_NETSHUTDOWN_SHUTDOWN_TIMEOUT_TXT;
Local_Printf(cc,get_str(cc,message_code));
}
}
out:
if(timer_request != NULL)
{
if(timer_ticking)
{
if(CheckIO((struct IORequest *)timer_request) == NULL)
AbortIO((struct IORequest *)timer_request);
WaitIO((struct IORequest *)timer_request);
}
if(timer_request->tr_node.io_Device != NULL)
CloseDevice((struct IORequest *)timer_request);
DeleteIORequest((struct IORequest *)timer_request);
}
DeleteMsgPort(timer_port);
DeleteMsgPort(reply_port);
FreeVec(shutdown_message);
FreeVec(recall_message);
if(rda != NULL)
FreeArgs(rda);
return(result);
}
/****************************************************************************/
STATIC LONG VARARGS68K
Local_Printf(struct CommandContext * cc,STRPTR format,...)
{
DECLARE_DOSBASE(cc);
va_list args;
LONG result;
#if defined(__amigaos4__)
{
va_startlinear(args,format);
result = VPrintf(format,va_getlinearva(args,APTR));
va_end(args);
}
#else
{
va_start(args,format);
result = VPrintf(format,args);
va_end(args);
}
#endif /* __amigaos4__ */
return(result);
}
/****************************************************************************/
STATIC LONG VARARGS68K
Local_ErrorPrintf(struct CommandContext * cc,STRPTR format,...)
{
DECLARE_DOSBASE(cc);
DECLARE_SYSBASE(cc);
va_list args;
LONG result;
BPTR fh;
#if defined(__amigaos4__)
{
fh = ErrorOutput();
}
#else
{
struct Process * this_process = (struct Process *)FindTask(NULL);
fh = this_process->pr_CES;
}
#endif /* __amigaos4__ */
if(fh == ZERO)
fh = Output();
#if defined(__amigaos4__)
{
va_startlinear(args,format);
result = VFPrintf(fh,format,va_getlinearva(args,APTR));
va_end(args);
}
#else
{
va_start(args,format);
result = VFPrintf(fh,format,args);
va_end(args);
}
#endif /* __amigaos4__ */
return(result);
}
/****************************************************************************/
/* This looks up a locale string ID in the builtin database; adapted
from CygnusEd because I couldn't find my own implementation for this
application... */
STATIC STRPTR
get_builtin_str(LONG id)
{
LONG top,middle,bottom;
STRPTR builtin_string;
/* The search area is all those message between bottom and top, inclusive. */
bottom = 0;
top = NUM_ENTRIES(CatCompArray) - 1;
/* Binary search through the CatCompArray to find the requested string.
Note that this assumes that the strings are sorted. Catcomp defaults
to creating sorted arrays, but it does _not_ force it. If in the .cd
file you specify out of order string numbers this routine will fail. */
while(bottom != top)
{
middle = (bottom + top) / 2;
if(CatCompArray[middle].cca_ID >= id)
top = middle;
else
bottom = middle + 1;
}
/* The only time this error message should occur is if you've passed
a garbage number OR if the CatCompArray is not sorted. */
if(CatCompArray[bottom].cca_ID == id)
builtin_string = (STRPTR)CatCompArray[bottom].cca_Str;
else
builtin_string = "";
return(builtin_string);
}
STATIC STRPTR
get_str(struct CommandContext * cc, LONG id)
{
STRPTR builtin_string;
STRPTR result;
builtin_string = get_builtin_str(id);
if(cc->cc_Catalog != NULL)
{
DECLARE_LOCALEBASE(cc);
result = (STRPTR)GetCatalogStr(cc->cc_Catalog,id,builtin_string);
}
else
{
result = builtin_string;
}
return(result);
}

View File

@ -1,6 +0,0 @@
#define VERSION 4
#define REVISION 7
#define DATE "11.3.2009"
#define VERS "NetShutdown 4.7"
#define VSTRING "NetShutdown 4.7 (11.3.2009)\r\n"
#define VERSTAG "\0$VER: NetShutdown 4.7 (11.3.2009)"

View File

@ -1,12 +0,0 @@
This directory contains the source code of the programs that call into
the Roadshow bsdsocket.library to configure the TCP/IP stack and to query
status information. These programs should compile out of the box, provided
you have the necessary SDK header files installed. I tried to keep all
the necessary files together, but it might not be the complete set.
Don't worry, though, the code is merely intended to be a demonstration
as to how to do what the configuration/query programs are doing.
This software is copyrighted, which means that you may create your own
programs using the techniques demonstrated in the source code, and
you may reuse parts of it, but you must not take this code as a whole
and claim it as your own.

View File

@ -1,650 +0,0 @@
/*
* $Id: RemoveNetInterface.c,v 1.6 2007-08-26 12:30:16 obarthel Exp $
*
* :ts=4
*
* Copyright © 2001-2007 by Olaf Barthel. All Rights Reserved.
*/
#include <libraries/bsdsocket.h>
#include <exec/execbase.h>
#include <exec/memory.h>
#include <dos/dosextens.h>
#include <dos/dostags.h>
#include <dos/dosasl.h>
#include <dos/rdargs.h>
#include <dos/stdio.h>
#include <libraries/locale.h>
/****************************************************************************/
#if defined(__amigaos4__)
#include <dos/obsolete.h>
#endif /* __amigaos4__ */
/****************************************************************************/
#if !defined(__amigaos4__)
#define NO_INLINE_STDARG
#endif /* __amigaos4__ */
#define __NOLIBBASE__
#define __NOGLOBALIFACE__
#define __USE_INLINE__
/****************************************************************************/
#include <proto/bsdsocket.h>
#include <proto/locale.h>
#include <proto/exec.h>
#include <proto/dos.h>
/****************************************************************************/
#include <string.h>
#include <stdarg.h>
/****************************************************************************/
#include "macros.h"
/****************************************************************************/
#include "RemoveNetInterface_rev.h"
/****************************************************************************/
#ifndef AbsExecBase
#define AbsExecBase (*(struct ExecBase **)4)
#endif /* AbsExecBase */
/****************************************************************************/
typedef LONG * NUMBER;
typedef LONG SWITCH;
typedef STRPTR KEY;
/****************************************************************************/
struct CommandContext
{
struct Library * cc_SysBase;
struct Library * cc_DOSBase;
struct Library * cc_SocketBase;
struct Library * cc_LocaleBase;
#if defined(__amigaos4__)
/************************************************************************/
struct ExecIFace * cc_IExec;
struct DOSIFace * cc_IDOS;
struct SocketIFace * cc_ISocket;
struct LocaleIFace * cc_ILocale;
/************************************************************************/
#endif /* __amigaos4__ */
struct Catalog * cc_Catalog;
UBYTE cc_ProgramName[256];
};
/****************************************************************************/
#if defined(__amigaos4__)
/****************************************************************************/
#define DECLARE_SYSBASE(cc) \
struct ExecIFace * IExec = cc->cc_IExec; \
struct Library * SysBase = cc->cc_SysBase
#define DECLARE_DOSBASE(cc) \
struct DOSIFace * IDOS = cc->cc_IDOS; \
struct Library * DOSBase = cc->cc_DOSBase
#define DECLARE_LOCALEBASE(cc) \
struct LocaleIFace * ILocale = cc->cc_ILocale; \
struct Library * LocaleBase = cc->cc_LocaleBase
#define DECLARE_SOCKETBASE(cc) \
struct SocketIFace * ISocket = cc->cc_ISocket; \
struct Library * SocketBase = cc->cc_SocketBase
/****************************************************************************/
#else
/****************************************************************************/
#define DECLARE_SYSBASE(cc) \
struct Library * SysBase = cc->cc_SysBase
#define DECLARE_DOSBASE(cc) \
struct Library * DOSBase = cc->cc_DOSBase
#define DECLARE_LOCALEBASE(cc) \
struct Library * LocaleBase = cc->cc_LocaleBase
#define DECLARE_SOCKETBASE(cc) \
struct Library * SocketBase = cc->cc_SocketBase
/****************************************************************************/
#endif /* __amigaos4__ */
/****************************************************************************/
LONG _start(VOID);
/****************************************************************************/
STATIC VOID close_libs(struct CommandContext *cc);
STATIC LONG open_libs(struct CommandContext *cc, struct Library *SysBase);
STATIC LONG cmd(struct CommandContext *cc);
STATIC LONG VARARGS68K Local_Printf(struct CommandContext *cc, STRPTR format, ...);
STATIC LONG VARARGS68K Local_ErrorPrintf(struct CommandContext *cc, STRPTR format, ...);
STATIC STRPTR get_builtin_str(LONG id);
STATIC STRPTR get_str(struct CommandContext *cc, LONG id);
STATIC LONG VARARGS68K Local_SocketBaseTags(struct CommandContext *cc, ...);
/****************************************************************************/
LONG
_start(VOID)
{
struct Library *SysBase = (struct Library *)AbsExecBase;
#if defined(__amigaos4__)
struct ExecIFace * IExec = (struct ExecIFace *)((struct ExecBase *)SysBase)->MainInterface;
#endif /* __amigaos4__ */
struct CommandContext _cc,*cc = &_cc;
LONG result = RETURN_FAIL;
struct Process * pr;
LONG error;
memset(cc,0,sizeof(*cc));
pr = (struct Process *)FindTask(NULL);
if(pr->pr_CLI == ZERO)
{
struct MsgPort * mp = &pr->pr_MsgPort;
struct Message * mn;
WaitPort(mp);
mn = GetMsg(mp);
Forbid();
ReplyMsg(mn);
goto out;
}
error = open_libs(cc,SysBase);
if(error == OK)
{
DECLARE_LOCALEBASE(cc);
if(cc->cc_LocaleBase != NULL)
cc->cc_Catalog = OpenCatalogA(NULL,"roadshow.catalog",NULL);
result = cmd(cc);
if(cc->cc_Catalog != NULL)
CloseCatalog(cc->cc_Catalog);
}
else
{
pr->pr_Result2 = error;
}
close_libs(cc);
out:
return(result);
}
/****************************************************************************/
STATIC VOID
close_libs(struct CommandContext * cc)
{
DECLARE_SYSBASE(cc);
#if defined(__amigaos4__)
{
if(cc->cc_IDOS != NULL)
DropInterface((struct Interface *)cc->cc_IDOS);
if(cc->cc_ILocale != NULL)
DropInterface((struct Interface *)cc->cc_ILocale);
if(cc->cc_ISocket != NULL)
DropInterface((struct Interface *)cc->cc_ISocket);
}
#endif /* __amigaos4__ */
if(cc->cc_SocketBase != NULL)
CloseLibrary(cc->cc_SocketBase);
if(cc->cc_LocaleBase != NULL)
CloseLibrary(cc->cc_LocaleBase);
if(cc->cc_DOSBase != NULL)
CloseLibrary(cc->cc_DOSBase);
}
/****************************************************************************/
STATIC LONG
open_libs(struct CommandContext * cc,struct Library *SysBase)
{
#if defined(__amigaos4__)
struct ExecIFace * IExec = (struct ExecIFace *)((struct ExecBase *)SysBase)->MainInterface;
#endif /* __amigaos4__ */
LONG error;
cc->cc_SysBase = SysBase;
#if defined(__amigaos4__)
{
cc->cc_IExec = IExec;
}
#endif /* __amigaos4__ */
cc->cc_DOSBase = OpenLibrary("dos.library",36);
#if defined(__amigaos4__)
{
if(cc->cc_DOSBase != NULL)
{
cc->cc_IDOS = (struct DOSIFace *)GetInterface(cc->cc_DOSBase, "main", 1, 0);
if(cc->cc_IDOS == NULL)
{
CloseLibrary(cc->cc_DOSBase);
cc->cc_DOSBase = NULL;
}
}
}
#endif /* __amigaos4__ */
if(cc->cc_DOSBase == NULL)
{
error = ERROR_INVALID_RESIDENT_LIBRARY;
goto out;
}
cc->cc_LocaleBase = OpenLibrary("locale.library",38);
#if defined(__amigaos4__)
{
if(cc->cc_LocaleBase != NULL)
{
cc->cc_ILocale = (struct LocaleIFace *)GetInterface(cc->cc_LocaleBase, "main", 1, 0);
if(cc->cc_ILocale == NULL)
{
CloseLibrary(cc->cc_LocaleBase);
cc->cc_LocaleBase = NULL;
}
}
}
#endif /* __amigaos4__ */
/* The following may be necessary to flush out an inoperable
bsdsocket.library which reached the end of the shutdown
process. */
#if 1
{
struct ExecBase * ex = (struct ExecBase *)SysBase;
struct Library * lib;
Forbid();
lib = (struct Library *)FindName(&ex->LibList,"bsdsocket.library");
if(lib != NULL)
RemLibrary(lib);
Permit();
}
#endif
cc->cc_SocketBase = OpenLibrary("bsdsocket.library",4);
#if defined(__amigaos4__)
{
if(cc->cc_SocketBase != NULL)
{
cc->cc_ISocket = (struct SocketIFace *)GetInterface(cc->cc_SocketBase, "main", 1, 0);
if(cc->cc_ISocket == NULL)
{
CloseLibrary(cc->cc_SocketBase);
cc->cc_SocketBase = NULL;
}
}
}
#endif /* __amigaos4__ */
error = OK;
out:
return(error);
}
/****************************************************************************/
#define CATCOMP_ARRAY
#define REMOVENETINTERFACE_CATALOG_STRINGS
#include "roadshow.h"
/****************************************************************************/
/****** ROADSHOW/REMOVENETINTERFACE ******************************************
*
* NAME
* RemoveNetInterface - Make the protocol stack forget about
* a network interface
*
* FORMAT
* RemoveNetInterface [QUIET] [FORCE] INTERFACE
*
* TEMPLATE
* INTERFACE/K,QUIET/S,FORCE/S
*
* PATH
* C:REMOVENETINTERFACE
*
* FUNCTION
* REMOVENETINTERFACE attempts to shut down the specified network
* interface, so that it may be added again with different parameters.
*
* OPTIONS
* INTERFACE/K
* The name of the interface to shut down. This must be the name
* previously given to ADDNETINTERFACE.
*
* QUIET/S
* This option causes the program not to emit any error messages
* or progress reports. Also, if the program encounters an error
* it will flag this as failure code 5 which can be looked at
* using the "if warn" shell script command. If this option is
* not in effect, failure codes will be more severe and all sorts
* of progress information will be displayed.
*
* FORCE/S
* REMOVENETINTERFACE tries not to shut down an interface which
* may still be in use. You can override this with the FORCE
* option which, however, carries the risk that not all the
* resources associated with the network interface may be released
* until you shut down the network with the NETSHUTDOWN command.
*
* EXAMPLES
* Shut down the interface called "DSL", and run quietly.
*
* 1> RemoveNetInterface DSL QUIET
*
* SEE ALSO
* AddNetInterface
* NetShutdown
*
******************************************************************************
*/
STATIC LONG
cmd(struct CommandContext * cc)
{
struct
{
KEY Interface;
SWITCH Force;
SWITCH Quiet;
} args;
STRPTR args_template =
"INTERFACE/A,"
"FORCE/S,"
"QUIET/S"
VERSTAG;
DECLARE_DOSBASE(cc);
DECLARE_SOCKETBASE(cc);
LONG result = RETURN_FAIL;
struct RDArgs * rda;
BOOL quiet = FALSE;
GetProgramName(cc->cc_ProgramName,sizeof(cc->cc_ProgramName));
memset(&args,0,sizeof(args));
rda = ReadArgs(args_template,(LONG *)&args,NULL);
if(rda == NULL)
{
PrintFault(IoErr(),cc->cc_ProgramName);
goto out;
}
quiet = (BOOL)(args.Quiet != 0);
if(SocketBase == NULL)
{
if(NOT quiet)
{
Local_ErrorPrintf(cc,get_str(cc,MSG_REMOVENETINTERFACE_CANNOT_OPEN_BSDSOCKET_TXT),
cc->cc_ProgramName);
}
goto out;
}
if(CANNOT RemoveInterface(args.Interface,args.Force))
{
result = RETURN_ERROR;
if(NOT quiet)
{
LONG error,code;
/* Older bsdsocket.library versions do not support the RemoveInterface()
functionality, which is why we will substitute the error code. */
error = Errno();
if(error == OK)
error = EBUSY;
code = error;
if(Local_SocketBaseTags(cc,
SBTM_GETREF(SBTC_ERRNOSTRPTR),&code,
TAG_END) != 0)
{
code = (LONG)"";
}
Local_ErrorPrintf(cc,get_str(cc,MSG_REMOVENETINTERFACE_COULD_NOT_REMOVE_INTERFACE_TXT),
cc->cc_ProgramName,args.Interface,error,code);
}
goto out;
}
if(NOT quiet)
{
Local_Printf(cc,get_str(cc,MSG_REMOVENETINTERFACE_INTERFACE_REMOVED_TXT),
cc->cc_ProgramName,args.Interface);
}
result = RETURN_OK;
out:
if(quiet && result != RETURN_OK)
result = RETURN_WARN;
if(rda != NULL)
FreeArgs(rda);
return(result);
}
/****************************************************************************/
STATIC LONG VARARGS68K
Local_Printf(struct CommandContext * cc,STRPTR format,...)
{
DECLARE_DOSBASE(cc);
va_list args;
LONG result;
#if defined(__amigaos4__)
{
va_startlinear(args,format);
result = VPrintf(format,va_getlinearva(args,APTR));
va_end(args);
}
#else
{
va_start(args,format);
result = VPrintf(format,args);
va_end(args);
}
#endif /* __amigaos4__ */
return(result);
}
/****************************************************************************/
STATIC LONG VARARGS68K
Local_ErrorPrintf(struct CommandContext * cc,STRPTR format,...)
{
DECLARE_DOSBASE(cc);
DECLARE_SYSBASE(cc);
va_list args;
LONG result;
BPTR fh;
#if defined(__amigaos4__)
{
fh = ErrorOutput();
}
#else
{
struct Process * this_process = (struct Process *)FindTask(NULL);
fh = this_process->pr_CES;
}
#endif /* __amigaos4__ */
if(fh == ZERO)
fh = Output();
#if defined(__amigaos4__)
{
va_startlinear(args,format);
result = VFPrintf(fh,format,va_getlinearva(args,APTR));
va_end(args);
}
#else
{
va_start(args,format);
result = VFPrintf(fh,format,args);
va_end(args);
}
#endif /* __amigaos4__ */
return(result);
}
/****************************************************************************/
/* This looks up a locale string ID in the builtin database; adapted
from CygnusEd because I couldn't find my own implementation for this
application... */
STATIC STRPTR
get_builtin_str(LONG id)
{
LONG top,middle,bottom;
STRPTR builtin_string;
/* The search area is all those message between bottom and top, inclusive. */
bottom = 0;
top = NUM_ENTRIES(CatCompArray) - 1;
/* Binary search through the CatCompArray to find the requested string.
Note that this assumes that the strings are sorted. Catcomp defaults
to creating sorted arrays, but it does _not_ force it. If in the .cd
file you specify out of order string numbers this routine will fail.*/
while(bottom != top)
{
middle = (bottom + top) / 2;
if(CatCompArray[middle].cca_ID >= id)
top = middle;
else
bottom = middle + 1;
}
/* The only time this error message should occur is if you've passed
a garbage number OR if the CatCompArray is not sorted. */
if(CatCompArray[bottom].cca_ID == id)
builtin_string = (STRPTR)CatCompArray[bottom].cca_Str;
else
builtin_string = "";
return(builtin_string);
}
STATIC STRPTR
get_str(struct CommandContext * cc, LONG id)
{
STRPTR builtin_string;
STRPTR result;
builtin_string = get_builtin_str(id);
if(cc->cc_Catalog != NULL)
{
DECLARE_LOCALEBASE(cc);
result = (STRPTR)GetCatalogStr(cc->cc_Catalog,id,builtin_string);
}
else
{
result = builtin_string;
}
return(result);
}
/****************************************************************************/
STATIC LONG VARARGS68K
Local_SocketBaseTags(struct CommandContext * cc,...)
{
DECLARE_SOCKETBASE(cc);
va_list args;
LONG result;
#if defined(__amigaos4__)
{
va_startlinear(args,cc);
result = SocketBaseTagList(va_getlinearva(args,struct TagItem *));
va_end(args);
}
#else
{
va_start(args,cc);
result = SocketBaseTagList((struct TagItem *)args);
va_end(args);
}
#endif /* __amigaos4__ */
return(result);
}

View File

@ -1,6 +0,0 @@
#define VERSION 4
#define REVISION 3
#define DATE "11.3.2009"
#define VERS "RemoveNetInterface 4.3"
#define VSTRING "RemoveNetInterface 4.3 (11.3.2009)\r\n"
#define VERSTAG "\0$VER: RemoveNetInterface 4.3 (11.3.2009)"

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +0,0 @@
#define VERSION 4
#define REVISION 9
#define DATE "23.4.2017"
#define VERS "RoadshowControl 4.9"
#define VSTRING "RoadshowControl 4.9 (23.4.2017)\r\n"
#define VERSTAG "\0$VER: RoadshowControl 4.9 (23.4.2017)"

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +0,0 @@
#define VERSION 4
#define REVISION 5
#define DATE "10.11.2016"
#define VERS "SampleNetSpeed 4.5"
#define VSTRING "SampleNetSpeed 4.5 (10.11.2016)\r\n"
#define VERSTAG "\0$VER: SampleNetSpeed 4.5 (10.11.2016)"

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +0,0 @@
#define VERSION 4
#define REVISION 28
#define DATE "11.3.2009"
#define VERS "ShowNetStatus 4.28"
#define VSTRING "ShowNetStatus 4.28 (11.3.2009)\r\n"
#define VERSTAG "\0$VER: ShowNetStatus 4.28 (11.3.2009)"

View File

@ -1,392 +0,0 @@
/*
* $Id: assert.c,v 1.1 2004-03-26 21:08:47 obarthel Exp $
*
* :ts=8
*
* Copyright © 2001-2003 by Olaf Barthel. All Rights Reserved.
*/
/****************************************************************************/
#include <dos/dos.h>
#include <clib/exec_protos.h>
#include <clib/dos_protos.h>
#include <pragmas/exec_pragmas.h>
#include <pragmas/dos_pragmas.h>
#include <string.h>
extern struct Library * SysBase;
extern void kprintf(const char *,...);
extern void __stdargs kputc(char c);
/****************************************************************************/
#include <stdarg.h>
/****************************************************************************/
#define DEBUGLEVEL_OnlyAsserts 0
#define DEBUGLEVEL_Reports 1
#define DEBUGLEVEL_CallTracing 2
/****************************************************************************/
static int indent_level = 0;
static int debug_level = DEBUGLEVEL_CallTracing;
static char program_name[40];
static int program_name_len = 0;
/****************************************************************************/
void
_SETPROGRAMNAME(char *name)
{
if(name != NULL && name[0] != '\0')
{
program_name_len = strlen(name);
if(program_name_len >= sizeof(program_name))
program_name_len = sizeof(program_name)-1;
strncpy(program_name,name,program_name_len);
program_name[program_name_len] = '\0';
}
else
{
program_name_len = 0;
}
}
/****************************************************************************/
int
_SETDEBUGLEVEL(int level)
{
int old_level = debug_level;
debug_level = level;
return(old_level);
}
/****************************************************************************/
int
_GETDEBUGLEVEL(void)
{
return(debug_level);
}
/****************************************************************************/
static int previous_debug_level = -1;
void
_PUSHDEBUGLEVEL(int level)
{
previous_debug_level = _SETDEBUGLEVEL(level);
}
void
_POPDEBUGLEVEL(void)
{
if(previous_debug_level != -1)
{
_SETDEBUGLEVEL(previous_debug_level);
previous_debug_level = -1;
}
}
/****************************************************************************/
void
_INDENT(void)
{
if(program_name_len > 0)
kprintf("(%s) ",program_name);
if(debug_level >= DEBUGLEVEL_CallTracing)
{
int i;
for(i = 0 ; i < indent_level ; i++)
kprintf(" ");
}
}
/****************************************************************************/
void
_SHOWVALUE(
unsigned long value,
int size,
const char *name,
const char *file,
int line)
{
if(debug_level >= DEBUGLEVEL_Reports)
{
char *fmt;
switch(size)
{
case 1:
fmt = "%s:%ld:%s = %ld, 0x%02lx";
break;
case 2:
fmt = "%s:%ld:%s = %ld, 0x%04lx";
break;
default:
fmt = "%s:%ld:%s = %ld, 0x%08lx";
break;
}
_INDENT();
kprintf(fmt,file,line,name,value,value);
if(size == 1 && value < 256)
{
if(value < ' ' || (value >= 127 && value < 160))
kprintf(", '\\x%02lx'",value);
else
kprintf(", '%lc'",value);
}
kprintf("\n");
}
}
/****************************************************************************/
void
_SHOWPOINTER(
void *pointer,
const char *name,
const char *file,
int line)
{
if(debug_level >= DEBUGLEVEL_Reports)
{
char *fmt;
_INDENT();
if(pointer != NULL)
fmt = "%s:%ld:%s = 0x%08lx\n";
else
fmt = "%s:%ld:%s = NULL\n";
kprintf(fmt,file,line,name,pointer);
}
}
/****************************************************************************/
void
_SHOWSTRING(
const char *string,
const char *name,
const char *file,
int line)
{
if(debug_level >= DEBUGLEVEL_Reports)
{
_INDENT();
kprintf("%s:%ld:%s = 0x%08lx \"%s\"\n",file,line,name,string,string);
}
}
/****************************************************************************/
void
_SHOWMSG(
const char *string,
const char *file,
int line)
{
if(debug_level >= DEBUGLEVEL_Reports)
{
_INDENT();
kprintf("%s:%ld:%s\n",file,line,string);
}
}
/****************************************************************************/
void
_DPRINTF_HEADER(
const char *file,
int line)
{
if(debug_level >= DEBUGLEVEL_Reports)
{
_INDENT();
kprintf("%s:%ld:",file,line);
}
}
static void __asm
putch(register __d0 c)
{
if(c != '\0')
kputc(c);
}
void
_DPRINTF(const char *fmt,...)
{
if(debug_level >= DEBUGLEVEL_Reports)
{
va_list args;
va_start(args,fmt);
RawDoFmt((char *)fmt,args,(VOID (*)())putch,NULL);
va_end(args);
kprintf("\n");
}
}
void
_DLOG(const char *fmt,...)
{
if(debug_level >= DEBUGLEVEL_Reports)
{
va_list args;
va_start(args,fmt);
RawDoFmt((char *)fmt,args,(VOID (*)())putch,NULL);
va_end(args);
}
}
/****************************************************************************/
void
_ENTER(
const char *file,
int line,
const char *function)
{
if(debug_level >= DEBUGLEVEL_CallTracing)
{
_INDENT();
kprintf("%s:%ld:Entering %s\n",file,line,function);
}
indent_level++;
}
void
_LEAVE(
const char *file,
int line,
const char *function)
{
indent_level--;
if(debug_level >= DEBUGLEVEL_CallTracing)
{
_INDENT();
kprintf("%s:%ld: Leaving %s\n",file,line,function);
}
}
void
_RETURN(
const char *file,
int line,
const char *function,
unsigned long result)
{
indent_level--;
if(debug_level >= DEBUGLEVEL_CallTracing)
{
_INDENT();
kprintf("%s:%ld: Leaving %s (result 0x%08lx, %ld)\n",file,line,function,result,result);
}
}
/****************************************************************************/
void
_ASSERT(
int x,
const char *xs,
const char *file,
int line,
const char *function)
{
#ifdef CONFIRM
{
STATIC BOOL ScrollMode = FALSE;
STATIC BOOL BatchMode = FALSE;
if(BatchMode == FALSE)
{
if(x == 0)
{
kprintf("%s:%ld:Expression `%s' failed assertion in %s().\n",
file,
line,
xs,
function);
if(ScrollMode == FALSE)
{
ULONG Signals;
SetSignal(0,SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_D | SIGBREAKF_CTRL_E);
kprintf(" ^C to continue, ^D to enter scroll mode, ^E to enter batch mode\r");
Signals = Wait(SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_D | SIGBREAKF_CTRL_E);
if(Signals & SIGBREAKF_CTRL_D)
{
ScrollMode = TRUE;
kprintf("Ok, entering scroll mode\033[K\n");
}
else if (Signals & SIGBREAKF_CTRL_E)
{
BatchMode = TRUE;
kprintf("Ok, entering batch mode\033[K\n");
}
else
{
/* Continue */
kprintf("\033[K\r");
}
}
}
}
}
#else
{
if(x == 0)
{
_INDENT();
kprintf("%s:%ld:Expression `%s' failed assertion in %s().\n",
file,
line,
xs,
function);
}
}
#endif /* CONFIRM */
}

View File

@ -1,95 +0,0 @@
/*
* $Id: assert.h,v 1.1 2004-03-26 21:08:47 obarthel Exp $
*
* :ts=8
*
* Copyright © 2001 by Olaf Barthel. All Rights Reserved.
*/
/****************************************************************************/
/* IMPORTANT: If DEBUG is redefined, it must happen only here. This
* will cause all modules to depend upon it to be rebuilt
* by the smakefile (that is, provided the smakefile has
* all the necessary dependency lines in place).
*/
/*#define DEBUG*/
/****************************************************************************/
#ifdef ASSERT
#undef ASSERT
#endif /* ASSERT */
#define PUSH_ASSERTS() PUSHDEBUGLEVEL(0)
#define PUSH_REPORTS() PUSHDEBUGLEVEL(1)
#define PUSH_CALLS() PUSHDEBUGLEVEL(2)
#define PUSH_ALL() PUSHDEBUGLEVEL(2)
#define POP() POPDEBUGLEVEL()
#if defined(DEBUG) && defined(__SASC)
void _ASSERT(int x,const char *xs,const char *file,int line,const char *function);
void _SHOWVALUE(unsigned long value,int size,const char *name,const char *file,int line);
void _SHOWPOINTER(void *p,const char *name,const char *file,int line);
void _SHOWSTRING(const char *string,const char *name,const char *file,int line);
void _SHOWMSG(const char *msg,const char *file,int line);
void _ENTER(const char *file,int line,const char *function);
void _LEAVE(const char *file,int line,const char *function);
void _RETURN(const char *file,int line,const char *function,unsigned long result);
void _DPRINTF_HEADER(const char *file,int line);
void _DPRINTF(const char *format,...);
void _DLOG(const char *format,...);
int _SETDEBUGLEVEL(int level);
void _PUSHDEBUGLEVEL(int level);
void _POPDEBUGLEVEL(void);
int _GETDEBUGLEVEL(void);
void _SETPROGRAMNAME(char *name);
#define ASSERT(x) _ASSERT((int)(x),#x,__FILE__,__LINE__,__FUNC__)
#define ENTER() _ENTER(__FILE__,__LINE__,__FUNC__)
#define LEAVE() _LEAVE(__FILE__,__LINE__,__FUNC__)
#define RETURN(r) _RETURN(__FILE__,__LINE__,__FUNC__,(unsigned long)r)
#define SHOWVALUE(v) _SHOWVALUE(v,sizeof(v),#v,__FILE__,__LINE__)
#define SHOWPOINTER(p) _SHOWPOINTER(p,#p,__FILE__,__LINE__)
#define SHOWSTRING(s) _SHOWSTRING(s,#s,__FILE__,__LINE__)
#define SHOWMSG(s) _SHOWMSG(s,__FILE__,__LINE__)
#define D(s) do { _DPRINTF_HEADER(__FILE__,__LINE__); _DPRINTF s; } while(0)
#define PRINTHEADER() _DPRINTF_HEADER(__FILE__,__LINE__)
#define PRINTF(s) _DLOG s
#define LOG(s) do { _DPRINTF_HEADER(__FILE__,__LINE__); _DLOG("<%s()>:",__FUNC__); _DLOG s; } while(0)
#define SETDEBUGLEVEL(l) _SETDEBUGLEVEL(l)
#define PUSHDEBUGLEVEL(l) _PUSHDEBUGLEVEL(l)
#define POPDEBUGLEVEL() _POPDEBUGLEVEL()
#define SETPROGRAMNAME(n) _SETPROGRAMNAME(n)
#define GETDEBUGLEVEL() _GETDEBUGLEVEL()
#undef DEBUG
#define DEBUG 1
#else
#define ASSERT(x) ((void)0)
#define ENTER() ((void)0)
#define LEAVE() ((void)0)
#define RETURN(r) ((void)0)
#define SHOWVALUE(v) ((void)0)
#define SHOWPOINTER(p) ((void)0)
#define SHOWSTRING(s) ((void)0)
#define SHOWMSG(s) ((void)0)
#define D(s) ((void)0)
#define PRINTHEADER() ((void)0)
#define PRINTF(s) ((void)0)
#define LOG(s) ((void)0)
#define SETDEBUGLEVEL(l) ((void)0)
#define PUSHDEBUGLEVEL(l) ((void)0)
#define POPDEBUGLEVEL() ((void)0)
#define SETPROGRAMNAME(n) ((void)0)
#define GETDEBUGLEVEL() (0)
#ifdef DEBUG
#undef DEBUG
#endif /* DEBUG */
#define DEBUG 0
#endif /* DEBUG */
/****************************************************************************/

View File

@ -1,56 +0,0 @@
/*
* $Id: compiler.h,v 1.3 2007-08-26 12:30:26 obarthel Exp $
*
* :ts=4
*
* Copyright © 2001-2007 by Olaf Barthel. All Rights Reserved.
*/
#ifndef _COMPILER_H
#define _COMPILER_H
/****************************************************************************/
#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif /* EXEC_TYPES_H */
/****************************************************************************/
/* The following definitions are redundant in the V50 AmigaOS header files. */
#ifndef AMIGA_COMPILER_H
/****************************************************************************/
#if defined(__SASC)
#define ASM __asm
#define REG(r,p) register __##r p
#define INLINE __inline
#define INTERRUPT __interrupt
#define FAR __far
#define STDARGS __stdargs
#elif defined(__GNUC__)
#define ASM
#define REG(r,p) p __asm(#r)
#define INLINE __inline__
#define INTERRUPT __attribute__((__interrupt__))
#define FAR
#define STDARGS __attribute__((__stkparm__))
#else
#define ASM
#define REG(x)
#define INLINE
#define INTERRUPT
#define FAR
#define STDARGS
#endif /* __SASC */
#define VARARGS68K
/****************************************************************************/
#endif /* AMIGA_COMPILER_H */
/****************************************************************************/
#endif /* _COMPILER_H */

View File

@ -1,61 +0,0 @@
/*
* $Id: macros.h,v 1.6 2007-08-26 12:30:26 obarthel Exp $
*
* :ts=4
*
* Copyright © 2001-2007 by Olaf Barthel. All Rights Reserved.
*/
#ifndef _MACROS_H
#define _MACROS_H
/****************************************************************************/
#define OK (0)
#define SAME (0)
#define BUSY ((struct IORequest *)NULL)
#define CANNOT !
#define NOT !
#define NO !
/****************************************************************************/
#ifdef NULL
#undef NULL
#define NULL ((VOID *)0UL)
#endif /* NULL */
/****************************************************************************/
#ifndef ZERO
#define ZERO ((BPTR)NULL)
#endif /* ZERO */
/****************************************************************************/
#define UNIX_TIME_OFFSET 252460800UL
/****************************************************************************/
#if !defined(_COMPILER_H) && !defined(AMIGA_COMPILER_H)
#include "compiler.h"
#endif /* !_COMPILER_H && !AMIGA_COMPILER_H */
/****************************************************************************/
#define FLAG_IS_SET(v,f) (((v) & (f)) == (f))
#define FLAG_IS_CLEAR(v,f) (((v) & (f)) == 0 )
#define SET_FLAG(v,f) ((VOID)((v) |= (f)))
#define CLEAR_FLAG(v,f) ((VOID)((v) &= ~((ULONG)(f))))
/****************************************************************************/
#define NUM_ENTRIES(t) (sizeof(t) / sizeof(t[0]))
/****************************************************************************/
#define MILLION 1000000
/****************************************************************************/
#endif /* _MACROS_H */

File diff suppressed because it is too large Load Diff