[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::amiga_v1

Title:AMIGA NOTES
Notice:Join us in the *NEW* conference - HYDRA::AMIGA_V2
Moderator:HYDRA::MOORE
Created:Sat Apr 26 1986
Last Modified:Wed Feb 05 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:5378
Total number of notes:38326

2361.0. "code to access multi-serial cards" by DECWET::TBAKER (Tom Baker - DECwest CSSE) Mon Mar 13 1989 20:50

    I picked this off usenet - thought some people might be interested.
    
    tom
    ====================================================================
    
From: papa@pollux.usc.edu (Marco Papa)
Newsgroups: comp.sys.amiga.tech
Subject: "Freely-redistributable" code to access MULTI-SERIAL cards
Date: 8 Mar 89 05:57:49 GMT
Organization: Felsina Software, Los Angeles, CA

In the interest of "standardization", I am posting the A-Talk III code that
permits access to multi-serial cards from TOOL and PROJECT icons, as well
as from the CLI.  This code is copyrighted, but freely redistributable.
It can be included in any commercial product, shareware or public domain
program, as long as the copyright and warranty sections are retained intact.
Thank you for complying with these clauses.

Enjoy.

/*
 *
 * Copyright 1988, 1989 by Felsina Software, Los Angeles, Ca.
 *
 * Copyright 1989 by Marco Papa
 *
 *
 *                         All Rights Reserved
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and that
 * both that copyright notice and this permission notice appear in
 * supporting documentation, and that the name of Felsina Software
 * or Marco Papa not be used in advertising or publicity pertaining to 
 * distribution of the software without specific, written prior permission.
 *
 * FELSINA SOFTWARE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 
 * EVENT SHALL FELSINA SOFTWARE BE LIABLE FOR ANY SPECIAL, INDIRECT OR 
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 
 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 
 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 
 * PERFORMANCE OF THIS SOFTWARE.
 *
 */


/*
 * MODIFICATION HISTORY
 *
 * 1.0 -- M. Papa, Felsina Software, January 1, 1989
 *        Inspired by MANX's _wbparse.c and C. Scheppner's Display.c
 * 1.1 -- January 15, 1989
 *        Added DEVICE keyword, suggested by Peter Da Silva
 * 1.2 -- February 5, 1989
 *        Added menubar update, suggested by Dave Haynie. Makes life
 *	  easier when running 20 concurrent copies of A-Talk III :-)
 */

#ifndef lint
static char *sccsid = "@(#)GetIconArgs.c	1.2	2/5/89";
#endif
/*
 *	GetIconArgs - This subroutine is called from the main() routine and 
 *		is used to select the options to be used. Version 1.2 allows 
 *		setting of the device, unit and script file. The options are 
 *		defined by setting the ToolType when using WorkBench, and
 *		on the command line when invoking the main program from
 *		the CLI. For example, to define the serial device to be used,
 *		the keyword DEVICE is set to the desired specification.  The 
 *		default DEVICE is "serial.device".
 *
 *	File:		GetIconArgs.c
 *
 *	Workbench Example:
 *			DEVICE=siosbx.device
 *			UNIT=2
 *			FROM=myscript
 *
 *	CLI Syntax:	ATalk3 [FROM <name>] [DEVICE <name>] [UNIT <nn>]
 *
 *	CLI Example: 	ATalk3 FROM myscript DEVICE siosbx.device UNIT 2
 *			
 */

#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <workbench/workbench.h>
#include <workbench/startup.h>
#include <workbench/icon.h>
#include <ctype.h>

static char *option[3] = {
	"FROM",		/* <name> */
	"DEVICE", 	/* <name> */
	"UNIT",		/* <nn>   */
};

void *IconBase;
long serunit  = 0;			/* default UNIT */
char serdevice[21] = "serial.device";	/* default DEVICE */
char scriptptr[21] = "";		/* default is no script file */

char banner[52] = "A-Talk III \251 1986, 1988 Felsina Software ";

/* For WorkBench startup */    
extern struct WBStartup *WBenchMsg;

GetIconArgs(argc, argv)
int argc;
char **argv;
   {
   register char *cp;
   register struct DiskObject *dop;
   struct WBArg *arg;
   void *_OpenLibrary();
   char *toolname;
   char *keyword;
   struct FileLock *startLock;
   char pgmname[11];

	if (argc==0) {	/* Workbench */
		arg = WBenchMsg->sm_ArgList;
		if (WBenchMsg->sm_NumArgs > 1) arg++; /* skip Default Tool */
		toolname = (char *) arg->wa_Name;

		if ((IconBase = _OpenLibrary("icon.library", 0L)) == 0)
			return;

		startLock  = (struct FileLock *) CurrentDir(arg->wa_Lock);

		if ((dop =  GetDiskObject(toolname)) == 0)
			goto closeit;

		if (cp = FindToolType(dop->do_ToolTypes, option[0])) {
			strncpy(scriptptr,cp,20);
		}
		if (cp = FindToolType(dop->do_ToolTypes, option[1])) {
			strncpy(serdevice,cp,20);
		}
		if (cp = FindToolType(dop->do_ToolTypes, option[2])) {
			if (isdigit(*cp))
				serunit = atoi(cp);
		}

		FreeDiskObject(dop);
closeit:
		CurrentDir(startLock);

		CloseLibrary(IconBase);
		IconBase = 0;

		/* add program name to menu bar */
		sprintf(pgmname,"[%.8s]", toolname);
		strcat(banner,pgmname);

	} else { /* CLI */

		/* add program name to menu bar */
		/* maybe strip disk/dir name */
		sprintf(pgmname,"[%.8s]", argv[0]);
		strcat(banner,pgmname);

		if (argc > 1) {	/* at least one parameter */
			if (*argv[1]=='?')
				Usage(), exit(RETURN_OK);
			while (--argc > 1) {
				keyword = *++argv;
				if (!strcmp(keyword,option[0])) /* FROM */
					strncpy(scriptptr, *++argv, 20);
				else if (!strcmp(keyword,option[1]))
					strncpy(serdevice, *++argv, 20);
				else if (!strcmp(keyword,option[2])) {
					if (isdigit((*++argv)[0]))
						serunit = atoi(*argv);
				} else {
					Usage(); puts("Bad args"); exit(RETURN_ERROR);
				}
				--argc;	/* skip over parameter */
			}
		}
	}
}

static Usage()
{
	puts("ATalk3 [FROM <name>] [DEVICE <name>] [UNIT <nn>]");
}

---

-- Marco Papa 'Doc'
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
uucp:...!pollux!papa       BIX:papa       ARPAnet:pollux!papa@oberon.usc.edu
 "There's Alpha, Beta, Gamma and Diga!" -- Leo Schwab [quoting Rick Unland]
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


T.RTitleUserPersonal
Name
DateLines