00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef VLC_COMMON_H
00033 # define VLC_COMMON_H 1
00034
00035
00036
00037
00038 #if defined( _MSC_VER )
00039 # pragma warning( disable : 4244 )
00040 #endif
00041
00042 #include "vlc_config.h"
00043
00044
00045
00046
00047 #include <stdlib.h>
00048 #include <stdarg.h>
00049
00050 #include <string.h>
00051 #include <stdio.h>
00052 #include <inttypes.h>
00053
00054 #ifndef __cplusplus
00055 # include <stdbool.h>
00056 #endif
00057
00058
00059
00060
00061 #if defined( WIN32 ) || defined( UNDER_CE )
00062 # include <malloc.h>
00063 # ifndef PATH_MAX
00064 # define PATH_MAX MAX_PATH
00065 # endif
00066 #endif
00067
00068
00069 typedef unsigned long count_t;
00070
00071
00072 typedef uint16_t audio_volume_t;
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 typedef int64_t mtime_t;
00085
00086
00087
00088
00089
00090
00091 typedef uint32_t vlc_fourcc_t;
00092
00093 #ifdef WORDS_BIGENDIAN
00094 # define VLC_FOURCC( a, b, c, d ) \
00095 ( ((uint32_t)d) | ( ((uint32_t)c) << 8 ) \
00096 | ( ((uint32_t)b) << 16 ) | ( ((uint32_t)a) << 24 ) )
00097 # define VLC_TWOCC( a, b ) \
00098 ( (uint16_t)(b) | ( (uint16_t)(a) << 8 ) )
00099
00100 #else
00101 # define VLC_FOURCC( a, b, c, d ) \
00102 ( ((uint32_t)a) | ( ((uint32_t)b) << 8 ) \
00103 | ( ((uint32_t)c) << 16 ) | ( ((uint32_t)d) << 24 ) )
00104 # define VLC_TWOCC( a, b ) \
00105 ( (uint16_t)(a) | ( (uint16_t)(b) << 8 ) )
00106
00107 #endif
00108
00109 static inline void __vlc_fourcc_to_char( vlc_fourcc_t fcc, char *psz_fourcc )
00110 {
00111 memcpy( psz_fourcc, &fcc, 4 );
00112 }
00113
00114 #define vlc_fourcc_to_char( a, b ) \
00115 __vlc_fourcc_to_char( (vlc_fourcc_t)(a), (char *)(b) )
00116
00117
00118
00119
00120
00121
00122 typedef struct vlc_list_t vlc_list_t;
00123 typedef struct vlc_object_t vlc_object_t;
00124 typedef struct libvlc_int_t libvlc_int_t;
00125 typedef struct variable_t variable_t;
00126 typedef struct date_t date_t;
00127 typedef struct dict_entry_t dict_entry_t;
00128 typedef struct dict_t dict_t;
00129 typedef struct gc_object_t gc_object_t ;
00130
00131
00132 typedef struct msg_subscription_t msg_subscription_t;
00133
00134
00135
00136
00137
00138
00139
00140 typedef enum {
00141 PLAYLIST_PLAY,
00142 PLAYLIST_VIEWPLAY,
00143
00144 PLAYLIST_PAUSE,
00145 PLAYLIST_STOP,
00146 PLAYLIST_SKIP,
00147 } playlist_command_t;
00148
00149
00150 typedef struct playlist_t playlist_t;
00151 typedef struct playlist_item_t playlist_item_t;
00152 typedef struct playlist_view_t playlist_view_t;
00153 typedef struct playlist_export_t playlist_export_t;
00154 typedef struct services_discovery_t services_discovery_t;
00155 typedef struct services_discovery_sys_t services_discovery_sys_t;
00156 typedef struct playlist_add_t playlist_add_t;
00157 typedef struct playlist_preparse_t playlist_preparse_t;
00158 typedef struct playlist_fetcher_t playlist_fetcher_t;
00159
00160
00161 typedef struct module_bank_t module_bank_t;
00162 typedef struct module_t module_t;
00163 typedef struct module_config_t module_config_t;
00164 typedef struct module_symbols_t module_symbols_t;
00165 typedef struct module_cache_t module_cache_t;
00166
00167 typedef struct config_category_t config_category_t;
00168
00169
00170 typedef struct intf_thread_t intf_thread_t;
00171 typedef struct intf_sys_t intf_sys_t;
00172 typedef struct intf_console_t intf_console_t;
00173 typedef struct intf_msg_t intf_msg_t;
00174 typedef struct interaction_t interaction_t;
00175 typedef struct interaction_dialog_t interaction_dialog_t;
00176 typedef struct user_widget_t user_widget_t;
00177
00178
00179 typedef struct input_thread_t input_thread_t;
00180 typedef struct input_thread_sys_t input_thread_sys_t;
00181 typedef struct input_item_t input_item_t;
00182 typedef struct access_t access_t;
00183 typedef struct access_sys_t access_sys_t;
00184 typedef struct stream_t stream_t;
00185 typedef struct stream_sys_t stream_sys_t;
00186 typedef struct demux_t demux_t;
00187 typedef struct demux_meta_t demux_meta_t;
00188 typedef struct demux_sys_t demux_sys_t;
00189 typedef struct es_out_t es_out_t;
00190 typedef struct es_out_id_t es_out_id_t;
00191 typedef struct es_out_sys_t es_out_sys_t;
00192 typedef struct es_descriptor_t es_descriptor_t;
00193 typedef struct seekpoint_t seekpoint_t;
00194 typedef struct info_t info_t;
00195 typedef struct info_category_t info_category_t;
00196 typedef struct input_attachment_t input_attachment_t;
00197
00198
00199 typedef struct audio_format_t audio_format_t;
00200 typedef struct video_format_t video_format_t;
00201 typedef struct subs_format_t subs_format_t;
00202 typedef struct es_format_t es_format_t;
00203 typedef struct video_palette_t video_palette_t;
00204
00205
00206 typedef struct aout_instance_t aout_instance_t;
00207 typedef struct aout_sys_t aout_sys_t;
00208 typedef struct aout_fifo_t aout_fifo_t;
00209 typedef struct aout_input_t aout_input_t;
00210 typedef struct aout_buffer_t aout_buffer_t;
00211 typedef audio_format_t audio_sample_format_t;
00212 typedef struct audio_date_t audio_date_t;
00213 typedef struct aout_filter_t aout_filter_t;
00214
00215
00216 typedef struct vout_thread_t vout_thread_t;
00217 typedef struct vout_sys_t vout_sys_t;
00218
00219 typedef video_format_t video_frame_format_t;
00220 typedef struct picture_t picture_t;
00221 typedef struct picture_sys_t picture_sys_t;
00222 typedef struct picture_heap_t picture_heap_t;
00223
00224
00225 typedef struct spu_t spu_t;
00226 typedef struct subpicture_t subpicture_t;
00227 typedef struct subpicture_sys_t subpicture_sys_t;
00228 typedef struct subpicture_region_t subpicture_region_t;
00229 typedef struct text_style_t text_style_t;
00230
00231 typedef struct image_handler_t image_handler_t;
00232
00233
00234 typedef struct sout_instance_t sout_instance_t;
00235 typedef struct sout_instance_sys_t sout_instance_sys_t;
00236
00237 typedef struct sout_input_t sout_input_t;
00238 typedef struct sout_packetizer_input_t sout_packetizer_input_t;
00239
00240 typedef struct sout_access_out_t sout_access_out_t;
00241 typedef struct sout_access_out_sys_t sout_access_out_sys_t;
00242
00243 typedef struct sout_mux_t sout_mux_t;
00244 typedef struct sout_mux_sys_t sout_mux_sys_t;
00245
00246 typedef struct sout_stream_t sout_stream_t;
00247 typedef struct sout_stream_sys_t sout_stream_sys_t;
00248
00249 typedef struct config_chain_t config_chain_t;
00250 typedef struct sap_session_t sap_session_t;
00251 typedef struct sap_address_t sap_address_t;
00252 typedef struct session_descriptor_t session_descriptor_t;
00253 typedef struct announce_method_t announce_method_t;
00254 typedef struct announce_handler_t announce_handler_t;
00255 typedef struct sap_handler_t sap_handler_t;
00256
00257 typedef struct sout_param_t sout_param_t;
00258 typedef struct sout_pcat_t sout_pcat_t;
00259 typedef struct sout_std_t sout_std_t;
00260 typedef struct sout_display_t sout_display_t;
00261 typedef struct sout_duplicate_t sout_duplicate_t;
00262 typedef struct sout_transcode_t sout_transcode_t;
00263 typedef struct sout_chain_t sout_chain_t;
00264 typedef struct streaming_profile_t streaming_profile_t;
00265 typedef struct sout_module_t sout_module_t;
00266 typedef struct sout_gui_descr_t sout_gui_descr_t;
00267 typedef struct profile_parser_t profile_parser_t;
00268
00269
00270 typedef struct decoder_t decoder_t;
00271 typedef struct decoder_sys_t decoder_sys_t;
00272 typedef struct decoder_synchro_t decoder_synchro_t;
00273
00274
00275 typedef struct encoder_t encoder_t;
00276 typedef struct encoder_sys_t encoder_sys_t;
00277
00278
00279 typedef struct filter_t filter_t;
00280 typedef struct filter_sys_t filter_sys_t;
00281
00282
00283 typedef struct network_socket_t network_socket_t;
00284 typedef struct virtual_socket_t v_socket_t;
00285 typedef struct sockaddr sockaddr;
00286 typedef struct addrinfo addrinfo;
00287 typedef struct vlc_acl_t vlc_acl_t;
00288 typedef struct vlc_url_t vlc_url_t;
00289
00290
00291 typedef struct iso639_lang_t iso639_lang_t;
00292 typedef struct device_t device_t;
00293 typedef struct device_probe_t device_probe_t;
00294 typedef struct probe_sys_t probe_sys_t;
00295
00296
00297 typedef struct block_t block_t;
00298 typedef struct block_fifo_t block_fifo_t;
00299
00300
00301 typedef struct httpd_t httpd_t;
00302 typedef struct httpd_host_t httpd_host_t;
00303 typedef struct httpd_url_t httpd_url_t;
00304 typedef struct httpd_client_t httpd_client_t;
00305 typedef struct httpd_callback_sys_t httpd_callback_sys_t;
00306 typedef struct httpd_message_t httpd_message_t;
00307 typedef int (*httpd_callback_t)( httpd_callback_sys_t *, httpd_client_t *, httpd_message_t *answer, const httpd_message_t *query );
00308 typedef struct httpd_file_t httpd_file_t;
00309 typedef struct httpd_file_sys_t httpd_file_sys_t;
00310 typedef int (*httpd_file_callback_t)( httpd_file_sys_t *, httpd_file_t *, uint8_t *psz_request, uint8_t **pp_data, int *pi_data );
00311 typedef struct httpd_handler_t httpd_handler_t;
00312 typedef struct httpd_handler_sys_t httpd_handler_sys_t;
00313 typedef int (*httpd_handler_callback_t)( httpd_handler_sys_t *, httpd_handler_t *, char *psz_url, uint8_t *psz_request, int i_type, uint8_t *p_in, int i_in, char *psz_remote_addr, char *psz_remote_host, uint8_t **pp_data, int *pi_data );
00314 typedef struct httpd_redirect_t httpd_redirect_t;
00315 typedef struct httpd_stream_t httpd_stream_t;
00316
00317
00318 typedef struct tls_server_t tls_server_t;
00319 typedef struct tls_session_t tls_session_t;
00320
00321
00322 typedef struct md5_s md5_t;
00323
00324
00325 typedef struct xml_t xml_t;
00326 typedef struct xml_sys_t xml_sys_t;
00327 typedef struct xml_reader_t xml_reader_t;
00328 typedef struct xml_reader_sys_t xml_reader_sys_t;
00329
00330
00331 typedef struct vod_t vod_t;
00332 typedef struct vod_sys_t vod_sys_t;
00333 typedef struct vod_media_t vod_media_t;
00334
00335
00336 typedef struct opengl_t opengl_t;
00337 typedef struct opengl_sys_t opengl_sys_t;
00338
00339
00340 typedef struct osd_menu_t osd_menu_t;
00341 typedef struct osd_state_t osd_state_t;
00342 typedef struct osd_event_t osd_event_t;
00343 typedef struct osd_button_t osd_button_t;
00344 typedef struct osd_menu_state_t osd_menu_state_t;
00345
00346
00347 typedef struct vlm_t vlm_t;
00348 typedef struct vlm_message_t vlm_message_t;
00349
00350
00351 typedef struct vlc_meta_t vlc_meta_t;
00352 typedef struct meta_export_t meta_export_t;
00353
00354
00355 typedef struct counter_t counter_t;
00356 typedef struct counter_sample_t counter_sample_t;
00357 typedef struct stats_handler_t stats_handler_t;
00358 typedef struct input_stats_t input_stats_t;
00359 typedef struct global_stats_t global_stats_t;
00360
00361
00362 typedef struct update_t update_t;
00363 typedef struct update_iterator_t update_iterator_t;
00364
00365
00366 typedef struct meta_engine_t meta_engine_t;
00367
00368
00369 #ifdef WIN32
00370 #include <sys/stat.h>
00371 struct _stati64;
00372 #define stat _stati64
00373 #define fstat _fstati64
00374
00375 #else
00376 struct stat;
00377 #endif
00378
00379
00380
00381
00382 typedef union
00383 {
00384 int i_int;
00385 bool b_bool;
00386 float f_float;
00387 char * psz_string;
00388 void * p_address;
00389 vlc_object_t * p_object;
00390 vlc_list_t * p_list;
00391 mtime_t i_time;
00392
00393 struct { char *psz_name; int i_object_id; } var;
00394
00395
00396 struct { char a, b, c, d, e, f, g, h; } padding;
00397
00398 } vlc_value_t;
00399
00400
00401
00402
00403 struct vlc_list_t
00404 {
00405 int i_count;
00406 vlc_value_t * p_values;
00407 int * pi_types;
00408
00409 };
00410
00411
00412
00413
00414
00415
00416 #define VLC_VAR_VOID 0x0010
00417 #define VLC_VAR_BOOL 0x0020
00418 #define VLC_VAR_INTEGER 0x0030
00419 #define VLC_VAR_HOTKEY 0x0031
00420 #define VLC_VAR_STRING 0x0040
00421 #define VLC_VAR_MODULE 0x0041
00422 #define VLC_VAR_FILE 0x0042
00423 #define VLC_VAR_DIRECTORY 0x0043
00424 #define VLC_VAR_VARIABLE 0x0044
00425 #define VLC_VAR_FLOAT 0x0050
00426 #define VLC_VAR_TIME 0x0060
00427 #define VLC_VAR_ADDRESS 0x0070
00428 #define VLC_VAR_MUTEX 0x0080
00429 #define VLC_VAR_LIST 0x0090
00430
00431
00432
00433
00434
00435 #define VLC_SUCCESS -0
00436 #define VLC_ENOMEM -1
00437 #define VLC_ETHREAD -2
00438 #define VLC_ETIMEOUT -3
00439
00440 #define VLC_ENOMOD -10
00441
00442 #define VLC_ENOOBJ -20
00443
00444 #define VLC_ENOVAR -30
00445 #define VLC_EBADVAR -31
00446
00447 #define VLC_ENOITEM -40
00448
00449 #define VLC_EEXIT -255
00450 #define VLC_EEXITSUCCESS -999
00451 #define VLC_EGENERIC -666
00452
00453
00454
00455
00456 typedef int ( * vlc_callback_t ) ( vlc_object_t *,
00457 char const *,
00458 vlc_value_t,
00459 vlc_value_t,
00460 void * );
00461
00462
00463
00464
00465
00466 #ifdef __cplusplus
00467 # define LIBVLC_EXTERN extern "C"
00468 #else
00469 # define LIBVLC_EXTERN extern
00470 #endif
00471 #if defined (WIN32) && defined (DLL_EXPORT)
00472 # define LIBVLC_EXPORT __declspec(dllexport)
00473 #else
00474 # define LIBVLC_EXPORT
00475 #endif
00476 #define VLC_EXPORT( type, name, args ) \
00477 LIBVLC_EXTERN LIBVLC_EXPORT type name args
00478
00479
00480
00481
00482 #if defined( WIN32 ) || defined( UNDER_CE )
00483 # define WIN32_LEAN_AND_MEAN
00484 # include <windows.h>
00485 # if defined( UNDER_CE )
00486 # define IS_WINNT 0
00487 # else
00488 # define IS_WINNT ( GetVersion() < 0x80000000 )
00489 # endif
00490 #endif
00491
00492 #include "vlc_mtime.h"
00493 #include "vlc_threads.h"
00494
00495 typedef struct vlc_object_internals_t vlc_object_internals_t;
00496
00497
00498
00499
00500
00501
00502 #define VLC_COMMON_MEMBERS \
00503
00504
00505 \
00506 \
00507 int i_object_id; \
00508 int i_object_type; \
00509 const char *psz_object_type; \
00510 char *psz_object_name; \
00511 \
00512 \
00513 char *psz_header; \
00514 int i_flags; \
00515 \
00516 \
00517 volatile bool b_error; \
00518 volatile bool b_die; \
00519 volatile bool b_dead; \
00520 bool b_force; \
00521 \
00522 \
00523 libvlc_int_t *p_libvlc; \
00524 \
00525 vlc_object_t * p_parent; \
00526 \
00527 \
00528 void * p_private; \
00529 \
00530 \
00531 int be_sure_to_add_VLC_COMMON_MEMBERS_to_struct; \
00532 \
00533
00534
00535 #define VLC_OBJECT( x ) \
00536 (((vlc_object_t *)(x))+0*(x)->be_sure_to_add_VLC_COMMON_MEMBERS_to_struct)
00537
00538 #define VLC_GC_MEMBERS \
00539
00540
00541 \
00542 \
00543 int i_gc_refcount; \
00544 void (*pf_destructor) ( gc_object_t * ); \
00545 void *p_destructor_arg; \
00546
00547
00548 struct gc_object_t
00549 {
00550 VLC_GC_MEMBERS
00551 };
00552
00553 VLC_EXPORT(void, __vlc_gc_incref, ( gc_object_t * p_gc ));
00554 VLC_EXPORT(void, __vlc_gc_decref, ( gc_object_t * p_gc ));
00555 VLC_EXPORT(void, __vlc_gc_init, ( gc_object_t * p_gc,
00556 void (*pf_destructor)( gc_object_t * ), void * arg));
00557
00558 #define vlc_gc_incref( a ) __vlc_gc_incref( (gc_object_t *)a )
00559 #define vlc_gc_decref( a ) __vlc_gc_decref( (gc_object_t *)a )
00560 #define vlc_gc_init( a,b,c ) __vlc_gc_init( (gc_object_t *)a,b,c )
00561
00562
00563
00564
00565
00566
00567
00568 #define CEIL(n, d) ( ((n) / (d)) + ( ((n) % (d)) ? 1 : 0) )
00569
00570
00571 #define PAD(n, d) ( ((n) % (d)) ? ((((n) / (d)) + 1) * (d)) : (n) )
00572
00573
00574 #ifndef __MAX
00575 # define __MAX(a, b) ( ((a) > (b)) ? (a) : (b) )
00576 #endif
00577 #ifndef __MIN
00578 # define __MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
00579 #endif
00580
00581 static inline int64_t GCD( int64_t a, int64_t b )
00582 {
00583 while( b )
00584 {
00585 int64_t c = a % b;
00586 a = b;
00587 b = c;
00588 }
00589 return a;
00590 }
00591
00592
00593 static inline uint8_t clip_uint8_vlc( int32_t a )
00594 {
00595 if( a&(~255) ) return (-a)>>31;
00596 else return a;
00597 }
00598
00599
00600 #define MALLOC_VOID( var, type ) do { var = (type*)malloc( sizeof( type) ); \
00601 if( !var ) return; } while(0)
00602 #define MALLOC_NULL( var, type ) do { var = (type*)malloc( sizeof( type) ); \
00603 if( !var ) return NULL; } while(0)
00604 #define MALLOC_ERR( var, type ) do { var = (type*)malloc( sizeof( type) ); \
00605 if( !var ) return VLC_ENOMEM; } while(0)
00606 #define MALLOC_GOTOERR( var, type ) do { var = (type*)malloc( sizeof( type) ); \
00607 if( !var ) goto error; } while(0)
00608 #define DECMALLOC_VOID( var, type ) type* var = (type*)malloc( sizeof(type) );\
00609 if( !var ) return;
00610 #define DECMALLOC_ERR( var, type ) type* var = (type*)malloc( sizeof(type) );\
00611 if( !var ) return VLC_ENOMEM;
00612 #define DECMALLOC_NULL( var, type ) type* var = (type*)malloc( sizeof(type) );\
00613 if( !var ) return NULL;
00614
00615 #define FREENULL(a) do { free( a ); a = NULL; } while(0)
00616
00617 #define EMPTY_STR(str) (!str || !*str)
00618
00619 VLC_EXPORT( char const *, vlc_error, ( int ) );
00620
00621 #include <vlc_arrays.h>
00622
00623
00624
00625 static inline uint16_t U16_AT( const void * _p )
00626 {
00627 const uint8_t * p = (const uint8_t *)_p;
00628 return ( ((uint16_t)p[0] << 8) | p[1] );
00629 }
00630 static inline uint32_t U32_AT( const void * _p )
00631 {
00632 const uint8_t * p = (const uint8_t *)_p;
00633 return ( ((uint32_t)p[0] << 24) | ((uint32_t)p[1] << 16)
00634 | ((uint32_t)p[2] << 8) | p[3] );
00635 }
00636 static inline uint64_t U64_AT( const void * _p )
00637 {
00638 const uint8_t * p = (const uint8_t *)_p;
00639 return ( ((uint64_t)p[0] << 56) | ((uint64_t)p[1] << 48)
00640 | ((uint64_t)p[2] << 40) | ((uint64_t)p[3] << 32)
00641 | ((uint64_t)p[4] << 24) | ((uint64_t)p[5] << 16)
00642 | ((uint64_t)p[6] << 8) | p[7] );
00643 }
00644
00645 static inline uint16_t GetWLE( const void * _p )
00646 {
00647 const uint8_t * p = (const uint8_t *)_p;
00648 return ( ((uint16_t)p[1] << 8) | p[0] );
00649 }
00650 static inline uint32_t GetDWLE( const void * _p )
00651 {
00652 const uint8_t * p = (const uint8_t *)_p;
00653 return ( ((uint32_t)p[3] << 24) | ((uint32_t)p[2] << 16)
00654 | ((uint32_t)p[1] << 8) | p[0] );
00655 }
00656 static inline uint64_t GetQWLE( const void * _p )
00657 {
00658 const uint8_t * p = (const uint8_t *)_p;
00659 return ( ((uint64_t)p[7] << 56) | ((uint64_t)p[6] << 48)
00660 | ((uint64_t)p[5] << 40) | ((uint64_t)p[4] << 32)
00661 | ((uint64_t)p[3] << 24) | ((uint64_t)p[2] << 16)
00662 | ((uint64_t)p[1] << 8) | p[0] );
00663 }
00664
00665 #define GetWBE( p ) U16_AT( p )
00666 #define GetDWBE( p ) U32_AT( p )
00667 #define GetQWBE( p ) U64_AT( p )
00668
00669
00670 #define SetWLE( p, v ) _SetWLE( (uint8_t*)(p), v)
00671 static inline void _SetWLE( uint8_t *p, uint16_t i_dw )
00672 {
00673 p[1] = ( i_dw >> 8 )&0xff;
00674 p[0] = ( i_dw )&0xff;
00675 }
00676
00677 #define SetDWLE( p, v ) _SetDWLE( (uint8_t*)(p), v)
00678 static inline void _SetDWLE( uint8_t *p, uint32_t i_dw )
00679 {
00680 p[3] = ( i_dw >> 24 )&0xff;
00681 p[2] = ( i_dw >> 16 )&0xff;
00682 p[1] = ( i_dw >> 8 )&0xff;
00683 p[0] = ( i_dw )&0xff;
00684 }
00685 #define SetQWLE( p, v ) _SetQWLE( (uint8_t*)(p), v)
00686 static inline void _SetQWLE( uint8_t *p, uint64_t i_qw )
00687 {
00688 SetDWLE( p, i_qw&0xffffffff );
00689 SetDWLE( p+4, ( i_qw >> 32)&0xffffffff );
00690 }
00691 #define SetWBE( p, v ) _SetWBE( (uint8_t*)(p), v)
00692 static inline void _SetWBE( uint8_t *p, uint16_t i_dw )
00693 {
00694 p[0] = ( i_dw >> 8 )&0xff;
00695 p[1] = ( i_dw )&0xff;
00696 }
00697
00698 #define SetDWBE( p, v ) _SetDWBE( (uint8_t*)(p), v)
00699 static inline void _SetDWBE( uint8_t *p, uint32_t i_dw )
00700 {
00701 p[0] = ( i_dw >> 24 )&0xff;
00702 p[1] = ( i_dw >> 16 )&0xff;
00703 p[2] = ( i_dw >> 8 )&0xff;
00704 p[3] = ( i_dw )&0xff;
00705 }
00706 #define SetQWBE( p, v ) _SetQWBE( (uint8_t*)(p), v)
00707 static inline void _SetQWBE( uint8_t *p, uint64_t i_qw )
00708 {
00709 SetDWBE( p+4, i_qw&0xffffffff );
00710 SetDWBE( p, ( i_qw >> 32)&0xffffffff );
00711 }
00712
00713 #define hton16(i) htons(i)
00714 #define hton32(i) htonl(i)
00715 #define ntoh16(i) ntohs(i)
00716 #define ntoh32(i) ntohl(i)
00717
00718 static inline uint64_t ntoh64 (uint64_t ll)
00719 {
00720 union { uint64_t qw; uint8_t b[16]; } v = { ll };
00721 return ((uint64_t)v.b[0] << 56)
00722 | ((uint64_t)v.b[1] << 48)
00723 | ((uint64_t)v.b[2] << 40)
00724 | ((uint64_t)v.b[3] << 32)
00725 | ((uint64_t)v.b[4] << 24)
00726 | ((uint64_t)v.b[5] << 16)
00727 | ((uint64_t)v.b[6] << 8)
00728 | ((uint64_t)v.b[7] << 0);
00729 }
00730 #define hton64(i) ntoh64(i)
00731
00732
00733 #ifdef __GNUC__
00734 # define LIBVLC_FORMAT(x,y) __attribute__ ((format(printf,x,y)))
00735 #else
00736 # define LIBVLC_FORMAT(x,y)
00737 #endif
00738
00739
00740 #define VLC_UNUSED(x) (void)(x)
00741
00742
00743 VLC_EXPORT( size_t, vlc_strlcpy, ( char *, const char *, size_t ) );
00744 VLC_EXPORT( long long, vlc_strtoll, ( const char *nptr, char **endptr, int base ) );
00745
00746 VLC_EXPORT( char *, vlc_strcasestr, ( const char *s1, const char *s2 ) );
00747
00748 #if defined(WIN32) || defined(UNDER_CE)
00749
00750 # if defined( _MSC_VER ) || !defined( __MINGW32__ )
00751 # define __attribute__(x)
00752 # define __inline__ __inline
00753 # define S_IFBLK 0x3000
00754 # define S_ISBLK(m) (0)
00755 # define S_ISCHR(m) (0)
00756 # define S_ISFIFO(m) (((m)&_S_IFMT) == _S_IFIFO)
00757 # define S_ISREG(m) (((m)&_S_IFMT) == _S_IFREG)
00758 # endif
00759
00760
00761 # if defined( __MINGW32__ )
00762 # if !defined( _OFF_T_ )
00763 typedef long long _off_t;
00764 typedef _off_t off_t;
00765 # define _OFF_T_
00766 # else
00767 # ifdef off_t
00768 # undef off_t
00769 # endif
00770