home *** CD-ROM | disk | FTP | other *** search
- /*
- * System Dependent Server Message Handler
- * VMS MailBox Implementation
- *
- * This program is the CONFIDENTIAL and PROPRIETARY property
- * of FairCom(R) Corporation. Any unauthorized use, reproduction or
- * transfer of this program is strictly prohibited.
- *
- * Copyright (c) 1988, 1989 FairCom Corporation
- * (Subject to limited distribution and
- * restricted disclosure only.)
- * *** ALL RIGHTS RESERVED ***
- *
- * 4006 West Broadway
- * Columbia, MO 65203
- *
- *
- * c-tree(R) Version 4.3
- * Release C
- * February 7, 1989 17:30
- *
- */
-
- #include "ctstdr.h"
- #include "ctoptn.h"
- #include "ctstrc.h"
- #include "cterrc.h"
- #include "ctcomm.h"
- #include "ctmssg.h"
-
- LOCAL UCOUNT msgsiz;
- LOCAL LONG *ausrmid;
-
- extern COUNT uerr_cod;
-
- /* elapsed time before unread user queue declared inactive */
- #define INDEFINITE 5 /* seconds */
-
- /* LTYPE is defined in ctmsgg.h */
-
- TEXT *getmid(sizmsg,maxusr)
- UCOUNT sizmsg;
- COUNT maxusr;
- {
- TEXT *retval;
-
- long status;
- TEXT *mballc();
-
- /* allocate an array for message ids: assumes long is OK */
- if ((ausrmid = (LONG *) mballc(maxusr + 1,sizeof(LONG))) == NULL) {
- uerr_cod = SSCB_ERR;
- return(NULL);
- }
-
- /* get message id for server */
- uerr_cod = 0;
-
- /* open permanent mailbox to server */
-
- if ((status = SYS$CREMBX(1,&srvid,sizmsg,
- sizmsg*MXMSG,0,PSL$C_USER,&SERVER)) != SS$_NORMAL)
- uerr_cod = ASID_ERR;
-
- if (uerr_cod)
- return(NULL);
-
-
- /* get space for server message */
- if ((retval = mballc(1,sizmsg + LTYPE)) == NULL) {
- uerr_cod = SSPC_ERR;
- return(NULL);
- }
-
- return(retval + LTYPE);
- }
-
- LONG getumsg(pmsg,usrn,msgptr) /* assumes that mpntr member contains msg id */
- MESSAGE *pmsg;
- COUNT usrn;
- TEXT *msgptr;
- {
- /* save message id of application: assumes that a long is sufficient */
- if (usrn >= 0)
- ausrmid[usrn] = pmsg->mpntr;
-
- return(pmsg->mpntr);
- }
-
- COUNT ridmid()
- {
-
- /* remove application message handling */
- long status;
-
- if ((status = SYS$DELMBX(srvid)) != SS$_NORMAL)
- return(uerr_cod = SMRD_ERR);
- else
- return(NO_ERROR);
- }
-
- COUNT dedusr(msgid)
- LONG msgid;
- {
- return(-1);
- }
-
- COUNT ctrqst(msgadr,pmsg)
- PFAST TEXT **msgadr;
- MESSAGE *pmsg;
- {
- /* read input message */
- long status;
-
- if((status = sys$qiow(1,srvid,IO$_READVBLK,&iosb,0,0,
- *msgadr,CTS_MAXSMSG,0,0,0,0)) != SS$_NORMAL)
- return(uerr_cod = SRQS_ERR);
-
- /* copy message header */
- cpybuf(pmsg,*msgadr,sizeof(MESSAGE));
-
- return(NO_ERROR);
- }
-
- COUNT ctrspn(msgadr,pmsg,sizmsg,usrn)
- PFAST TEXT *msgadr;
- MESSAGE *pmsg;
- UCOUNT sizmsg;
- COUNT usrn;
- {
- /* local copy of message id with correct type */
- int locmid;
- long status;
-
- if (usrn < 0)
- usrn = - (usrn + 1);
- locmid = ausrmid[usrn];
-
- /* copy message header */
- cpybuf(msgadr,pmsg,sizeof(MESSAGE));
-
- /* send response */
- sprintf(usrstr,"USER%04X\0",locmid);
-
- user.dsc$b_class = DSC$K_CLASS_D; /* dynamic descriptor */
- user.dsc$b_dtype = DSC$K_DTYPE_T; /* character type */
- user.dsc$a_pointer = usrstr;
- user.dsc$w_length = strlen(usrstr);
-
- status = sys$assign(&user,&dummy,0,0); /* get channel */
-
- status = sys$qiow(1,dummy,IO$_WRITEVBLK|IO$M_NOW,
- &iosb,0,0,msgadr,sizmsg,0,0,0,0);
-
- sys$dassgn(dummy); /* get rid of channel */
-
- if (status != SS$_NORMAL)
- return(uerr_cod = SRSP_ERR);
-
- return(NO_ERROR);
-
- }
-
- COUNT norspn(usrn)
- COUNT usrn;
- {
- /* a non-zero response from norspn() indicates inactive user */
-
- /* current time measure */
- long time();
- long status;
-
- /* local copy of message id with correct type */
- int locmid;
-
- locmid = ausrmid[usrn];
-
- /* get status of user queue and see if it has unread messages */
-
- /* make attempt at getting mailbox information */
-
- sprintf(usrstr,"USER%04X\0",locmid);
-
- user.dsc$b_class = DSC$K_CLASS_D; /* dynamic descriptor */
- user.dsc$b_dtype = DSC$K_DTYPE_T; /* character type */
- user.dsc$a_pointer = usrstr;
- user.dsc$w_length = strlen(usrstr);
-
- status = sys$assign(&user,&dummy,0,0); /* get channel */
-
-
- if (status != SS$_NORMAL)
- return(YES);
-
- sys$dassgn(dummy);
-
- if (iosb.status != SS$_NORMAL)
- return(YES);
- else
- return(NO);
-
- /* successful status check with no unread messages left with user */
- return(NO);
- }
-
- chkusrtim(usrtim,usrmap,usrtrn)
- LONG *usrtim;
- COUNT *usrmap;
- LONG *usrtrn;
- {
- /*
- * This function can interrogate the usrtim[] array to
- * determine if any active user slot is in fact dead.
- */
- return(NO_ERROR);
- }
-
- /* end of ctsmsg.vms */
-