Added "generate headers only" command-line option. Implemented imports
[wine/multimedia.git] / server / smb.c
blob49127b0ccdb3c9e1acdd41810e73d86e758e8b9f
1 /*
2 * Server-side smb network file management
4 * Copyright (C) 1998 Alexandre Julliard
5 * Copyright (C) 2000, 2001, 2002 Mike McCormack
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * FIXME: if you can't find something to fix,
22 * you're not looking hard enough
25 #include "config.h"
27 #include <assert.h>
28 #include <fcntl.h>
29 #include <stdio.h>
30 #include <string.h>
31 #include <stdlib.h>
32 #include <errno.h>
33 #ifdef HAVE_SYS_ERRNO_H
34 #include <sys/errno.h>
35 #endif
36 #include <sys/time.h>
37 #include <sys/types.h>
38 #include <time.h>
39 #include <unistd.h>
40 #include <utime.h>
41 #include <termios.h>
42 #include <sys/ioctl.h>
44 #include "winerror.h"
45 #include "winbase.h"
47 #include "handle.h"
48 #include "thread.h"
49 #include "request.h"
51 static void smb_dump( struct object *obj, int verbose );
52 static int smb_get_fd( struct object *obj );
53 static int smb_get_info( struct object *obj, struct get_file_info_reply *reply, int *flags );
54 static int smb_get_poll_events( struct object *obj );
55 static void destroy_smb(struct object *obj);
57 struct smb
59 struct object obj;
60 unsigned int tree_id;
61 unsigned int user_id;
62 unsigned int dialect;
63 unsigned int file_id;
64 unsigned int offset;
67 static const struct object_ops smb_ops =
69 sizeof(struct smb), /* size */
70 smb_dump, /* dump */
71 default_poll_add_queue, /* add_queue */
72 default_poll_remove_queue, /* remove_queue */
73 default_poll_signaled, /* signaled */
74 no_satisfied, /* satisfied */
75 smb_get_poll_events, /* get_poll_events */
76 default_poll_event, /* poll_event */
77 smb_get_fd, /* get_fd */
78 no_flush, /* flush */
79 smb_get_info, /* get_file_info */
80 NULL, /* queue_async */
81 destroy_smb /* destroy */
84 static void destroy_smb( struct object *obj)
86 /* struct smb *smb = (struct smb *)obj; */
87 assert( obj->ops == &smb_ops );
90 static void smb_dump( struct object *obj, int verbose )
92 struct smb *smb = (struct smb *)obj;
93 assert( obj->ops == &smb_ops );
94 fprintf( stderr, "smb file with socket fd=%d \n", smb->obj.fd );
97 struct smb *get_smb_obj( struct process *process, obj_handle_t handle, unsigned int access )
99 return (struct smb *)get_handle_obj( process, handle, access, &smb_ops );
102 static int smb_get_poll_events( struct object *obj )
104 /* struct smb *smb = (struct smb *)obj; */
105 int events = 0;
106 assert( obj->ops == &smb_ops );
108 events |= POLLIN;
110 /* fprintf(stderr,"poll events are %04x\n",events); */
112 return events;
115 static int smb_get_fd( struct object *obj )
117 struct smb *smb = (struct smb *)obj;
118 assert( obj->ops == &smb_ops );
119 return smb->obj.fd;
122 static int smb_get_info( struct object *obj, struct get_file_info_reply *reply, int *flags )
124 /* struct smb *smb = (struct smb *) obj; */
125 assert( obj->ops == &smb_ops );
127 if (reply)
129 reply->type = FILE_TYPE_CHAR;
130 reply->attr = 0;
131 reply->access_time = 0;
132 reply->write_time = 0;
133 reply->size_high = 0;
134 reply->size_low = 0;
135 reply->links = 0;
136 reply->index_high = 0;
137 reply->index_low = 0;
138 reply->serial = 0;
141 *flags = 0;
143 return FD_TYPE_SMB;
146 /* create a smb */
147 DECL_HANDLER(create_smb)
149 struct smb *smb;
150 int fd;
152 reply->handle = 0;
154 fd = thread_get_inflight_fd( current, req->fd );
155 if (fd == -1)
157 set_error( STATUS_INVALID_HANDLE );
158 return;
161 smb = alloc_object( &smb_ops, fd );
162 if (smb)
164 smb->tree_id = req->tree_id;
165 smb->user_id = req->user_id;
166 smb->dialect = req->dialect;
167 smb->file_id = req->file_id;
168 smb->offset = 0;
169 reply->handle = alloc_handle( current->process, smb, GENERIC_READ, 0);
170 release_object( smb );
174 DECL_HANDLER(get_smb_info)
176 struct smb *smb;
178 if ((smb = get_smb_obj( current->process, req->handle, 0 )))
180 if(req->flags & SMBINFO_SET_OFFSET)
181 smb->offset = req->offset;
183 reply->tree_id = smb->tree_id;
184 reply->user_id = smb->user_id;
185 reply->dialect = smb->dialect;
186 reply->file_id = smb->file_id;
187 reply->offset = smb->offset;
189 release_object( smb );