summaryrefslogtreecommitdiffstats
path: root/private/utils/ntbackup/src/opensys.c
blob: c0c1bdc3213ad803f1d1231a874f03ddaf46178c (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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/**
Copyright(c) Maynard Electronics, Inc. 1984-89


	Name:		opensys.c

	Date Updated:	$./FDT$ $./FTM$

	Description:	This file contains the code to open and close a specified
        file system.  A file system must be opened prior to access.


	$Log:   J:/LOGFILES/OPENSYS.C_V  $

   Rev 1.15   26 Jul 1993 19:22:54   DON
When we close down the file system, added a call to free the os path or name queue!

   Rev 1.14   11 Nov 1992 09:52:34   GREGG
Unicodeized literals.

   Rev 1.13   10 Nov 1992 08:17:46   STEVEN
move os path and os name into common part of dblk

   Rev 1.12   25 Sep 1992 16:22:22   CARLS
Fixed error in last edit. [Barry]

   Rev 1.11   25 Sep 1992 13:18:26   BARRY
Removed references to FS_SIZEOF_NAMELESS_STREAM_HEAD.

   Rev 1.10   01 Sep 1992 11:44:20   TIMN
Fixed typo for BINT16

   Rev 1.9   18 Aug 1992 10:26:48   STEVEN
fix warnings

   Rev 1.8   23 Jul 1992 12:41:06   STEVEN
fix warning

   Rev 1.7   09 Jul 1992 13:58:30   STEVEN
BE_Unicode updates

   Rev 1.6   21 May 1992 13:58:10   STEVEN
added more long path stuff

   Rev 1.5   16 Mar 1992 10:06:56   LORIB
Added InitQueue() for path_q.

   Rev 1.4   01 Oct 1991 11:15:48   BARRY
Include standard headers.

   Rev 1.3   06 Aug 1991 18:30:24   DON
added NLM File System support

   Rev 1.2   25 Jun 1991 09:34:54   BARRY
Changes for new config.

   Rev 1.1   03 Jun 1991 13:27:04   BARRY
Remove product defines from conditional compilation.

   Rev 1.0   09 May 1991 13:38:26   HUNTER
Initial revision.

**/
/* begin include list */
#include <stdlib.h>
#include <std_err.h>

#include "stdtypes.h"
#include "msassert.h"

#include "beconfig.h"
#include "fsys.h"
#include "fsys_prv.h"
/* $end$ include list */

/**/
/**

	Name:		FS_OpenFileSys()

	Description:	This function is called to get a file system handle.
     The handle is required for all subsequent calls to the file system.
     This routine allocates all resources necessary to support the
     particular file system.  The valid file system types are:
          LOCAL_IMAGE
          LOCAL_DOS_DRV
          REMOTE_DOS_DRV
          NOVELL_DRV
          NOVELL_AFP_DRV
          IBM_PC_LAN_DRV

	Modified:		7/14/1989

	Returns:		Error codes:
          UNDEFINED_TYPE
          OUT_OF_MEMORY
          SUCCESS


	Notes:		

	See also:		$/SEE( FS_AttachDLE(), FS_CloseFileSys() )$

	Declaration:

**/
/* begin declaration */
INT16 FS_OpenFileSys( 
FSYS_HAND   *fsh,       /* O - Created file system handle */
INT16       type,       /* I - File system type           */
BE_CFG_PTR  cfg )       /* I - configuration structure    */
{
     if ( type >= MAX_DRV_TYPES ) {
          return ( FS_UNDEFINED_TYPE ) ;
     }

     *fsh = (FSYS_HAND)calloc( 1, sizeof( struct FSYS_HAND_STRUCT ) ) ;

     if( *fsh != NULL ) {

          (*fsh)->stream_ptr      = NULL;
          (*fsh)->stream_buf_size = 0;

          (*fsh)->cur_dir = calloc( 1, CUR_DIR_CHUNK ) ;

          if ( (*fsh)->cur_dir == NULL ) {
               free( (*fsh)->stream_ptr ) ;
               free( *fsh ) ;
          } else {

               #if ( defined(FS_AFP) && defined(FS_NONAFP) )
                    if ( ( type == NOVELL_AFP_DRV ) && !BEC_GetAFPSupport( cfg ) ) {
                         type = NOVELL_DRV ;
                    }
               #endif

               #if ( defined(FS_NLMAFP) && defined(FS_NLMNOV) )
                    if ( ( type == NLM_AFP_VOLUME ) && !BEC_GetAFPSupport( cfg ) ) {
                         type = NLM_VOLUME ;
                    }
               #endif

               (*fsh)->f_type   = type ;
               (*fsh)->tab_ptr  = &(func_tab[type]) ;
               (*fsh)->leng_dir = CUR_DIR_CHUNK ;
               (*fsh)->cfg      = cfg;

               InitQueue( &((*fsh)->min_ddb_stk) ) ;

               InitQueue( &((*fsh)->in_use_name_q) ) ;
 
               InitQueue( &((*fsh)->avail_name_q) ) ;

               return ( SUCCESS ) ;
          }
     }
     return ( OUT_OF_MEMORY ) ;
}

/**/
/**

	Name:		FS_ReOpenFileSys()

	Description:	This function is called to modify a file system handle.
     The previously opened file system is closed and the memory for the old
     handle is reused for the new file system. This routine allocates all
     resources necessary to support the particular file system.  The valid
     file system types are:
          LOCAL_IMAGE
          LOCAL_DOS_DRV
          REMOTE_DOS_DRV
          NOVELL_DRV
          NOVELL_AFP_DRV
          IBM_PC_LAN_DRV

	Modified:		7/14/1989

	Returns:		Error codes:
          UNDEFINED_TYPE
          OUT_OF_MEMORY
          SUCCESS


	Notes:		

	See also:		$/SEE( FS_AttachDLE(), FS_CloseFileSys() )$

	Declaration:

**/
/* begin declaration */
INT16 FS_ReOpenFileSys( 
FSYS_HAND   fsh,        /* O - Modified file system handle */
INT16       type,       /* I - File system type            */
BE_CFG_PTR  cfg )        /* I - configuration structure     */
{
     if ( type < MAX_DRV_TYPES ) {
          return ( FS_UNDEFINED_TYPE ) ;
     }

     msassert( fsh != NULL ) ;

     if ( fsh->attached_dle != NULL ) {
          FS_DetachDLE( fsh )  ;
     }

     fsh->f_type     = type ;
     fsh->tab_ptr    = &(func_tab[type]) ;
     fsh->cur_dir[0] = TEXT('\0') ;
     fsh->cfg        = cfg;

     InitQueue( &(fsh->min_ddb_stk) ) ;

     InitQueue( &(fsh->in_use_name_q) ) ;

     InitQueue( &(fsh->avail_name_q) ) ;

     return ( SUCCESS ) ;
}


/**/
/**

	Name:		FS_CloseFileSys()

	Description:	This releases any memory allocated by the FS_OpenFileSys()
     function.  It will also release any memory leftover from FS_PushDir()


	Modified:		7/14/1989

	Returns:		Error codes:
          FS_NOT_OPEN
          SUCCESS

	Notes:		

	See also:		$/SEE( FS_OpenFileSys( ), FS_PushDir( ) )$

	Declaration:

**/
/* begin declaration */
INT16 FS_CloseFileSys( fsh )
FSYS_HAND fsh ;
{
     if ( fsh != NULL ) {

          /* Release any unreleased resources in the name queue */
          FS_FreeOSPathOrNameQueueInHand( fsh );

          if ( fsh->attached_dle != NULL ) {
               FS_DetachDLE( fsh )  ;
          }

          free( fsh->cur_dir ) ;
          free( fsh->stream_ptr ) ;
          free( fsh ) ;

          return ( SUCCESS ) ;
     } else {

          return ( FS_NOT_OPEN );

     }
}

UINT16 FS_GetStringTypes( FSYS_HAND fsh )
{
     return BEC_GetStringTypes( fsh->cfg ) ;
}