home *** CD-ROM | disk | FTP | other *** search
- /*
- * OS/2 Lan Manager DOS Api calls for
- * 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 <stdlib.h>
- #include <stdio.h>
- #include <string.h>
-
- #include "ctpipes.h"
-
- static void get_info_seg_pointers(void);
-
- int fl_backgr_proc = 0;
-
- int fl_infoseg_init = 0;
- static GINFOSEG FAR *pgs = 0L;
- static LINFOSEG FAR *pls = 0L;
-
-
- void set_max_file_handles(int maxfh)
- {
- int i;
-
- i = DosSetMaxFH(maxfh);
- /* if (i)
- printf("SetMaxFH ERROR %d", i); */
- }
-
-
- static void get_info_seg_pointers()
- {
- SEL selGlobalSeg, selLocalSeg;
-
- if (fl_infoseg_init)
- return;
- DosGetInfoSeg(&selGlobalSeg, &selLocalSeg);
- pgs = MAKEPGINFOSEG(selGlobalSeg);
- pls = MAKEPLINFOSEG(selLocalSeg);
- fl_infoseg_init = 1;
- }
-
-
- int get_process_id()
- {
- if (!fl_infoseg_init)
- get_info_seg_pointers();
-
- return(pls->pidCurrent); /* return identifier of the current process.*/
- }
-
-
- /*
- * Return type of process :
- * 0 = Full screen
- * 1 = Windowed appl
- * 2 = Background
- * 3 = Background OS2 1.0 (proc_id < max. screen groups)
- * 9 = Other
- */
- int get_process_type()
- {
- int proc_type = 0;
-
- if (!fl_infoseg_init)
- get_info_seg_pointers();
-
- /*
- * Process Type codes (local info seg typeProcess field)
- * ONLY functionating in OS/2 1.1 (IBM EXTENDED EDITION)
- *
- * for OS/2 1.0 Process Type is always = 0 (PT_FULLSCREEN)
- *
- *
- * Process Type codes (local info seg typeProcess field)
- * #define PT_FULLSCREEN 0 Full screen app.
- * #define PT_REALMODE 1 Real mode process
- * #define PT_WINDOWABLEVIO 2 VIO windowable app.
- * #define PT_PM 3 Presentation Manager app.
- * #define PT_DETACHED 4 Detached app.
- */
- switch (pls->typeProcess) {
- case PT_DETACHED: /* Detached app. */
- fl_backgr_proc = 1;
- proc_type = 2;
- if (pls->pidCurrent < pgs->sgMax)
- /* proc_id < max. screen groups */
- proc_type = 3;
- break;
- case PT_FULLSCREEN: /* Full screen app. */
- fl_backgr_proc = 0;
- proc_type = 0;
- /* if current screen group == maximum number of screen groups,
- * then background process. NB! test ONLY valid for OS/2 1.0
- */
- if (pls->sgCurrent == pgs->sgMax) {
- fl_backgr_proc = 1;
- proc_type = 2;
- if (pls->pidCurrent < pgs->sgMax)
- /* proc_id < max. screen groups */
- proc_type = 3;
- }
- break;
- case PT_WINDOWABLEVIO: /* VIO windowable app. */
- fl_backgr_proc = 0;
- proc_type = 1;
- break;
- case PT_REALMODE: /* Real mode process */
- case PT_PM: /* Presentation Manager app. */
- default:
- fl_backgr_proc = 0;
- proc_type = 9;
- break;
- }
-
- return(proc_type); /* return process type */
- }
-
-
- int get_curr_screen_group()
- {
-
- if (!fl_infoseg_init)
- get_info_seg_pointers();
-
- return(pls->sgCurrent); /* return current screen group */
-
- }
-
- /*
- * Return type of OS/2 operating system:
- * 0 = OS/2 1.0 med 3Com Named Pipes
- * 1 = OS/2 1.1 Standard or Extended Edition
- * 9 = newer versions not supported
- */
- int get_os2_version()
- {
- USHORT versj = 0;
- unsigned major, minor;
-
- if (DosGetVersion(&versj))
- return 9;
- major = ((versj & 0xff00) >> 8);
- minor = (versj & 0x00ff);
- if (major > 10)
- return 9;
- if (major == 10 && minor >= 10)
- return 1;
- return 0;
- }
-
-
- /*
- * Copy of memory blocks from different segments
- *
- * The stfarmov function copies a number of bytes from the first
- * string into the second string's allocated space.
- * returns number of bytes copied.
- *
- * NOTE: destination must have allocated
- * at least n number of bytes
- *
- */
- unsigned stfarmov(char far *src, char far *dest, unsigned n)
- {
- unsigned count = 0;
-
- if (n) {
- while (n-- > 0) {
- *dest++ = *src++;
- count++;
- }
- }
- else
- /*
- * No number of bytes specified copy unit NULL character
- */
- while (*src) {
- *dest++ = *src++;
- count++;
- }
-
- return count;
-
- } /* end stfarmov */
-
-