Lines Matching refs:f
81 void (*_fh_init) ( FH f );
82 int (*_fh_close)( FH f );
83 int (*_fh_lseek)( FH f, int pos, int origin );
84 int (*_fh_read) ( FH f, void* buf, int len );
85 int (*_fh_write)( FH f, const void* buf, int len );
86 void (*_fh_hook) ( FH f, int events, EventHook hook );
126 FH f; in _fh_from_int() local
136 f = &_win32_fhs[fd]; in _fh_from_int()
138 if (f->used == 0) { in _fh_from_int()
144 return f; in _fh_from_int()
149 _fh_to_int( FH f ) in _fh_to_int() argument
151 if (f && f->used && f >= _win32_fhs && f < _win32_fhs + WIN32_MAX_FHS) in _fh_to_int()
152 return (int)(f - _win32_fhs) + WIN32_FH_BASE; in _fh_to_int()
161 FH f = NULL; in _fh_alloc() local
166 f = &_win32_fhs[ _win32_fh_count++ ]; in _fh_alloc()
172 f = &_win32_fhs[nn]; in _fh_alloc()
178 if (f) { in _fh_alloc()
179 f->clazz = clazz; in _fh_alloc()
180 f->used = 1; in _fh_alloc()
181 f->eof = 0; in _fh_alloc()
182 clazz->_fh_init(f); in _fh_alloc()
185 return f; in _fh_alloc()
190 _fh_close( FH f ) in _fh_close() argument
192 if ( f->used ) { in _fh_close()
193 f->clazz->_fh_close( f ); in _fh_close()
194 f->used = 0; in _fh_close()
195 f->eof = 0; in _fh_close()
196 f->clazz = NULL; in _fh_close()
214 _fh_file_init( FH f ) in _fh_file_init() argument
216 f->fh_handle = INVALID_HANDLE_VALUE; in _fh_file_init()
220 _fh_file_close( FH f ) in _fh_file_close() argument
222 CloseHandle( f->fh_handle ); in _fh_file_close()
223 f->fh_handle = INVALID_HANDLE_VALUE; in _fh_file_close()
228 _fh_file_read( FH f, void* buf, int len ) in _fh_file_read() argument
232 if ( !ReadFile( f->fh_handle, buf, (DWORD)len, &read_bytes, NULL ) ) { in _fh_file_read()
233 D( "adb_read: could not read %d bytes from %s\n", len, f->name ); in _fh_file_read()
237 f->eof = 1; in _fh_file_read()
243 _fh_file_write( FH f, const void* buf, int len ) in _fh_file_write() argument
247 if ( !WriteFile( f->fh_handle, buf, (DWORD)len, &wrote_bytes, NULL ) ) { in _fh_file_write()
248 D( "adb_file_write: could not write %d bytes from %s\n", len, f->name ); in _fh_file_write()
252 f->eof = 1; in _fh_file_write()
258 _fh_file_lseek( FH f, int pos, int origin ) in _fh_file_lseek() argument
273 result = SetFilePointer( f->fh_handle, pos, NULL, method ); in _fh_file_lseek()
278 f->eof = 0; in _fh_file_lseek()
283 static void _fh_file_hook( FH f, int event, EventHook eventhook ); /* forward */
305 FH f; in adb_open() local
326 f = _fh_alloc( &_fh_file_class ); in adb_open()
327 if ( !f ) { in adb_open()
332 f->fh_handle = CreateFile( path, desiredAccess, shareMode, NULL, OPEN_EXISTING, in adb_open()
335 if ( f->fh_handle == INVALID_HANDLE_VALUE ) { in adb_open()
336 _fh_close(f); in adb_open()
356 snprintf( f->name, sizeof(f->name), "%d(%s)", _fh_to_int(f), path ); in adb_open()
357 D( "adb_open: '%s' => fd %d\n", path, _fh_to_int(f) ); in adb_open()
358 return _fh_to_int(f); in adb_open()
364 FH f; in adb_creat() local
366 f = _fh_alloc( &_fh_file_class ); in adb_creat()
367 if ( !f ) { in adb_creat()
372 f->fh_handle = CreateFile( path, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, in adb_creat()
376 if ( f->fh_handle == INVALID_HANDLE_VALUE ) { in adb_creat()
377 _fh_close(f); in adb_creat()
396 snprintf( f->name, sizeof(f->name), "%d(%s)", _fh_to_int(f), path ); in adb_creat()
397 D( "adb_creat: '%s' => fd %d\n", path, _fh_to_int(f) ); in adb_creat()
398 return _fh_to_int(f); in adb_creat()
404 FH f = _fh_from_int(fd); in adb_read() local
406 if (f == NULL) { in adb_read()
410 return f->clazz->_fh_read( f, buf, len ); in adb_read()
416 FH f = _fh_from_int(fd); in adb_write() local
418 if (f == NULL) { in adb_write()
422 return f->clazz->_fh_write(f, buf, len); in adb_write()
428 FH f = _fh_from_int(fd); in adb_lseek() local
430 if (!f) { in adb_lseek()
434 return f->clazz->_fh_lseek(f, pos, where); in adb_lseek()
440 FH f = _fh_from_int(fd); in adb_shutdown() local
442 if (!f) { in adb_shutdown()
446 D( "adb_shutdown: %s\n", f->name); in adb_shutdown()
447 shutdown( f->fh_socket, SD_BOTH ); in adb_shutdown()
454 FH f = _fh_from_int(fd); in adb_close() local
456 if (!f) { in adb_close()
460 D( "adb_close: %s\n", f->name); in adb_close()
461 _fh_close(f); in adb_close()
487 _fh_socket_init( FH f ) in _fh_socket_init() argument
489 f->fh_socket = INVALID_SOCKET; in _fh_socket_init()
490 f->event = WSACreateEvent(); in _fh_socket_init()
491 f->mask = 0; in _fh_socket_init()
495 _fh_socket_close( FH f ) in _fh_socket_close() argument
498 shutdown( f->fh_socket, SD_BOTH ); in _fh_socket_close()
499 closesocket( f->fh_socket ); in _fh_socket_close()
500 f->fh_socket = INVALID_SOCKET; in _fh_socket_close()
501 CloseHandle( f->event ); in _fh_socket_close()
502 f->mask = 0; in _fh_socket_close()
507 _fh_socket_lseek( FH f, int pos, int origin ) in _fh_socket_lseek() argument
514 _fh_socket_read( FH f, void* buf, int len ) in _fh_socket_read() argument
516 int result = recv( f->fh_socket, buf, len, 0 ); in _fh_socket_read()
525 _fh_socket_write( FH f, const void* buf, int len ) in _fh_socket_write() argument
527 int result = send( f->fh_socket, buf, len, 0 ); in _fh_socket_write()
535 static void _fh_socket_hook( FH f, int event, EventHook hook ); /* forward */
581 FH f = _fh_alloc( &_fh_socket_class ); in socket_loopback_client() local
585 if (!f) in socket_loopback_client()
599 _fh_close(f); in socket_loopback_client()
603 f->fh_socket = s; in socket_loopback_client()
606 _fh_close(f); in socket_loopback_client()
609 …snprintf( f->name, sizeof(f->name), "%d(lo-client:%s%d)", _fh_to_int(f), type != SOCK_STREAM ? "ud… in socket_loopback_client()
610 …ck_client: port %d type %s => fd %d\n", port, type != SOCK_STREAM ? "udp" : "tcp", _fh_to_int(f) ); in socket_loopback_client()
611 return _fh_to_int(f); in socket_loopback_client()
618 FH f = _fh_alloc( &_fh_socket_class ); in socket_loopback_server() local
623 if (!f) { in socket_loopback_server()
638 f->fh_socket = s; in socket_loopback_server()
644 _fh_close(f); in socket_loopback_server()
652 _fh_close(f); in socket_loopback_server()
656 …snprintf( f->name, sizeof(f->name), "%d(lo-server:%s%d)", _fh_to_int(f), type != SOCK_STREAM ? "ud… in socket_loopback_server()
657 …ck_server: port %d type %s => fd %d\n", port, type != SOCK_STREAM ? "udp" : "tcp", _fh_to_int(f) ); in socket_loopback_server()
658 return _fh_to_int(f); in socket_loopback_server()
664 FH f = _fh_alloc( &_fh_socket_class ); in socket_network_client() local
669 if (!f) in socket_network_client()
677 _fh_close(f); in socket_network_client()
688 _fh_close(f); in socket_network_client()
691 f->fh_socket = s; in socket_network_client()
694 _fh_close(f); in socket_network_client()
698 …snprintf( f->name, sizeof(f->name), "%d(net-client:%s%d)", _fh_to_int(f), type != SOCK_STREAM ? "u… in socket_network_client()
699 …'%s' port %d type %s => fd %d\n", host, port, type != SOCK_STREAM ? "udp" : "tcp", _fh_to_int(f) ); in socket_network_client()
700 return _fh_to_int(f); in socket_network_client()
706 FH f = _fh_alloc( &_fh_socket_class ); in socket_inaddr_any_server() local
711 if (!f) in socket_inaddr_any_server()
724 _fh_close(f); in socket_inaddr_any_server()
728 f->fh_socket = s; in socket_inaddr_any_server()
733 _fh_close(f); in socket_inaddr_any_server()
742 _fh_close(f); in socket_inaddr_any_server()
746 …snprintf( f->name, sizeof(f->name), "%d(any-server:%s%d)", _fh_to_int(f), type != SOCK_STREAM ? "u… in socket_inaddr_any_server()
747 …dr_server: port %d type %s => fd %d\n", port, type != SOCK_STREAM ? "udp" : "tcp", _fh_to_int(f) ); in socket_inaddr_any_server()
748 return _fh_to_int(f); in socket_inaddr_any_server()
1106 void _fh_socketpair_init( FH f ) in _fh_socketpair_init() argument
1108 f->fh_pair = NULL; in _fh_socketpair_init()
1112 _fh_socketpair_close( FH f ) in _fh_socketpair_close() argument
1114 if ( f->fh_pair ) { in _fh_socketpair_close()
1115 SocketPair pair = f->fh_pair; in _fh_socketpair_close()
1117 if ( f == pair->a_fd ) { in _fh_socketpair_close()
1129 f->fh_pair = NULL; in _fh_socketpair_close()
1135 _fh_socketpair_lseek( FH f, int pos, int origin ) in _fh_socketpair_lseek() argument
1142 _fh_socketpair_read( FH f, void* buf, int len ) in _fh_socketpair_read() argument
1144 SocketPair pair = f->fh_pair; in _fh_socketpair_read()
1150 if ( f == pair->a_fd ) in _fh_socketpair_read()
1159 _fh_socketpair_write( FH f, const void* buf, int len ) in _fh_socketpair_write() argument
1161 SocketPair pair = f->fh_pair; in _fh_socketpair_write()
1167 if ( f == pair->a_fd ) in _fh_socketpair_write()
1176 static void _fh_socketpair_hook( FH f, int event, EventHook hook ); /* forward */
1338 FH f = hook->fh; in event_hook_signal() local
1339 int fd = _fh_to_int(f); in event_hook_signal()
1379 FH f = _fh_from_int(fd); in event_looper_hook() local
1383 if (f == NULL) /* invalid arg */ { in event_looper_hook()
1388 pnode = event_looper_find_p( looper, f ); in event_looper_hook()
1391 node = event_hook_alloc( f ); in event_looper_hook()
1400 f->clazz->_fh_hook( f, events & ~node->wanted, node ); in event_looper_hook()
1952 static void _fh_file_hook( FH f, int events, EventHook hook ) in _fh_file_hook() argument
1954 hook->h = f->fh_handle; in _fh_file_hook()
2071 static void _fh_socket_hook( FH f, int events, EventHook hook ) in _fh_socket_hook() argument