home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c004 / 3.ddi / VAX / CTAMSG.C next >
Encoding:
C/C++ Source or Header  |  1989-04-18  |  4.6 KB  |  175 lines

  1. /*
  2.  *      System Dependent Application Message Handling
  3.  *      VMS Implementation
  4.  *
  5.  *    This program is the CONFIDENTIAL and PROPRIETARY property 
  6.  *    of FairCom(R) Corporation. Any unauthorized use, reproduction or
  7.  *    transfer of this program is strictly prohibited.
  8.  *
  9.  *      Copyright (c) 1988, 1989 FairCom Corporation
  10.  *    (Subject to limited distribution and
  11.  *     restricted disclosure only.)
  12.  *    *** ALL RIGHTS RESERVED ***
  13.  *
  14.  *    4006 West Broadway
  15.  *      Columbia, MO 65203
  16.  *
  17.  *
  18.  *      c-tree(R)      Version 4.3
  19.  *                      Release C
  20.  *                      February 7, 1989 17:30
  21.  *
  22.  */
  23.  
  24. #include "ctstdr.h"
  25. #include "ctoptn.h"
  26. #include "ctstrc.h"
  27. #include "cterrc.h"
  28. #include "ctcomm.h"
  29. #include "ctmssg.h"
  30.  
  31. /* LTYPE is defined in ctmssg.h */
  32.  
  33. #define DIR_SEP '/'
  34. #define DIR_PAR '.'
  35.  
  36. LOCAL TEXT dir_sepstr[] = {
  37.                         DIR_SEP,
  38.                         '\0'};
  39. LOCAL UCOUNT msgsiz;
  40. extern COUNT uerr_cod;
  41. extern TEXT  ct_buf[];
  42.  
  43. /* copies a file name, after modifying name to a fully specified form */
  44. COUNT fulnam(dp, tp,maxlen) 
  45. PFAST TEXT  *dp,*tp;
  46. COUNT               maxlen;
  47. {
  48.         COUNT bpos;
  49.  
  50.         if (strlen(tp) > maxlen)
  51.                 return(uerr_cod = AFLN_ERR);
  52.         strcpy(dp,tp);
  53.         return(NO_ERROR);
  54. }
  55.  
  56. TEXT *getmids(apsize,pmsg)
  57. UCOUNT        apsize;
  58. MESSAGE             *pmsg;
  59. {
  60.         TEXT *retval;
  61.     long status;
  62.         TEXT *mballc();
  63.     static $DESCRIPTOR(TABNAM,"LNM$PROCESS_DIRECTORY");
  64.     static $DESCRIPTOR(LOGNAM,"LNM$TEMPORARY_MAILBOX");
  65.     char *ename = {"LNM$SYSTEM"};
  66.     struct items {
  67.         unsigned short length,code;
  68.         unsigned long address,retadr;
  69.     }itmlst[2];
  70.  
  71.     itmlst[0].length = strlen(ename);
  72.     itmlst[0].code = LNM$_STRING;
  73.     itmlst[0].address = ename;
  74.     itmlst[0].retadr = 0;
  75.     itmlst[1].length = 0;
  76.     itmlst[1].code = 0;
  77.  
  78.         /* get server msg id */
  79.         uerr_cod = 0;
  80.  
  81.     /* open permanent mailbox to server */
  82.     /* make size that of several messages */
  83.         msgsiz            = apsize;
  84.  
  85.     if ((status = SYS$CREMBX(1,&srvid,apsize,apsize*MXMSG,0,
  86.                PSL$C_USER,&SERVER)) != SS$_NORMAL)
  87.             uerr_cod = ASID_ERR;
  88.                           
  89.         /* change logical name table for temporary mailboxes*/
  90.  
  91.     status = SYS$CRELNM(0,&TABNAM,&LOGNAM,0,&itmlst);
  92.       
  93.         /* open temporary mailbox back to this process */
  94.                 /* make size that of only one message */
  95.  
  96.     apxid = getpid();    /* use process id for vms */
  97.  
  98.     sprintf(usrstr,"USER%04X\0",apxid);    /* make user id for mbx*/
  99.  
  100.     user.dsc$b_class = DSC$K_CLASS_D;    /* dynamic descriptor */
  101.     user.dsc$b_dtype = DSC$K_DTYPE_T;    /* character type */
  102.     user.dsc$a_pointer = usrstr;
  103.     user.dsc$w_length = strlen(usrstr);
  104.       
  105.     if ((status = SYS$CREMBX(0,&dummy,1024,1024,0,
  106.          PSL$C_USER,&user)) != SS$_NORMAL)
  107.             uerr_cod = AMST_ERR;
  108.  
  109.         if (uerr_cod)
  110.                 return(NULL);
  111.  
  112.         /* get space for message structure required by system */
  113.         if ((retval = mballc(1,apsize + LTYPE)) == NULL) {
  114.                 uerr_cod = ASPC_ERR;
  115.                 return(NULL);
  116.         }
  117.  
  118.         /* set application message id into mpntr member of message header */
  119.         pmsg->mpntr = apxid;
  120.  
  121.         /* return pointer to actual text portion */
  122.         return(retval + LTYPE);
  123. }
  124.  
  125. COUNT ridmids()
  126. {
  127.  
  128.         /* remove application message handling */
  129.     long status;
  130.  
  131.     if ((status = SYS$DELMBX(dummy)) != SS$_NORMAL)
  132.                 return(uerr_cod = AMRD_ERR);
  133.         else
  134.                 return(NO_ERROR);
  135. }
  136.  
  137. COUNT ctrqst(msgadr,pmsg)
  138. PFAST TEXT  *msgadr;            /* ptr to message area          */
  139. MESSAGE            *pmsg;       /* ptr to message header        */
  140. {
  141.         int msglen;
  142.     long status;
  143.  
  144.         /* copy message header */
  145.         cpybuf(msgadr,pmsg,sizeof(MESSAGE));
  146.         msglen = sizeof(MESSAGE) + pmsg->mdlen;
  147.  
  148.         /* send message: ordinarily an interprocess comm call (e.g., q call) */
  149.     if ((status = sys$qiow(1,srvid,IO$_WRITEVBLK|IO$M_NOW,
  150.                 &iosb,0,0,msgadr,msglen,0,0,0,0)) != SS$_NORMAL)
  151.                 return(uerr_cod = ARQS_ERR);
  152.         else
  153.                 return(NO_ERROR);
  154. }
  155.  
  156. COUNT ctrspn(msgadr,pmsg)
  157. PFAST TEXT **msgadr;
  158. MESSAGE            *pmsg;
  159. {
  160.         /* get response: interprocess comm call which leaves answer in apxmsg */
  161.  
  162.     long status;
  163.  
  164.     if((status = sys$qiow(1,dummy,IO$_READVBLK,&iosb,0,0,
  165.                *msgadr,1024,0,0,0,0)) != SS$_NORMAL)
  166.                 return(uerr_cod = ARSP_ERR);
  167.  
  168.         /* copy message header */
  169.         cpybuf(pmsg,*msgadr,sizeof(MESSAGE));
  170.  
  171.         return(NO_ERROR);
  172. }
  173.  
  174. /* end of ctamsg.vms */
  175.