win95-initial-port-20010430
[openafs.git] / src / WINNT / afsd / netbios95.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /* Netbios function for DJGPP: calls interrupt 5Ch for Netbios function.
11    NCB and buffer space must be in DOS memory (below 1MB). */
12
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <dpmi.h>
16 #include <go32.h>
17 #include "dosdefs95.h"
18 #include "netbios95.h"
19
20 extern int handler_seg, handler_off;
21
22 int Netbios(NCB *Ncb, dos_ptr dos_ncb)
23 {
24   __dpmi_regs regs;
25   int asynch = 1;
26   dos_ptr oldncb_buffer;
27
28 #if 1
29   if (Ncb->ncb_command == NCBRESET ||
30       Ncb->ncb_command == NCBCANCEL ||
31       Ncb->ncb_command == NCBUNLINK ||
32       Ncb->ncb_command == NCBADDNAME ||
33       Ncb->ncb_command == NCBENUM ||
34       Ncb->ncb_command == NCBDELNAME) /* temp */
35     asynch = 0;
36 #else
37   if (1)
38     asynch = 0;
39 #endif
40   else
41     /* set to asynchronous */
42     Ncb->ncb_command |= ASYNCH;
43
44   /* adjust ncb_buffer pointer to be a segment:zero-offset pointer
45      for __dpmi_int */
46   oldncb_buffer = Ncb->ncb_buffer;
47   Ncb->ncb_buffer = Ncb->ncb_buffer << 12;
48
49   /*if (asynch)
50     Ncb->ncb_post = (handler_seg << 16) | handler_off;*/
51
52   /* copy to DOS space */
53   dosmemput(Ncb, sizeof(NCB), dos_ncb);
54
55   /* set address of NCB in registers */
56   memset(&regs, 0, sizeof(regs));
57   regs.d.ebx = 0;
58   regs.x.ds = regs.x.es = dos_ncb/16;
59
60   __dpmi_int(0x5c,&regs);
61   /*dosmemget(__tb, sizeof(NCB), Ncb);*/
62   
63   if (asynch)
64     IOMGR_NCBSelect(Ncb, dos_ncb, NULL);
65
66   /* undo the change to ncb_buffer */
67   Ncb->ncb_buffer = oldncb_buffer;
68
69   return regs.x.ax;
70 }
71