home *** CD-ROM | disk | FTP | other *** search
- /*
- * OS/2 Lan Manager using named pipes version of c-tree server
- *
- * 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
- *
- */
-
- #define INCL_DOS
- #define INCL_DOSERRORS
- #include <os2def.h> /* Common definitions */
- #include <bsedos.h> /* Base definitions */
- #include <bseerr.h> /* Base error code definitions */
-
- #include <net\netcons.h>
- #ifndef INCL_DOSNMPIPES /* This define i set if MS SDK 1.06 include files */
- #include <net\nmpipe.h>
- #endif
-
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <malloc.h>
-
- #include "ctpipes.h"
-
- /*
- * Receive buffer for call DosTransactNmPipe
- * in and out buffer could not be the same ??????!!!!!!?????
- */
-
- unsigned pipe_errcode;
-
- unsigned makepipe(unsigned *handle, char *pipename)
- {
- pipe_errcode = DosMakeNmPipe(pipename, handle,
- SRV_DOSOPENMODE, SRV_PIPOPENMODE,
- PIPESIZE, PIPESIZE, PIPE_TIMEOUT);
- return(pipe_errcode);
- }
-
- unsigned sendlogonreply(unsigned handle)
- {
- long yes_i_am = PIPE_ANSW;
-
- writepipe(handle, (char far *)&yes_i_am, sizeof(long));
-
- return(pipe_errcode);
- }
-
- unsigned readpipe(unsigned handle, char far *buffer)
- {
- USHORT bytes;
-
- /*
- * we will now hang on ConnectNmPipe until something to do
- */
- /* here we should implemet set to non-blocking mode
- to se if any request is made, else sleep.
- We could also implement several handles for many instances of
- pipes to be opened */
- if (!(pipe_errcode = DosConnectNmPipe(handle)) ) {
- pipe_errcode = DosRead((HFILE)handle, buffer, (unsigned)PIPESIZE, &bytes);
- }
-
- return(pipe_errcode ? 0 : bytes);
- }
-
-
- unsigned writepipe(unsigned handle, char far *buffer, unsigned len)
- {
- USHORT bytes;
- char dummy[4];
- unsigned short rbytes, avail, status;
-
- if (!(pipe_errcode = DosWrite((HFILE)handle, buffer, len, &bytes))) {
- for (;;) {
- rbytes = 0;
- avail = 0;
- if ((pipe_errcode = DosPeekNmPipe(handle, dummy, 0, &rbytes,
- &avail, &status))) {
- break;
- }
-
- if (status == NP_CLOSING)
- break;
-
- DosSleep(10L);
-
- }
- pipe_errcode = DosDisConnectNmPipe(handle);
- }
-
- return(pipe_errcode ? 0 : bytes);
- }
-
- unsigned disconnect_pipe(unsigned handle)
- {
- pipe_errcode = DosClose(handle);
- return(pipe_errcode);
- }
-
- /*
- * This function is used to try to set Server application
- * to a higer priority level than the application(and other)
- * for faster performance.
- * I have not succeded in doing this, becuase a background process
- * always get less priority than the foreground procces.
- * At time-critical level the server will not recive request
- * from the server.
- * Temporarly we then use this fuction as a DUMMY.
- */
- void set_exec_priority(int max_min) /* 0 = min, 1 = max */
- {
- USHORT id; /* process or thread identifier */
- USHORT retval;
- static short first = 0;
- USHORT prio;
- static int pri_class;
- static int pri_level;
-
- static SHORT pr_max = 15, pr_min = -31, pr_class = 5;
-
- return;
-
- id = get_process_id();
-
- if (!first) {
- retval = DosGetPrty(PRTYS_PROCESS, &prio, id);
- pri_class = HIBYTE(prio);
- pri_level = LOBYTE(prio);
- first++;
- }
- if (max_min) {
- retval = DosSetPrty(PRTYS_PROCESS, PRTYC_TIMECRITICAL, pr_max, id);
- }
- else
- /* set back to normal */
- retval = DosSetPrty(PRTYS_PROCESS, pri_class, pri_level, id);
-
- }
-
-
-