home *** CD-ROM | disk | FTP | other *** search
- /*
- * System Dependent Application Message Handling
- * VMS 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"
-
- /* LTYPE is defined in ctmssg.h */
-
- #define DIR_SEP '/'
- #define DIR_PAR '.'
-
- LOCAL TEXT dir_sepstr[] = {
- DIR_SEP,
- '\0'};
- LOCAL UCOUNT msgsiz;
- extern COUNT uerr_cod;
- extern TEXT ct_buf[];
-
- /* copies a file name, after modifying name to a fully specified form */
- COUNT fulnam(dp, tp,maxlen)
- PFAST TEXT *dp,*tp;
- COUNT maxlen;
- {
- COUNT bpos;
-
- if (strlen(tp) > maxlen)
- return(uerr_cod = AFLN_ERR);
- strcpy(dp,tp);
- return(NO_ERROR);
- }
-
- TEXT *getmids(apsize,pmsg)
- UCOUNT apsize;
- MESSAGE *pmsg;
- {
- TEXT *retval;
- long status;
- TEXT *mballc();
- static $DESCRIPTOR(TABNAM,"LNM$PROCESS_DIRECTORY");
- static $DESCRIPTOR(LOGNAM,"LNM$TEMPORARY_MAILBOX");
- char *ename = {"LNM$SYSTEM"};
- struct items {
- unsigned short length,code;
- unsigned long address,retadr;
- }itmlst[2];
-
- itmlst[0].length = strlen(ename);
- itmlst[0].code = LNM$_STRING;
- itmlst[0].address = ename;
- itmlst[0].retadr = 0;
- itmlst[1].length = 0;
- itmlst[1].code = 0;
-
- /* get server msg id */
- uerr_cod = 0;
-
- /* open permanent mailbox to server */
- /* make size that of several messages */
- msgsiz = apsize;
-
- if ((status = SYS$CREMBX(1,&srvid,apsize,apsize*MXMSG,0,
- PSL$C_USER,&SERVER)) != SS$_NORMAL)
- uerr_cod = ASID_ERR;
-
- /* change logical name table for temporary mailboxes*/
-
- status = SYS$CRELNM(0,&TABNAM,&LOGNAM,0,&itmlst);
-
- /* open temporary mailbox back to this process */
- /* make size that of only one message */
-
- apxid = getpid(); /* use process id for vms */
-
- sprintf(usrstr,"USER%04X\0",apxid); /* make user id for mbx*/
-
- 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);
-
- if ((status = SYS$CREMBX(0,&dummy,1024,1024,0,
- PSL$C_USER,&user)) != SS$_NORMAL)
- uerr_cod = AMST_ERR;
-
- if (uerr_cod)
- return(NULL);
-
- /* get space for message structure required by system */
- if ((retval = mballc(1,apsize + LTYPE)) == NULL) {
- uerr_cod = ASPC_ERR;
- return(NULL);
- }
-
- /* set application message id into mpntr member of message header */
- pmsg->mpntr = apxid;
-
- /* return pointer to actual text portion */
- return(retval + LTYPE);
- }
-
- COUNT ridmids()
- {
-
- /* remove application message handling */
- long status;
-
- if ((status = SYS$DELMBX(dummy)) != SS$_NORMAL)
- return(uerr_cod = AMRD_ERR);
- else
- return(NO_ERROR);
- }
-
- COUNT ctrqst(msgadr,pmsg)
- PFAST TEXT *msgadr; /* ptr to message area */
- MESSAGE *pmsg; /* ptr to message header */
- {
- int msglen;
- long status;
-
- /* copy message header */
- cpybuf(msgadr,pmsg,sizeof(MESSAGE));
- msglen = sizeof(MESSAGE) + pmsg->mdlen;
-
- /* send message: ordinarily an interprocess comm call (e.g., q call) */
- if ((status = sys$qiow(1,srvid,IO$_WRITEVBLK|IO$M_NOW,
- &iosb,0,0,msgadr,msglen,0,0,0,0)) != SS$_NORMAL)
- return(uerr_cod = ARQS_ERR);
- else
- return(NO_ERROR);
- }
-
- COUNT ctrspn(msgadr,pmsg)
- PFAST TEXT **msgadr;
- MESSAGE *pmsg;
- {
- /* get response: interprocess comm call which leaves answer in apxmsg */
-
- long status;
-
- if((status = sys$qiow(1,dummy,IO$_READVBLK,&iosb,0,0,
- *msgadr,1024,0,0,0,0)) != SS$_NORMAL)
- return(uerr_cod = ARSP_ERR);
-
- /* copy message header */
- cpybuf(pmsg,*msgadr,sizeof(MESSAGE));
-
- return(NO_ERROR);
- }
-
- /* end of ctamsg.vms */
-