summaryrefslogtreecommitdiffstats
path: root/private/nw/nwscript/ntnw.c
blob: 00cf540573689d229aa0fb31ec54d3797f2be646 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*************************************************************************
*
*  NTNW.C
*
*  Dos NetWare to NT NetWare translation 
*
*  Copyright (c) 1995 Microsoft Corporation
*
*  $Log:   N:\NT\PRIVATE\NW4\NWSCRIPT\VCS\NTNW.C  $
*  
*     Rev 1.1   22 Dec 1995 14:25:28   terryt
*  Add Microsoft headers
*  
*     Rev 1.0   15 Nov 1995 18:07:24   terryt
*  Initial revision.
*  
*     Rev 1.2   25 Aug 1995 16:23:08   terryt
*  Capture support
*  
*     Rev 1.1   23 May 1995 19:37:10   terryt
*  Spruce up source
*  
*     Rev 1.0   15 May 1995 19:10:44   terryt
*  Initial revision.
*  
*************************************************************************/

#include <stdio.h>
#include <direct.h>
#include <time.h>
#include "common.h"

extern int CONNECTION_ID;

/********************************************************************

        NTGetCurrentDirectory

Routine Description:

        Return the current directory.

Arguments:

        DriveNumber = The drive to get the directory from.
                        (0 = A, 1 = B, 2 = C, etc)
        pPath = A pointer to a 64 byte buffer to return the
                    current directory.

Return Value:

        0       Success
        else    Error

 ********************************************************************/

unsigned int
NTGetCurrentDirectory(
    unsigned char DriveNumber,
    unsigned char *pPath
    )
{
    char * CurPath;
    int currentDrive = _getdrive() ;

    //
    // Change to the drive and get its current working directory.
    // Default to root if fail to get cwd. DriveNumber is from 0.
    //

    _chdrive (DriveNumber+1);

    CurPath = _getcwd(NULL,MAX_PATH) ;

    if ( CurPath != NULL ) {
        
        strcpy( pPath, CurPath );
        free(CurPath) ;
    }
    else {

        strcpy( pPath, "A:\\" );
        pPath[0] += DriveNumber;
    }

    _chdrive (currentDrive);

    return 0;
}

/********************************************************************

        AttachToFileServer

Routine Description:

        Attach to a named file server

Arguments:

        pServerName      - Name of server
        pNewConnectionId - returned connection handle 

Return Value:
        0 = success
        else NetWare error

 *******************************************************************/
unsigned int
AttachToFileServer(
    unsigned char     *pServerName,
    unsigned int      *pNewConnectionId
    )
{
    unsigned int Result;

    if ( NTIsConnected( pServerName ) ) {
        return 0x8800;  // Already atached.
    }

    Result = NTAttachToFileServer( pServerName, pNewConnectionId );

    return Result;
}

/********************************************************************

        GetConnectionHandle

Routine Description:

        Given a server name, return the connection handle.
        The server should already be attached
        Note that this is not called for 4X servers.  It's used
        for attaches and bindery connections.

Arguments:

        pServerName       - Name of server
        pConnectionHandle - pointer to returned connection handle 

Return Value:
        0 = success
        else NetWare error

 *******************************************************************/
unsigned int
GetConnectionHandle(
    unsigned char *pServerName,
    unsigned int  *pConnectionHandle
    )
{
    unsigned int Result;

    if ( !NTIsConnected( pServerName ) ) {
        return 0xFFFF;  // not already connected
    }

    Result = NTAttachToFileServer( pServerName, pConnectionHandle );

    return Result;
}