[comp.os.vms] Info-Vax Digest V0 #7

Info-Vax-REQUEST@KL.SRI.COM (Ramon Curiel) (05/04/87)

Info-Vax Digest           Sunday, 3 May 1987        Volume 0 : Issue 7

Today's Topics:
  Mail/DECNET interface
  Re: redirection of stdio, et al.
  Re: cbreak
  Submission for mod-computers-vax
  Re: How do you ring bell in DCL file?
  Re: Accessing global variable from FORTRAN
  Re: How do you NOT write a <RETURN>? (was:ring bell in DCL file)?
  RE: vi written in TPU
  Terminal capture program wanted
  VMS pseudo terminal set up
----------------------------------------------------------------------

Date: Fri, 1 May 87 10:50 CST
From: <SLOANE%UKANVAX.BITNET@wiscvm.wisc.edu> (BOB)
Subject: Mail/DECNET interface

In reply to Dave Stevens' question about the mail/decnet interface,
there was an article about that very topic in VAX Professional in the
August 1986 issue.  It includes a BASIC program to send mail messages
through DECNET.  Following is a translation of that program to C. Sorry
there are no comments, but the program was written just to play with the
interface, and was never intended to see the light of day.  The program
in the article is well documented.  Hope this helps.

                   Bob Sloane
                   University of Kansas
                   Computing Services
                   (913) 864-4291
                   SLOANE@UKANVAX on BITNET
==============================================================================
#include <ssdef.h>
#include <stdio.h>

main()
{
        char    *to_list[10];
        char    *text[100];
        int     status;

        to_list[0] = "SLOANE";
        to_list[1] = NULL;

        text[0] = "This is a mail message.";
        text[1] = "It contains several lines.";
        text[2] = "This is the last line";
        text[3] = NULL;

        status = decmail( "KUHUB", "One Who Knows", to_list, "One Who Asked",
                                "Why would I want to do this?", text );

        exit( status );
}       /*  main  */

#include <descrip.h>
#include <iodef.h>
#include <ssdef.h>
#include <stdio.h>
#include <stsdef.h>

#define EXIT_IF( cond, sts )    if( cond ) { \
                                        sys$dassgn( mail_chan ); \
                                        return( sts ); \
                                }

struct iosb_s {
        short   io_sts;
        short   io_count;
        long    io_devinfo;
};

int     mail_chan;
int     link_err;
int     errsts;
int     receivers;

decmail( node, from_name, to_list, to_show, subject, text )
        char    *node;
        char    *from_name;
        char    **to_list;
        char    *to_show;
        char    *subject;
        char    **text;
{
        char    node_name[64], object_name[64], *p;
        int     status, i, to_count, save_count;

        strcpy( node_name, node );
        if( (p = strchr( node_name, ':' )) != NULL )
                *p = '\0';

        sprintf( object_name, "%s::\"27=\"", node_name );
        status = sys$assign( ldescrip(object_name), &mail_chan, 0, 0 );
        if( (status & 1) == 0 )
                return( status );

        status = put_msg( from_name );
        EXIT_IF( (status & 1) == 0, status );

        for( i = 0; to_list[i] != NULL; ++i ) {
                status = put_msg( to_list[i] );
                EXIT_IF( (status & 1) == 0, status );
                errchk();
                EXIT_IF( (link_err & 1) == 0, link_err );
                EXIT_IF( (errsts & 1) == 0, errsts );
        }
        to_count = i;

        status = put_msg( NULL );
        EXIT_IF( (status & 1) == 0, status );

        if( receivers == 0 ) {
                printf( "No messages sent.\n" );
                sys$dassgn( mail_chan );
                return( SS$_NORMAL );
        }

        status = put_msg( to_show );
        EXIT_IF( (status & 1) == 0, status );

        status = put_msg( subject );
        EXIT_IF( (status & 1) == 0, status );

        for( i = 0; text[i] != NULL; ++i ) {
                status = put_msg( text[i] );
                EXIT_IF( (status & 1) == 0, status );
        }

        status = put_msg( NULL );
        EXIT_IF( (status & 1) == 0, status );

        save_count = receivers;

        for( i = 0; i < save_count; ++i ) {
                errchk();
                EXIT_IF( (link_err & 1) == 0, link_err );
        }

        printf( "%d messages sent.\n", save_count );

        sys$dassgn( mail_chan );

        return( SS$_NORMAL );
}       /*  decmail  */









errchk()
{
        char    msg[256];
        int     mail_sts;

        get_msg( msg, sizeof msg );
        mail_sts = msg[0];
        if( (link_err & 1) == 0 ) {
                errsts = link_err;
                return;
        }
        if( (mail_sts & 1) == 1 ) {
                ++receivers;
                errsts = mail_sts;
                return;
        }

        for(;;) {
                get_msg( msg, sizeof msg );
                if( (link_err & 1) == 0 ) {
                        errsts = link_err;
                        return;
                }
                if( strlen(msg) != 1 ) {
                        printf( "%s\n", msg );
                        continue;
                }
                if( msg[0] == 0 )
                        return;
        }

}       /*  errchk  */









int
put_msg( msg )
        char    *msg;
{
        static char     zero = '\0';
        struct iosb_s   iosb;
        int     status;

        if( msg == NULL )
                status = sys$qiow( 0, mail_chan, IO$_WRITEVBLK, &iosb, 0, 0,
                                        &zero, 1, 0, 0, 0, 0 );
        else
                status = sys$qiow( 0, mail_chan, IO$_WRITEVBLK, &iosb, 0, 0,
                                        msg, strlen(msg), 0, 0, 0, 0 );

        if( status != SS$_NORMAL )
                return( status );

        return( iosb.io_sts );
}       /*  put_msg  */









get_msg( msg, msg_siz )
        char    *msg;
        int     msg_siz;
{
        struct iosb_s   iosb;
        int     status;

        status = sys$qiow( 0, mail_chan, IO$_READVBLK, &iosb, 0, 0,
                                msg, msg_siz, 0, 0, 0, 0 );

        if( status != SS$_NORMAL ) {
                link_err = status;
                return;
        }
        if( iosb.io_sts != SS$_NORMAL ) {
                link_err = iosb.io_sts;
                return;
        }

        msg[iosb.io_count] = '\0';
        link_err = SS$_NORMAL;

}       /*  get_msg  */

------------------------------

Date: 30 Apr 87 17:17:35 GMT
From: mcvax!ukc!dcl-cs!sslvax!gdw@seismo.css.gov  (Grenville Whelan)
Subject: Re: redirection of stdio, et al.

In article <224@unc.cs.unc.edu> mcguffey@unc.cs.unc.edu (Michael McGuffey) writes:
>
>Does anyone know of any tools that allow command line redirection of
>stdio under VMS. Something similar to the way unix and msdos does it is
>preferable to some of the methods that have previously been proposed.
>
>-mike mcguffey


Simply redirect the logical SYS$OUTPUT to a file rather than the terminal,
ie.
     $ ASSIGN <FILE> SYS$OUTPUT
     $ <commands>
     $ DEASSIGN SYS$OUTPUT
--
# Grenville Whelan  -  Software Sciences Ltd, Park Street, Macclesfield, UK  #
# (EMAIL gdw@uk.co.ssl-macc) (UUCP !mcvax!ukc!mcvax!gdw) (TEL +44 625 29241) #

      "Are you the Police?"  "No ma'am, we're musicians!" -- Elwood.

------------------------------

Date: 30 Apr 87 13:19:36 GMT
From: eagle!icdoc!iwm@ucbvax.Berkeley.EDU  (Ian W Moor)
Subject: Re: cbreak

In article <8704260033.AA24777@ucbvax.Berkeley.EDU> "*Hobbit*" <hobbit@aim.rutgers.edu> writes:
>I want to do single-character getchar()'s in C, but getchar()
>doesn't do genuine 1-char QIOs.  It seems to want char + <ret>.  Can cbreak
>mode easily be simulated without replacing the getchar() call with a qio?

Something that I have used is the Screen manager routines, they are rather
higher level than QIO and are used by VMS curses although VMS curses doesnt
seem to simulate cbreak. If you are not using curses create a virtual keyboard:
unsigned kb;
SMG$CREATE_VIRTUAL_KEYBOARD(&kb);

then use read_keystroke

short key;
SMG$READ_KEYSTROKE(&kb,&key);

key is a short because function and arrow keys are  coded as numbers out of
ascii range. I used this method to add arrow key support for the VMS Rogue
that was posted a while back. Terminal independent  decoding of arrow keys !


--
Ian W Moor
  UUCP: seismo!mcvax!ukc!icdoc!iwm
  ARPA: iwm%icdoc@ucl

 Department of Computing   Whereat a great and far-off voice was heard, saying,
 Imperial College.         Poop-poop-poopy, and it was even so; and the days
 180 Queensgate            of Poopy Panda were long in the land.
 London SW7 Uk.

------------------------------

Date: 2 May 87 02:36:59 GMT
From: mcvax!uvabick!uucp@seismo.CSS.GOV (uucp)
Subject: Submission for mod-computers-vax

Path: uvabick!mcvax!ukc!dcl-cs!sslvax!gdw
From: gdw@ssl-macc.co.uk (Grenville Whelan)
Newsgroups: mod.computers.vax,comp.sys.dec
Subject: Re: redirection of stdio, et al.
Message-ID: <627@sslvaxssl-macc.co.uk>
Date: 30 Apr 87 17:17:35 GMT
References: <224@unc.cs.unc.edu>
Reply-To: gdw@ssl-macc.co.uk (Grenville Whelan)
Organization: Software Sciences Ltd, Macclesfield, UK
Lines: 19

In article <224@unc.cs.unc.edu> mcguffey@unc.cs.unc.edu (Michael McGuffey) writes:
>
>Does anyone know of any tools that allow command line redirection of
>stdio under VMS. Something similar to the way unix and msdos does it is
>preferable to some of the methods that have previously been proposed.
>
>-mike mcguffey


Simply redirect the logical SYS$OUTPUT to a file rather than the terminal,
ie.
     $ ASSIGN <FILE> SYS$OUTPUT
     $ <commands>
     $ DEASSIGN SYS$OUTPUT
--
# Grenville Whelan  -  Software Sciences Ltd, Park Street, Macclesfield, UK  #
# (EMAIL gdw@uk.co.ssl-macc) (UUCP !mcvax!ukc!mcvax!gdw) (TEL +44 625 29241) #

      "Are you the Police?"  "No ma'am, we're musicians!" -- Elwood.

------------------------------

Date: Fri, 1 May 87 23:31:49 PDT
From: carl@CitHex.Caltech.Edu (Carl J Lydick)
Subject: Re: How do you ring bell in DCL file?

 > I would like to have the terminal bell rung from within a DCL command
 > file.  Is there a way to specify control characters within a string
 > used with a 'write sys$output' statement? Can the control character be
 > entered "raw" into the string or is there a character escape mechanism?

 > I tried everything I could think of and didn't see anything in the orange
 > wall of manuals. Right now I 'type' a file which has a single bell character
 > in it.

For details of how to do this, type the command "$ HELP SYMBOL".  As an
example, to create a symbol containing only a control-G (ASCII 7), you could
use the following:
        $ BEL :=        !Make BEL a string symbol
        $ BEL[0,8] = 7  !Put an ASCII 7 in the first byte

------------------------------

Date: 1 May 87 16:19:44 GMT
From: tedcrane@tcgould.tn.cornell.edu  (Ted Crane)
Subject: Re: Accessing global variable from FORTRAN

In article <8704300556.AA02237@ucbvax.Berkeley.EDU> KND@DHDMPI5.BITNET writes:
>
>I would like to access a location in a MACRO Subroutine from a FORTRAN
>Main Program and don't want to use a COMMON for that.
>The location in MACRO is defined as follows :
>
>                LABEL:: .WORD   number
>
>The %LOC function in FORTRAN gives me the ADDRESS of 'LABEL'. But how
>can I get the contents of 'LABEL' ?

It is most likely that you will have to write a subroutine or function
to do this:

        subroutine MOVE_GLOBAL(IN,OUT)
        integer*2 IN,OUT
        OUT = IN
        end

and call it:

        call MOVE_GLOBAL(%val(LABEL),RESULT)

(You can extrapolate the function call form of this)

The interesting thing is that using VAX FORTRAN, the global variable
need not be a simple tpye such as <word=integer*2>.  All that is
necessary is to declare the global variable appropriately in the subroutine/
function.  It could be an array or a structure.  You could return any
value at all, whether it is one array element, a field from a structure, or
something calculated.

------------------------------

Date: 1 May 87 21:24:09 GMT
From: robert@arizona.edu  (Robert J. Drabek)
Subject: Re: How do you NOT write a <RETURN>? (was:ring bell in DCL
         file)?

In article <102@blic.BLI.COM>, garvey@blic.BLI.COM (Robert Garvey) writes:
>
> This is an example of how that could be done:
>       $ clear == "WRITE SYS$OUTPUT esc_chr,""[H"",esc_chr,""[2J"""

I have been using the above type of statements to do clear screens, but
they really leave the cursor on the second row since there is a
<return> effectively at the end of the write sys$output.

Is there someway around that?  (In Unix echo -n does the job.)
--
Robert J. Drabek
Department of Computer Science
University of Arizona
Tucson, AZ  85721

------------------------------

Date: 1  May 87 16:23 -0800
From: Ken Wallewein <kenw%noah.arc.cdn%ubc.csnet@RELAY.CS.NET>
Subject: RE: vi written in TPU



------------------------------

Date: 1 May 87 10:28:44 GMT
From: eagle!rde@ucbvax.Berkeley.EDU  (R.D.Eager)
Subject: Terminal capture program wanted

I am after a program to enable recording of a terminal session on VMS. I
saw  an  example  of one during an explanation of a different topic in a
recent article, but couldn't contact the author.

The program I saw was called PHOTO, and you typed something like:

    $ PHOTO file
    $   .
    $
    $   .
    $ ! either logout or PHOTO something

and file would contain all the intermediate terminal transactions.

Any ideas please?
--
           Bob Eager
           rde@ukc.UUCP
           ...!mcvax!ukc!rde
           Phone: +44 227 66822 ext 7589

------------------------------

Date: 30 Apr 87 21:45:50 GMT
From: trwrb!ucla-an!medivax!chinson@ucbvax.Berkeley.EDU  (Chinson Yi)
Subject: VMS pseudo terminal set up

I am trying to set ther pseudo-terminals characteristics for
DECserver 100 tapped into DECnet.   The system calls it
LTA[0-7] but you can only set it when the line is active.
Is there anyother way to set it ?

Chinson Yi
UCLA, Dept of Medicine

------------------------------

End of Info-Vax Digest
**********************