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

  1. /*
  2.  *   System Dependent Application Message Handling
  3.  *
  4.  *   OS/2 Lan Manager using named pipes
  5.  *
  6.  *    This program is the CONFIDENTIAL and PROPRIETARY property 
  7.  *    of FairCom(R) Corporation. Any unauthorized use, reproduction or
  8.  *    transfer of this program is strictly prohibited.
  9.  *
  10.  *      Copyright (c) 1987, 1988, 1989 FairCom Corporation
  11.  *    (Subject to limited distribution and
  12.  *     restricted disclosure only.)
  13.  *    *** ALL RIGHTS RESERVED ***
  14.  *
  15.  *    4006 West Broadway
  16.  *    Columbia, MO 65203
  17.  *
  18.  *
  19.  *    c-tree(R)    Version 4.3
  20.  *            Release C
  21.  *            February 7, 1989 17:30
  22.  *
  23.  */
  24.  
  25. #include "ctstdr.h"
  26. #include "ctoptn.h"
  27. #include "ctstrc.h"
  28. #include "cterrc.h"
  29. #include "ctcomm.h"
  30.  
  31. #define INCL_CLIENTPIPE  
  32. #include "ctpipes.h"
  33.  
  34. #include <string.h>
  35.  
  36. #ifdef DEBUG
  37.  #ifdef LOCAL
  38.   #undef LOCAL
  39.   #define LOCAL /* */
  40.  #endif
  41. #endif
  42.  
  43.  
  44. LOCAL TEXT usrname[USR_NAME_LEN] = USR_NETNAME;
  45. LOCAL UCOUNT sess_no;
  46. LOCAL UCOUNT msgsiz;
  47.  
  48. extern COUNT uerr_cod;
  49. extern TEXT  ct_buf[];
  50. extern UCOUNT cts_apxsiz;
  51.  
  52. TEXT *mballc();
  53.  
  54. /* copies a file name, after modifying name to a fully specified form */
  55. COUNT fulnam(dp, tp,maxlen) 
  56. PFAST TEXT  *dp,*tp;
  57. COUNT          maxlen;
  58. {
  59.    strcpy(dp,tp);
  60.    return(NO_ERROR);
  61. }
  62.  
  63.  
  64. /*
  65.  * get server message id, create application id, & get space
  66.  * for msg
  67.  */
  68. TEXT *getmids(UCOUNT apsize, MESSAGE *pmsg)
  69. {
  70. TEXT *retval;
  71. UCOUNT e, local;
  72. TEXT *p_str;
  73. char   is_progparam[NAMESIZE];
  74. int proc_typ;
  75.  
  76.    if (ct_srv_use) {             /* server or local use ? */
  77.       strcpy(pipename, "\\\\");
  78.       strcat(pipename, SRV_NETNAME);
  79.       local = 0;
  80.    }
  81.    else {
  82.       strcpy(pipename, "\0");
  83.       local = 1;
  84.    }
  85.    strcat(pipename, ISAM_PIPENAME);
  86.  
  87.    uerr_cod = 0;
  88.    msgsiz = apsize;      /* local copy of msg len */
  89.  
  90.    cpybuf(is_progparam, ISAM_SRV_PARAMS, sizeof(ISAM_SRV_PARAMS));
  91.    if (e = startusepipe(pipename,ISAM_SRV_PROGNAME,is_progparam,local)) {
  92.       if (e != PIPE_STARTED_LOCAL) {
  93.          uerr_cod = ASKY_ERR;
  94.          return (NULL);
  95.       }
  96.    }
  97.  
  98.   /*
  99.    * get application user name
  100.    */
  101.     if ((p_str = get_net_user_name()) != NULL)
  102.       strcpy(usrname,p_str);
  103.    else
  104.       strcpy(usrname,USR_NETNAME);
  105.  
  106.   /* get application screen-group / process number,
  107.    * only one user logged in at server per screen session
  108.    *
  109.    * Return type of process :
  110.    *        0 = Full screen
  111.    *        1 = Windowed appl
  112.    *        2 = Background
  113.    *        9 = Other
  114.    */
  115.    proc_typ = get_process_type();
  116.    if (proc_typ == 0 || proc_typ == 1)
  117.       sess_no = get_curr_screen_group();   /* Full screen */
  118.    else {
  119.       sess_no = get_process_id();
  120.       if (proc_typ == 3)
  121.          /* proc_id < max. screen groups */
  122.          sess_no += 20000;
  123.    }
  124.    /* get space for message structure required by system */
  125.     if ((retval = mballc(1,apsize)) == NULL) {
  126.       disconnect();
  127.       uerr_cod = ASPC_ERR;
  128.       return (NULL);
  129.    }
  130.  
  131.    /* application message id into mpntr member of message header */
  132.    pmsg->mpntr = get_process_id();
  133.  
  134.    return (retval);      
  135. }
  136.  
  137. COUNT ridmids()
  138. {
  139.    disconnect();
  140.    return (0);
  141. }
  142.  
  143. COUNT ctrqst(msgadr,pmsg)
  144. PFAST TEXT  *msgadr;    /* ptr to message area */
  145. MESSAGE     *pmsg;      /* ptr to message header */
  146. {
  147. unsigned msglen;
  148.  
  149.    /* copy message header */
  150.    cpybuf(msgadr,pmsg,sizeof(MESSAGE));
  151.  
  152.     /* if TST_MSGSIZ (login), add machine name to
  153.      * message (will be stripped off by ctsmsg)
  154.      */
  155.     if (pmsg->mfunc == TST_MSGSIZ ||
  156.         pmsg->mfunc == TST_SPCLOG)    {
  157.         ((MESSAGE *) msgadr)->mdlen += (USR_NAME_LEN + sizeof(int) + 1);
  158.         cpybuf(msgadr + sizeof(MESSAGE) + pmsg->mdlen,
  159.               (char*)&sess_no, sizeof(int));
  160.         cpybuf(msgadr + sizeof(MESSAGE) + pmsg->mdlen + sizeof(int),
  161.               usrname, USR_NAME_LEN);
  162.         *(msgadr + sizeof(MESSAGE) + pmsg->mdlen + 15) = 0;
  163.     }
  164.  
  165.     msglen = sizeof(MESSAGE) + ((MESSAGE *) msgadr)->mdlen;
  166.  
  167.   /*
  168.    * send and receive message (RPC-call)
  169.    */
  170.    if (!(msglen = dopipe(pipename, (char far*)msgadr, msglen,
  171.                                    (char far*)msgadr))) {
  172.       pmsg->merrn = uerr_cod = ARQS_ERR;
  173.       return(uerr_cod);
  174.    }
  175.  
  176.    /* update callers header buffer */
  177.    cpybuf(pmsg, msgadr, sizeof(MESSAGE));
  178.  
  179.    return (NO_ERROR);
  180. }
  181.  
  182. COUNT ctrspn(msgadr,pmsg)
  183. PFAST TEXT **msgadr;
  184. MESSAGE    *pmsg;
  185. {
  186.    return (NO_ERROR);
  187. }
  188.  
  189.  
  190. /*
  191.  * hangup. if user hasn't logically logged off, server will clean up anyway
  192.  */
  193. disconnect()
  194. {
  195. }
  196.  
  197. /* end of ctamsg.c */
  198.