From:	US2RMC::"gezelter@rlgsc.com" "Robert Gezelter" 29-DEC-1996 13:55:14.07
To:	star::everhart
CC:	
Subj:	Modified Example Program for DECnet

Glenn,
 
The following is the example program which appears to run correctly on VAX 
(at least on my good old 5.4-2 MVII) and fails on a client DEC 3000 (OVMS 
6.1). Illuminating insight would be appreciated!
 
I made some changes to abstract the code, but I get back an ACCVIO from the 
QIO call. The C++ compiler that I am using is 5.4.
 
Thanks in advance!
 
- Bob
+--------------------------------------------------------------------------+
| Robert "Bob" Gezelter                       E-Mail:  gezelter@rlgsc.com  |
| Robert Gezelter Software Consultant         Voice:   +1 718 463 1079     |
| 35-20 167th Street, Suite 215               Fax:       (on Request)      |
| Flushing, New York  11358-1731                                           |
| United States of America                                                 |
+--------------------------------------------------------------------------+
-----------------------------------Included Text--------------------
/*	.TITLE	DB_SERVER - Database server program			   *
 *	.IDENT	'X-4'							   */

/***************************************************************************/
/*									   */
/*  COPYRIGHT (c) 1978, 1980, 1982, 1984 BY				   */
/*  DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASSACHUSETTS.		   */
/*  ALL RIGHTS RESERVED.						   */
/* 								           */
/*  THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED  */
/*  ONLY IN  ACCORDANCE WITH  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE  */
/*  INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR  ANY  OTHER  */
/*  COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY  */
/*  OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE IS  HEREBY  */
/*  TRANSFERRED.							   */
/* 									   */
/*  THE INFORMATION IN THIS SOFTWARE IS  SUBJECT TO CHANGE WITHOUT NOTICE  */
/*  AND  SHOULD  NOT  BE  CONSTRUED AS  A COMMITMENT BY DIGITAL EQUIPMENT  */
/*  CORPORATION.							   */
/* 									   */
/*  DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE  OR  RELIABILITY OF ITS  */
/*  SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.		   */
/* 									   */
/*									   */
/***************************************************************************/

/*++									   */
/* FACILITY:	DECnet nontransparent task-to-task communication.          */

/* ABSTRACT:	DB_SERVER						   */

/* This program demonstrates how to declare a known network object and     *
 * service and manage multiple connect requests.  It is a simple           *
 * implementation of task-to-task communication using DECnet               *
 * nontransparently.  DB_SERVER accesses the database DB_USER, based on    * 
 * the name key supplied in the request buffer, and sends a response to    *
 * the requesting node.                                                    */

/* ENVIRONMENT:	User mode						   */

/* AUTHOR:  Scott A. Shurts, 	CREATION DATE:  10-Nov-1986		   */

/* MODIFIED BY:								   */
/*  									   */
/*  X-4	    JC00001	Jim Colombo			13-Dec-1991        */
/*	    Added support for new CPU architecture.			   */
/*									   */
/*  X-3	    SAS0210	Scott A. Shurts			06-Nov-1989        */
/*	    Add missing "return return_status" in initialize_variables.	It */
/*	    was detected when the compiler optimization changed behavior.  */
/*                                                                         */
/*  X-2	    SAS0039     Scott A. Shurts                 06-Sept-1988       */
/*          Insert align macro for explicit quadword alignment of queue    */
/*          header and buffers.  This was previously done implicitly by    */
/*          the compiler.  Also change the use of the return_status        */
/*          variable in the ast_routine. Change the definition of the      */
/*          pointers cur_buff and netcmd_buff to reference the buff_blk    */
/*          structure.                                                     */
/*                                                                         */

/*  INCLUDE EXTERNAL CONSTANTS                                             */

#include <descrip>
#include <dvidef>
#include <iodef>
#include <msgdef>
#include <nfbdef>
#include <starlet>

#pragma nomember_alignment
#include <fab>
#include <rab>
#include <rmsdef>

#pragma member_alignment
#include <ssdef>
#include <stsdef>
#include <stdio>

/*  DEFINE LOCAL CONSTANTS                                                 */

#define TEMP_MBX 0
#define MAX_BUFFS 100
#define MAX_LINKS 32   		    /*  Must be <= 32  for ffs/ffc to work */
#define MAX_NAME 20
#define MAX_ACCOUNT 11
#define MAX_PHONE 14
#define MAX_ADDRESS 30
#define MAX_LOCATION 30
#define MAX_REC_SIZE MAX_NAME+MAX_ACCOUNT+MAX_PHONE+MAX_ADDRESS+MAX_LOCATION+4
#define BUF_QUO 128
#define MAX_MSG 128
#define MAX_NCB 110

/*  DEFINE AST COMPLETION TYPES                                            */

#define NET_RD 1
#define NET_WRT 2
#define NET_CMD 3

/*  DEFINE QUEUE HEADER CONSTANTS                                          */

#define FREE_QUE 0
#define LIVE_QUE 1

/*  DEFINE GLOBAL DATA STRUCTURES                                          */

#pragma nomember_alignment
    struct data_blk {
	char name[MAX_NAME];
	char account[MAX_ACCOUNT];
	char phone[MAX_PHONE];
	char address[MAX_ADDRESS];
	char location[MAX_LOCATION];
	int  status;
	char spare[7];
    };

    struct mbx_blk {
	short int msg;
	short int unit;
	char name_info[MAX_NCB];
    };

    struct ast_blk {
	char type;
	short int ndx;
	char unused;
    };

    struct io_stat_blk {
	short int status ;
        short int msg_len ;
        int unused;
    };

    struct buff_blk {
	int flink;
	int blink;
	union {
	    int astid;
	    struct ast_blk ast;
	} cmplt_stat;
	struct io_stat_blk iosb;
	union {
	    struct data_blk data;
	    struct mbx_blk mbx_msg;
	} msg_area;
    } ;

/*  DECLARE AST ROUTINE                                                    */

int ast_routine ();

/*  DECLARE DATA                                                           */

#pragma member_alignment
    struct FAB db_fab;
    struct RAB db_rab;

    struct io_stat_blk iosb ;

    struct {
	char func;
	int terminator;
    } nfb = { NFB$C_DECLNAME, 0 };

    int dvi_unit;

    struct {
	short int buff_len;
	short int code;
	int *ret_info;
	int ret_len;
	int terminator;
    } getdvi_itm = { 4, DVI$_UNIT, &dvi_unit, 0, 0 };

    int return_status, lct_alloc_mask = 0, mask_siz = 32, rtry = 10;
    struct buff_blk *cur_buff, *netcmd_buff;
    short int netdcl_chan, mbx_chan, mbx_msg_len = MAX_MSG;
    char index, start_pos, net_shut = 0;
    char ncb[MAX_NCB];
    char db_file[19] = "DB_DIR:DB_USER.IDX";

/*  BUILD DESCRIPTORS                                                      */

    static $DESCRIPTOR ( net_device, "_NET:" );
    static $DESCRIPTOR ( object_name, "DB_SERVER" );
    static $DESCRIPTOR ( netcmd_mbx, "NETCMD_MBX" );

    struct dsc$descriptor_s nfb_desc;
    struct dsc$descriptor_s ncb_desc;

initialize_variables ()

{
    int i;
    return_status = SS$_NORMAL;
    net_shut = 0;

    nfb_desc.dsc$w_length = sizeof( nfb );
    nfb_desc.dsc$a_pointer = (char *)(&nfb); 
    nfb_desc.dsc$b_dtype = DSC$K_DTYPE_T;
    nfb_desc.dsc$b_class = DSC$K_CLASS_S;

    return return_status;

}

declare_network_object ()

/* Declare the DB_SERVER process as a know network object to allow the     * 
 * reception of multiple inbound connect requests.  The three steps are:   *
 *   1.  Create a temporary mailbox to receive network command messages.   *
 *   2.  Assign a channel to the _NET device and associate the temporary   *
 *       mailbox with it.                                                  *
 *   3.  Issue a QIO with a function code of IO$_ACPCONTROL, the P1        *
 *       parameter set to the address of the network function block (nfb), *
 *       and the P2 parameter set to the address of the descriptor         *
 *       containing the object name to be declared.                        */

{
    return_status = sys$crembx ( TEMP_MBX,
				 &mbx_chan,
				 MAX_MSG,
				 BUF_QUO, 
				 0, 0,
				 &netcmd_mbx );

    if ( return_status & STS$M_SUCCESS ) {
	return_status = sys$assign ( &net_device,
				     &netdcl_chan,
				     0,
				     &netcmd_mbx );

	if ( return_status & STS$M_SUCCESS ) {
	    return_status = sys$qiow (  0,
	 				netdcl_chan,
					IO$_ACPCONTROL,
					&iosb,
					0, 0,
					&nfb_desc,
					&object_name,
					0, 0, 0, 0 );
	    if ( return_status & STS$M_SUCCESS )
		return_status = iosb.status;
	}
    }
    return return_status;
}
initialization ()

/*  Set up descriptors, initialize variables, queues and buffers, declare   *
/*  the process as a network receiver, open the database, and issue a read  *
/*  to the network command mailbox.                                         */

{
	return_status = initialize_variables ();
	return_status = declare_network_object ();
	return return_status;
	}

main ()

/* After initialization, DB_SERVER processes requests until a NETSHUT      *
 * message is received in the network command mailbox.  Asynchronous       *
 * processing, which permits several logical links to be serviced          *
 * concurrently, is achieved through the use of asynchronous system traps  *
 * (ASTs).                                                                 */

{
    return_status = initialization () ;

}

------------------------------End Included File ------------------------------

% ====== Internet headers and postmarks (see DECWRL::GATEWAY.DOC) ======
% Received: from mail13.digital.com by us2rmc.zko.dec.com (5.65/rmc-22feb94) id AA19519; Sun, 29 Dec 96 13:47:08 -0500
% Received: from tam.dorsai.org by mail13.digital.com (8.7.5/UNX 1.5/1.0/WV) id NAA17750; Sun, 29 Dec 1996 13:43:54 -0500 (EST)
% Received: from kensie.dorsai.org (root@kensie.dorsai.org [206.127.32.39]) by tam.dorsai.org (8.8.0/8.6.12) with ESMTP id NAA16429 for <everhart@star.enet.dec.com>; Sun, 29 Dec 1996 13:39:10 -0500 (EST)
% Received: from rlgsc.UUCP (uucp@localhost) by kensie.dorsai.org (8.6.12/8.6.12) with UUCP id OAA07043 for star.enet.dec.com!everhart; Sun, 29 Dec 1996 14:38:30 -0500
% Received: by rlgsc.com (DECUS UUCP 1.2 w/Smail); Sun, 29 Dec 96 13:28:53 EST
% Date: Sun, 29 Dec 96 13:28:53 EST
% Message-Id: <009AD914B2FC6620.00000170@rlgsc.com>
% From: Robert Gezelter <gezelter@rlgsc.com>
% Subject: Modified Example Program for DECnet
% To: star::everhart
% X-Vms-Mail-To: UUCP%"everhart@star.enet.dec.com"
% X-Vms-Mail-Cc: GEZELTER
