home *** CD-ROM | disk | FTP | other *** search
- head 1.9;
- access;
- symbols
- sercli_v1_10:1.9
- sercli_v1_9:1.6
- sercli_v1_8:1.4
- sercli_v1_7:1.3
- sercli_v1_6:1.2
- sercli_v1_5:1.1;
- locks
- rkr:1.9;
- comment @** @;
-
-
- 1.9
- date 93.06.16.23.29.30; author rkr; state Exp;
- branches;
- next 1.8;
-
- 1.8
- date 93.06.11.10.24.44; author rkr; state Exp;
- branches;
- next 1.7;
-
- 1.7
- date 93.06.10.16.43.21; author rkr; state Exp;
- branches;
- next 1.6;
-
- 1.6
- date 93.06.06.10.34.37; author rkr; state Exp;
- branches;
- next 1.5;
-
- 1.5
- date 93.06.06.10.26.32; author rkr; state Exp;
- branches;
- next 1.4;
-
- 1.4
- date 91.12.20.09.43.45; author rkr; state Exp;
- branches;
- next 1.3;
-
- 1.3
- date 91.12.10.02.48.11; author rkr; state Exp;
- branches;
- next 1.2;
-
- 1.2
- date 91.12.02.10.51.29; author rkr; state Exp;
- branches;
- next 1.1;
-
- 1.1
- date 91.11.28.08.25.17; author rkr; state Exp;
- branches;
- next ;
-
-
- desc
- @sercli is a program to permit shell-like interface to the serial port,
- while also permitting easy config- and run-time-control over the way the
- serial port (or even _which_ serial port) is used.
-
- @
-
-
- 1.9
- log
- @Added per-file copyright notice, as suggested by GPL.
-
- Also will now only create the ARexx port if RexxSysBase was opened;
- this should make it able to run correctly on ARexxless systems.
- @
- text
- @/*
- ** $Source: WB_2.1:homes/rkr/prog/sercli/src/RCS/rexx.c,v $
- ** $Author: rkr $
- ** $Revision: 1.8 $
- ** $Locker: rkr $
- ** $State: Exp $
- ** $Date: 1993/06/11 10:24:44 $
- **
- ** sercli (an Amiga .device <-> FIFO interface tool)
- ** Copyright (C) 1993 Richard Rauch
- **
- ** See /doc/sercli.doc and /COPYING for use and distribution license.
- **
- */
-
- #include <rexx/errors.h>
-
- #include <clib/alib_protos.h>
- #include <clib/exec_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/rexxsyslib_protos.h>
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #include "config.h"
- #include "defs.h"
- #include "rexx.h"
- #include "keywords.h"
- #include "sercli-config.h"
- #include "ser_supp.h"
-
- void *RexxSysBase; /*** screwey `struct RxsLib' name, if you care ***/
-
- MsgPort *rexx_port;
-
- ULONG rexx_mask;
-
- static RexxMsg *rm;
-
- /*
- ** Reply to an ARexx message.
- **
- ** Args:
- ** {rm} - The ARexx msg to reply to
- ** {rc} - Result1 to send back
- ** {res} - Result2 to send back
- **
- ** NOTE that according to ARexx documentation, you should only set {res}
- ** when {rc} is 0. rexx_reply() makes NO such checks!
- **
- ** {rm} isn't really needed in this context, since we only have the global
- ** {rm}, but it's a bit more flexible this way (should probably stick
- ** {rm}s in more of the function parameter lists...).
- **
- */
- void rexx_reply (RexxMsg *rm, LONG rc, char *res)
- {
- rm->rm_Result1 = rc;
- if ( (rm->rm_Action & RXFF_RESULT) && (res) )
- rm->rm_Result2 = CreateArgstring (res, strlen (res) );
- ReplyMsg ( (Message *)rm);
- }
-
-
- /*
- ** Creates an ARexx port.
- **
- ** Does NOT open the arexx libraries; that will be handled by autoinit
- ** code (if Dillon hasn't yet put auto support for ARexx in, I'll add
- ** that...
- **
- ** Basically, creates a port with {prog_id} (a global; that global
- ** defaults to "sercli" but can be set before this function is called...
- ** In the current context (i.e., the sercli program) it may be set by
- ** read_sercli_config() when reading in a config file with an appropriate
- ** config line...).
- **
- */
- void open_rexx (void)
- {
- if (RexxSysBase)
- {
- Forbid ();
- {
- if (FindPort (prog_id) )
- exit (10);
- rexx_port = CreatePort (prog_id, 1);
- }
- Permit ();
- rexx_mask = 1 << (rexx_port->mp_SigBit);
- }
- }
-
-
- /*
- ** Closes down the ARexx port.
- **
- ** Like open_rexx(), close_rexx() does not deal with the libraries (and
- ** for analogous reasons).
- **
- */
- void close_rexx (void)
- {
- if (rexx_port)
- {
- RemPort (rexx_port);
-
- while (rm = (RexxMsg *) GetMsg (rexx_port) )
- rexx_reply (rm, RC_ERROR, NULL);
-
- DeletePort (rexx_port);
- rexx_port = NULL;
- rexx_mask = 0;
- }
- }
-
-
- /*
- ** Handles all ARexx messages that accumulate at {rexx_port}.
- **
- ** The {rexx_port} is a global, as is {rm} (the {RexxMsg *}).
- **
- */
- void handle_rexx (void)
- {
- int ser_soft_param = 0;
- int ser_hard_param = 0;
-
- while (rm = (RexxMsg *)GetMsg (rexx_port) )
- {
- char *line;
- char *result = 0;
- char *tmp;
- LONG rc = RC_OK;
-
- line = tmp = rm->rm_Args [0];
- while ( (*tmp) && (*tmp++ != ':') )
- ;
-
- while ( (*tmp) && (*tmp == ' ') )
- ++tmp;
-
- switch (match (line, keywords) )
- {
- case OPTION_NOT_FOUND:
- rc = RC_ERROR;
- break;
-
-
- case OPTION_COMMENT:
- break;
-
- /*
- ** General:
- ** Add support to return the "old" values for these serial
- ** param controls?
- **
- ** Or else call ser_soft_set() from each & return the result
- ** of that?
- **
- */
- case SER_BPS:
- if (*tmp)
- {
- ser_bps = strtol (tmp, NULL, 0);
- ser_soft_param = 1;
- }
- else if (alert_loc)
- printf ("Invalid {bps} in rexx msg: {%s}\n", line);
- break;
-
-
- case SER_BITS:
- if (*tmp)
- {
- ser_read_bits = ser_write_bits = strtol (tmp, NULL, 0);
- ser_soft_param = 1;
- }
- else if (alert_loc)
- printf ("Invalid {bits} in rexx msg {%s}.\n", line);
- break;
-
-
- case SER_STOP_BITS:
- if (*tmp)
- {
- ser_stop_bits = strtol (tmp, NULL, 0);
- ser_soft_param = 1;
- }
- else if (alert_loc)
- printf ("Invalid {stop bits} in rexx msg {%s}.\n", line);
- break;
-
-
- case SER_7WIRE:
- ser_7wire = 1;
- ser_hard_param = 1;
- break;
-
-
- case SER_3WIRE:
- ser_7wire = 0;
- ser_hard_param = 1;
- break;
-
-
- case SER_XON_XOFF:
- ser_xon_xoff = 1;
- ser_soft_param = 1; /*** hard?? ***/
- break;
-
-
- case SER_NO_XON_XOFF:
- ser_xon_xoff = 0;
- ser_soft_param = 1; /*** hard?? ***/
- break;
-
-
- case SER_SHARED:
- ser_exclusive = 0;
- ser_hard_param = 1;
- break;
-
-
- case SER_EXCLUSIVE:
- ser_exclusive = 1;
- ser_hard_param = 1;
- break;
-
-
- case SER_NO_RAD_BOOGIE:
- ser_rad_boogie = 0;
- ser_hard_param = 1;
- break;
-
-
- case SER_RAD_BOOGIE:
- ser_rad_boogie = 1;
- ser_hard_param = 1;
- break;
-
-
- case SER_NO_PARITY:
- ser_parity = 0;
- ser_soft_param = 1;
- break;
-
-
- case SER_ODD_PARITY:
- ser_parity = 1;
- ser_soft_param = 1;
- break;
-
-
- case SER_EVEN_PARITY:
- ser_parity = 2;
- ser_soft_param = 1;
- break;
-
-
- case SET_WINDOW_TITLE:
- {
- char buf [256];
-
- int len;
-
- if (nether_name)
- free (nether_name);
-
- /*
- ** return old title; gets freed on way out...
- **
- */
- result = window_title; /*** Just use nw.Title??? ***/
- nether_name = strdup (tmp);
- len = sprintf
- (
- buf,
- "sercli: with {%s} id {%s}",
- nether_name,
- prog_id
- );
- window_title = strdup (buf); /*** Just use nw.Title??? ***/
- SetWindowTitles (win, window_title, (UBYTE *)~0);
-
- rc = RC_OK;
- break;
- }
-
-
- case SET_WINDOW_SIZE:
- {
- int new_width;
- int new_height;
-
- rc = RC_ERROR;
-
- sscanf (tmp, "%d %d", &new_width, &new_height);
- if ( (new_width > 0) && (new_height > 0) )
- {
- char buf [256];
-
- SizeWindow (win, new_width - win_width, new_height - win_height);
-
- sprintf (buf, "%d %d", win_width, win_height);
- result = strdup (buf);
-
- win_width = new_width;
- win_height = new_height;
-
- rc = RC_OK;
- }
- break;
- }
-
-
- case ALERT_LOC:
- alert_loc = 1;
- break;
-
-
- case ALERT_SER:
- alert_ser = 1;
- break;
-
-
- case NO_ALERT_LOC:
- alert_loc = 0;
- break;
-
-
- case NO_ALERT_SER:
- alert_ser = 0;
- break;
-
-
- case SER_QUERY:
- /*
- ** Not really and "error," but this'll do the job for now.
- **
- */
- handle_error (error_type_serial, query_ser () );
- break;
-
-
- default:
- if (alert_loc)
- printf ("rexx command {%s} not implemented.\n", line);
- rc = RC_ERROR;
- break;
- }
-
- rexx_reply (rm, rc, result);
- if (result)
- free (result);
- }
-
- if (ser_hard_param)
- {
- close_ser ();
- open_ser ();
- }
- else if (ser_soft_param)
- set_ser_soft ();
- }
-
- @
-
-
- 1.8
- log
- @Oops; forgot about rexx_mask -- shouldn't matter, but just to be safe,
- it's cleared now during rexx_close().
- @
- text
- @d4 1
- a4 1
- ** $Revision: 1.7 $
- d7 1
- a7 1
- ** $Date: 1993/06/10 16:43:21 $
- d9 5
- d34 1
- a62 1
-
- d83 1
- a83 1
- Forbid ();
- d85 8
- a92 4
- if (FindPort (prog_id) )
- exit (10);
-
- rexx_port = CreatePort (prog_id, 1);
- a93 2
- Permit ();
- rexx_mask = 1 << (rexx_port->mp_SigBit);
- a265 1
- // char *cptr; /*** UNUSED VAR ***/
- @
-
-
- 1.7
- log
- @In close_rexx(), clear global info so that multiple opens/closes can
- be handled correctly & safely.
- @
- text
- @d4 2
- a5 2
- ** $Revision: 1.6 $
- ** $Locker: $
- d7 1
- a7 1
- ** $Date: 1993/06/06 10:34:37 $
- d108 1
- @
-
-
- 1.6
- log
- @Converted {rexx_name} to {prog_id}. In many spots, then, deleted
- redundant {prog_id}. (Well, in _some_ spots...)
- @
- text
- @d2 1
- a2 1
- ** $Source: WB_2.1:ho/RCS/rexx.c,v $
- d4 2
- a5 2
- ** $Revision: 1.5 $
- ** $Locker: rkr $
- d7 1
- a7 1
- ** $Date: 1993/06/06 10:26:32 $
- d107 1
- d258 1
- a258 1
- char *cptr;
- @
-
-
- 1.5
- log
- @Made {FidoName} refs to {prog_id}
- @
- text
- @d2 1
- a2 1
- ** $Source: WB_2.1:ho/rcs/rexx.c,v $
- d4 2
- a5 2
- ** $Revision: 1.4 $
- ** $Locker: $
- d7 1
- a7 1
- ** $Date: 1991/12/20 09:43:45 $
- a33 2
- char *rexx_name = "sercli";
-
- d69 1
- a69 1
- ** Basically, creates a port with {rexx_name} (a global; that global
- d80 1
- a80 1
- if (FindPort (rexx_name) )
- d83 1
- a83 1
- rexx_port = CreatePort (rexx_name, 1);
- d273 1
- a273 1
- "sercli: with {%s} fifo {%s}, rx {%s}",
- d275 1
- a275 2
- prog_id,
- rexx_name
- @
-
-
- 1.4
- log
- @*** empty log message ***
- @
- text
- @d2 1
- a2 1
- ** $Source: Workbench:personal/rkr/prog/sercli/src/rcs/rexx.c,v $
- d4 2
- a5 2
- ** $Revision: 1.3 $
- ** $Locker: rkr $
- d7 1
- a7 1
- ** $Date: 91/12/10 02:48:11 $
- d277 1
- a277 1
- FifoName,
- @
-
-
- 1.3
- log
- @** set {ser_hard_param = 1} for changes of rad boogie (_not_ a soft
- param!)
-
-
- ** Added "ser query" ARexx command.
-
-
- @
- text
- @d4 1
- a4 1
- ** $Revision: 1.2 $
- d7 1
- a7 1
- ** $Date: 91/12/02 10:51:29 $
- @
-
-
- 1.2
- log
- @*** empty log message ***
- @
- text
- @d7 1
- a7 1
- ** $Date: 91/12/02 10:42:06 $
- d228 1
- a228 1
- ser_soft_param = 1;
- d234 1
- a234 1
- ser_soft_param = 1;
- d331 9
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d2 6
- a7 6
- ** $Source$
- ** $Author$
- ** $Revision$
- ** $Locker$
- ** $State$
- ** $Date$
- d352 1
- a352 1
- ser_soft_set ();
- @
-