home *** CD-ROM | disk | FTP | other *** search
- /*
- * System Dependent Application Message Handling
- *
- * OS/2 Lan Manager using named pipes
- *
- * 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) 1987, 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"
-
- #define INCL_CLIENTPIPE
- #include "ctpipes.h"
-
- #include <string.h>
-
- #ifdef DEBUG
- #ifdef LOCAL
- #undef LOCAL
- #define LOCAL /* */
- #endif
- #endif
-
-
- LOCAL TEXT usrname[USR_NAME_LEN] = USR_NETNAME;
- LOCAL UCOUNT sess_no;
- LOCAL UCOUNT msgsiz;
-
- extern COUNT uerr_cod;
- extern TEXT ct_buf[];
- extern UCOUNT cts_apxsiz;
-
- TEXT *mballc();
-
- /* copies a file name, after modifying name to a fully specified form */
- COUNT fulnam(dp, tp,maxlen)
- PFAST TEXT *dp,*tp;
- COUNT maxlen;
- {
- strcpy(dp,tp);
- return(NO_ERROR);
- }
-
-
- /*
- * get server message id, create application id, & get space
- * for msg
- */
- TEXT *getmids(UCOUNT apsize, MESSAGE *pmsg)
- {
- TEXT *retval;
- UCOUNT e, local;
- TEXT *p_str;
- char is_progparam[NAMESIZE];
- int proc_typ;
-
- if (ct_srv_use) { /* server or local use ? */
- strcpy(pipename, "\\\\");
- strcat(pipename, SRV_NETNAME);
- local = 0;
- }
- else {
- strcpy(pipename, "\0");
- local = 1;
- }
- strcat(pipename, ISAM_PIPENAME);
-
- uerr_cod = 0;
- msgsiz = apsize; /* local copy of msg len */
-
- cpybuf(is_progparam, ISAM_SRV_PARAMS, sizeof(ISAM_SRV_PARAMS));
- if (e = startusepipe(pipename,ISAM_SRV_PROGNAME,is_progparam,local)) {
- if (e != PIPE_STARTED_LOCAL) {
- uerr_cod = ASKY_ERR;
- return (NULL);
- }
- }
-
- /*
- * get application user name
- */
- if ((p_str = get_net_user_name()) != NULL)
- strcpy(usrname,p_str);
- else
- strcpy(usrname,USR_NETNAME);
-
- /* get application screen-group / process number,
- * only one user logged in at server per screen session
- *
- * Return type of process :
- * 0 = Full screen
- * 1 = Windowed appl
- * 2 = Background
- * 9 = Other
- */
- proc_typ = get_process_type();
- if (proc_typ == 0 || proc_typ == 1)
- sess_no = get_curr_screen_group(); /* Full screen */
- else {
- sess_no = get_process_id();
- if (proc_typ == 3)
- /* proc_id < max. screen groups */
- sess_no += 20000;
- }
- /* get space for message structure required by system */
- if ((retval = mballc(1,apsize)) == NULL) {
- disconnect();
- uerr_cod = ASPC_ERR;
- return (NULL);
- }
-
- /* application message id into mpntr member of message header */
- pmsg->mpntr = get_process_id();
-
- return (retval);
- }
-
- COUNT ridmids()
- {
- disconnect();
- return (0);
- }
-
- COUNT ctrqst(msgadr,pmsg)
- PFAST TEXT *msgadr; /* ptr to message area */
- MESSAGE *pmsg; /* ptr to message header */
- {
- unsigned msglen;
-
- /* copy message header */
- cpybuf(msgadr,pmsg,sizeof(MESSAGE));
-
- /* if TST_MSGSIZ (login), add machine name to
- * message (will be stripped off by ctsmsg)
- */
- if (pmsg->mfunc == TST_MSGSIZ ||
- pmsg->mfunc == TST_SPCLOG) {
- ((MESSAGE *) msgadr)->mdlen += (USR_NAME_LEN + sizeof(int) + 1);
- cpybuf(msgadr + sizeof(MESSAGE) + pmsg->mdlen,
- (char*)&sess_no, sizeof(int));
- cpybuf(msgadr + sizeof(MESSAGE) + pmsg->mdlen + sizeof(int),
- usrname, USR_NAME_LEN);
- *(msgadr + sizeof(MESSAGE) + pmsg->mdlen + 15) = 0;
- }
-
- msglen = sizeof(MESSAGE) + ((MESSAGE *) msgadr)->mdlen;
-
- /*
- * send and receive message (RPC-call)
- */
- if (!(msglen = dopipe(pipename, (char far*)msgadr, msglen,
- (char far*)msgadr))) {
- pmsg->merrn = uerr_cod = ARQS_ERR;
- return(uerr_cod);
- }
-
- /* update callers header buffer */
- cpybuf(pmsg, msgadr, sizeof(MESSAGE));
-
- return (NO_ERROR);
- }
-
- COUNT ctrspn(msgadr,pmsg)
- PFAST TEXT **msgadr;
- MESSAGE *pmsg;
- {
- return (NO_ERROR);
- }
-
-
- /*
- * hangup. if user hasn't logically logged off, server will clean up anyway
- */
- disconnect()
- {
- }
-
- /* end of ctamsg.c */
-