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 #include <stddef.h>
00054
00055 #ifndef __cplusplus
00056 # include <stdbool.h>
00057 #endif
00058
00059
00060 #ifdef __GNUC__
00061 # define VLC_GCC_VERSION(maj,min) \
00062 ((__GNUC__ > (maj)) || (__GNUC__ == (maj) && __GNUC_MINOR__ >= (min)))
00063 #else
00064 # define VLC_GCC_VERSION(maj,min) (0)
00065 #endif
00066
00067
00068 #if defined( _WIN32 ) && defined( __USE_MINGW_ANSI_STDIO )
00069 #undef PRId64
00070 #define PRId64 "lld"
00071 #undef PRIi64
00072 #define PRIi64 "lli"
00073 #undef PRIu64
00074 #define PRIu64 "llu"
00075 #undef PRIo64
00076 #define PRIo64 "llo"
00077 #undef PRIx64
00078 #define PRIx64 "llx"
00079 #define snprintf __mingw_snprintf
00080 #define vsnprintf __mingw_vsnprintf
00081 #endif
00082
00083
00084 #ifdef __GNUC__
00085 # define VLC_DEPRECATED __attribute__((deprecated))
00086
00087 # if defined( _WIN32 ) && VLC_GCC_VERSION(4,4)
00088 # define VLC_FORMAT(x,y) __attribute__ ((format(gnu_printf,x,y)))
00089 # else
00090 # define VLC_FORMAT(x,y) __attribute__ ((format(printf,x,y)))
00091 # endif
00092 # define VLC_FORMAT_ARG(x) __attribute__ ((format_arg(x)))
00093
00094 # define VLC_MALLOC __attribute__ ((malloc))
00095 # define VLC_NORETURN __attribute__ ((noreturn))
00096
00097 # if VLC_GCC_VERSION(3,4)
00098 # define VLC_USED __attribute__ ((warn_unused_result))
00099 # else
00100 # define VLC_USED
00101 # endif
00102
00103 #else
00104 # define VLC_DEPRECATED
00105 # define VLC_FORMAT(x,y)
00106 # define VLC_FORMAT_ARG(x)
00107 # define VLC_MALLOC
00108 # define VLC_NORETURN
00109 # define VLC_USED
00110 #endif
00111
00112
00113
00114 #ifdef __GNUC__
00115 # define likely(p) __builtin_expect(!!(p), 1)
00116 # define unlikely(p) __builtin_expect(!!(p), 0)
00117 #else
00118 # define likely(p) (!!(p))
00119 # define unlikely(p) (!!(p))
00120 #endif
00121
00122
00123 #ifdef __cplusplus
00124 # define VLC_EXTERN extern "C"
00125 #else
00126 # define VLC_EXTERN
00127 #endif
00128
00129 #if defined (WIN32) && defined (DLL_EXPORT)
00130 # define VLC_EXPORT __declspec(dllexport)
00131 #elif VLC_GCC_VERSION(4,0)
00132 # define VLC_EXPORT __attribute__((visibility("default")))
00133 #else
00134 # define VLC_EXPORT
00135 #endif
00136
00137 #define VLC_API VLC_EXTERN VLC_EXPORT
00138
00139
00140
00141
00142
00143 #if defined( WIN32 ) || defined( UNDER_CE )
00144 # include <malloc.h>
00145 # ifndef PATH_MAX
00146 # define PATH_MAX MAX_PATH
00147 # endif
00148 #endif
00149
00150 #ifdef __SYMBIAN32__
00151 #include <sys/syslimits.h>
00152 #endif
00153
00154
00155 typedef uint16_t audio_volume_t;
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 typedef int64_t mtime_t;
00168
00169
00170
00171
00172
00173
00174 typedef uint32_t vlc_fourcc_t;
00175
00176 #ifdef WORDS_BIGENDIAN
00177 # define VLC_FOURCC( a, b, c, d ) \
00178 ( ((uint32_t)d) | ( ((uint32_t)c) << 8 ) \
00179 | ( ((uint32_t)b) << 16 ) | ( ((uint32_t)a) << 24 ) )
00180 # define VLC_TWOCC( a, b ) \
00181 ( (uint16_t)(b) | ( (uint16_t)(a) << 8 ) )
00182
00183 #else
00184 # define VLC_FOURCC( a, b, c, d ) \
00185 ( ((uint32_t)a) | ( ((uint32_t)b) << 8 ) \
00186 | ( ((uint32_t)c) << 16 ) | ( ((uint32_t)d) << 24 ) )
00187 # define VLC_TWOCC( a, b ) \
00188 ( (uint16_t)(a) | ( (uint16_t)(b) << 8 ) )
00189
00190 #endif
00191
00192
00193
00194
00195
00196
00197
00198
00199 static inline void vlc_fourcc_to_char( vlc_fourcc_t fcc, char *psz_fourcc )
00200 {
00201 memcpy( psz_fourcc, &fcc, 4 );
00202 }
00203
00204 #define vlc_fourcc_to_char( a, b ) \
00205 vlc_fourcc_to_char( (vlc_fourcc_t)(a), (char *)(b) )
00206
00207
00208
00209
00210
00211
00212 typedef struct vlc_list_t vlc_list_t;
00213 typedef struct vlc_object_t vlc_object_t;
00214 typedef struct libvlc_int_t libvlc_int_t;
00215 typedef struct date_t date_t;
00216
00217
00218
00219
00220
00221
00222
00223 typedef enum {
00224 PLAYLIST_PLAY,
00225 PLAYLIST_VIEWPLAY,
00226
00227 PLAYLIST_PAUSE,
00228 PLAYLIST_STOP,
00229 PLAYLIST_SKIP,
00230 } playlist_command_t;
00231
00232
00233 typedef struct playlist_t playlist_t;
00234 typedef struct playlist_item_t playlist_item_t;
00235 typedef struct playlist_view_t playlist_view_t;
00236 typedef struct services_discovery_t services_discovery_t;
00237 typedef struct services_discovery_sys_t services_discovery_sys_t;
00238 typedef struct playlist_add_t playlist_add_t;
00239
00240
00241 typedef struct module_t module_t;
00242 typedef struct module_config_t module_config_t;
00243
00244 typedef struct config_category_t config_category_t;
00245
00246
00247 typedef struct input_thread_t input_thread_t;
00248 typedef struct input_item_t input_item_t;
00249 typedef struct input_item_node_t input_item_node_t;
00250 typedef struct access_t access_t;
00251 typedef struct access_sys_t access_sys_t;
00252 typedef struct stream_t stream_t;
00253 typedef struct stream_sys_t stream_sys_t;
00254 typedef struct demux_t demux_t;
00255 typedef struct demux_sys_t demux_sys_t;
00256 typedef struct es_out_t es_out_t;
00257 typedef struct es_out_id_t es_out_id_t;
00258 typedef struct es_out_sys_t es_out_sys_t;
00259 typedef struct seekpoint_t seekpoint_t;
00260 typedef struct info_t info_t;
00261 typedef struct info_category_t info_category_t;
00262 typedef struct input_attachment_t input_attachment_t;
00263
00264
00265 typedef struct audio_format_t audio_format_t;
00266 typedef struct video_format_t video_format_t;
00267 typedef struct subs_format_t subs_format_t;
00268 typedef struct es_format_t es_format_t;
00269 typedef struct video_palette_t video_palette_t;
00270
00271
00272 typedef struct audio_output audio_output_t;
00273 typedef struct aout_sys_t aout_sys_t;
00274 typedef struct aout_fifo_t aout_fifo_t;
00275 typedef struct aout_input_t aout_input_t;
00276 typedef struct block_t aout_buffer_t;
00277 typedef audio_format_t audio_sample_format_t;
00278
00279
00280 typedef struct vout_thread_t vout_thread_t;
00281
00282 typedef video_format_t video_frame_format_t;
00283 typedef struct picture_t picture_t;
00284 typedef struct picture_sys_t picture_sys_t;
00285
00286
00287 typedef struct spu_t spu_t;
00288 typedef struct subpicture_t subpicture_t;
00289 typedef struct subpicture_sys_t subpicture_sys_t;
00290 typedef struct subpicture_region_t subpicture_region_t;
00291
00292 typedef struct image_handler_t image_handler_t;
00293
00294
00295 typedef struct sout_instance_t sout_instance_t;
00296 typedef struct sout_instance_sys_t sout_instance_sys_t;
00297
00298 typedef struct sout_input_t sout_input_t;
00299 typedef struct sout_packetizer_input_t sout_packetizer_input_t;
00300
00301 typedef struct sout_access_out_t sout_access_out_t;
00302 typedef struct sout_access_out_sys_t sout_access_out_sys_t;
00303
00304 typedef struct sout_mux_t sout_mux_t;
00305 typedef struct sout_mux_sys_t sout_mux_sys_t;
00306
00307 typedef struct sout_stream_t sout_stream_t;
00308 typedef struct sout_stream_sys_t sout_stream_sys_t;
00309
00310 typedef struct config_chain_t config_chain_t;
00311 typedef struct session_descriptor_t session_descriptor_t;
00312
00313
00314 typedef struct decoder_t decoder_t;
00315 typedef struct decoder_sys_t decoder_sys_t;
00316 typedef struct decoder_synchro_t decoder_synchro_t;
00317
00318
00319 typedef struct encoder_t encoder_t;
00320 typedef struct encoder_sys_t encoder_sys_t;
00321
00322
00323 typedef struct filter_t filter_t;
00324 typedef struct filter_sys_t filter_sys_t;
00325
00326
00327 typedef struct virtual_socket_t v_socket_t;
00328 typedef struct vlc_url_t vlc_url_t;
00329
00330
00331 typedef struct iso639_lang_t iso639_lang_t;
00332
00333
00334 typedef struct block_t block_t;
00335 typedef struct block_fifo_t block_fifo_t;
00336
00337
00338 typedef struct md5_s md5_t;
00339
00340
00341 typedef struct xml_t xml_t;
00342 typedef struct xml_sys_t xml_sys_t;
00343 typedef struct xml_reader_t xml_reader_t;
00344 typedef struct xml_reader_sys_t xml_reader_sys_t;
00345
00346
00347 typedef struct vod_t vod_t;
00348 typedef struct vod_sys_t vod_sys_t;
00349 typedef struct vod_media_t vod_media_t;
00350
00351
00352 typedef struct osd_menu_t osd_menu_t;
00353 typedef struct osd_state_t osd_state_t;
00354 typedef struct osd_event_t osd_event_t;
00355 typedef struct osd_button_t osd_button_t;
00356 typedef struct osd_menu_state_t osd_menu_state_t;
00357
00358
00359 typedef struct vlm_t vlm_t;
00360 typedef struct vlm_message_t vlm_message_t;
00361
00362
00363 typedef struct vlc_meta_t vlc_meta_t;
00364 typedef struct input_stats_t input_stats_t;
00365
00366
00367 typedef struct update_t update_t;
00368 typedef struct update_iterator_t update_iterator_t;
00369
00370
00371 typedef struct meta_engine_t meta_engine_t;
00372
00373
00374
00375
00376 typedef union
00377 {
00378 int64_t i_int;
00379 bool b_bool;
00380 float f_float;
00381 char * psz_string;
00382 void * p_address;
00383 vlc_object_t * p_object;
00384 vlc_list_t * p_list;
00385 mtime_t i_time;
00386 struct { int32_t x; int32_t y; } coords;
00387
00388 } vlc_value_t;
00389
00390
00391
00392
00393 struct vlc_list_t
00394 {
00395 int i_count;
00396 vlc_value_t * p_values;
00397 int * pi_types;
00398
00399 };
00400
00401
00402
00403
00404 #define VLC_SUCCESS -0
00405 #define VLC_ENOMEM -1
00406 #define VLC_ETIMEOUT -3
00407
00408 #define VLC_ENOMOD -10
00409
00410 #define VLC_ENOOBJ -20
00411
00412 #define VLC_ENOVAR -30
00413 #define VLC_EBADVAR -31
00414
00415 #define VLC_ENOITEM -40
00416
00417 #define VLC_EEXIT -255
00418 #define VLC_EEXITSUCCESS -999
00419 #define VLC_EGENERIC -666
00420
00421
00422
00423
00424 typedef int ( * vlc_callback_t ) ( vlc_object_t *,
00425 char const *,
00426 vlc_value_t,
00427 vlc_value_t,
00428 void * );
00429
00430
00431
00432
00433 #if defined( WIN32 ) || defined( UNDER_CE )
00434 # include <windows.h>
00435 #endif
00436
00437 #ifdef __OS2__
00438 # define OS2EMX_PLAIN_CHAR
00439 # define INCL_BASE
00440 # define INCL_PM
00441 # include <os2.h>
00442 #endif
00443
00444 #include "vlc_mtime.h"
00445 #include "vlc_threads.h"
00446
00447
00448
00449
00450 typedef union
00451 {
00452 volatile uintptr_t u;
00453 volatile intptr_t s;
00454 } vlc_atomic_t;
00455
00456
00457
00458
00459
00460
00461 #define VLC_COMMON_MEMBERS \
00462
00463
00464 \
00465 \
00466 const char *psz_object_type; \
00467 \
00468 \
00469 char *psz_header; \
00470 int i_flags; \
00471 \
00472 \
00473 volatile bool b_die; \
00474 bool b_force; \
00475 \
00476 \
00477 libvlc_int_t *p_libvlc; \
00478 \
00479 vlc_object_t * p_parent; \
00480 \
00481 \
00482
00483
00484 #if VLC_GCC_VERSION(4,0)
00485 # ifndef __cplusplus
00486 # define VLC_OBJECT( x ) \
00487 __builtin_choose_expr( \
00488 __builtin_offsetof(__typeof__(*(x)), psz_object_type), \
00489 (void)0 , \
00490 (vlc_object_t *)(x))
00491 # else
00492 # define VLC_OBJECT( x ) \
00493 ((vlc_object_t *)(x) \
00494 + 0 * __builtin_offsetof(__typeof__(*(x)), psz_object_type))
00495 # endif
00496 #else
00497 # define VLC_OBJECT( x ) ((vlc_object_t *)(x))
00498 #endif
00499
00500 typedef struct gc_object_t
00501 {
00502 vlc_atomic_t refs;
00503 void (*pf_destructor) (struct gc_object_t *);
00504 } gc_object_t;
00505
00506
00507
00508
00509 #define VLC_GC_MEMBERS gc_object_t vlc_gc_data;
00510
00511 VLC_API void * vlc_gc_init(gc_object_t *, void (*)(gc_object_t *));
00512 VLC_API void * vlc_hold(gc_object_t *);
00513 VLC_API void vlc_release(gc_object_t *);
00514
00515 #define vlc_gc_init( a,b ) vlc_gc_init( &(a)->vlc_gc_data, (b) )
00516 #define vlc_gc_incref( a ) vlc_hold( &(a)->vlc_gc_data )
00517 #define vlc_gc_decref( a ) vlc_release( &(a)->vlc_gc_data )
00518 #define vlc_priv( gc, t ) ((t *)(((char *)(gc)) - offsetof(t, vlc_gc_data)))
00519
00520
00521
00522
00523
00524
00525 #define CEIL(n, d) ( ((n) / (d)) + ( ((n) % (d)) ? 1 : 0) )
00526
00527
00528 #define PAD(n, d) ( ((n) % (d)) ? ((((n) / (d)) + 1) * (d)) : (n) )
00529
00530
00531 #ifndef __MAX
00532 # define __MAX(a, b) ( ((a) > (b)) ? (a) : (b) )
00533 #endif
00534 #ifndef __MIN
00535 # define __MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
00536 #endif
00537
00538
00539 #define VLC_CLIP(v, min, max) __MIN(__MAX((v), (min)), (max))
00540
00541 VLC_USED
00542 static inline int64_t GCD ( int64_t a, int64_t b )
00543 {
00544 while( b )
00545 {
00546 int64_t c = a % b;
00547 a = b;
00548 b = c;
00549 }
00550 return a;
00551 }
00552
00553
00554 VLC_USED
00555 static inline uint8_t clip_uint8_vlc( int32_t a )
00556 {
00557 if( a&(~255) ) return (-a)>>31;
00558 else return a;
00559 }
00560
00561
00562 VLC_USED
00563 static inline unsigned clz (unsigned x)
00564 {
00565 #if VLC_GCC_VERSION(3,4)
00566 return __builtin_clz (x);
00567 #else
00568 unsigned i = sizeof (x) * 8;
00569
00570 while (x)
00571 {
00572 x = x >> 1;
00573 i--;
00574 }
00575 return i;
00576 #endif
00577 }
00578
00579 #define clz8( x ) (clz(x) - ((sizeof(unsigned) - sizeof (uint8_t)) * 8))
00580 #define clz16( x ) (clz(x) - ((sizeof(unsigned) - sizeof (uint16_t)) * 8))
00581
00582 #define clz32( x ) (clz(x) - ((sizeof(unsigned) - sizeof (uint32_t)) * 8))
00583
00584
00585 VLC_USED
00586 static inline unsigned popcount (unsigned x)
00587 {
00588 #if VLC_GCC_VERSION(3,4)
00589 return __builtin_popcount (x);
00590 #else
00591 unsigned count = 0;
00592 while (x)
00593 {
00594 count += x & 1;
00595 x = x >> 1;
00596 }
00597 return count;
00598 #endif
00599 }
00600
00601 VLC_USED
00602 static inline unsigned parity (unsigned x)
00603 {
00604 #if VLC_GCC_VERSION(3,4)
00605 return __builtin_parity (x);
00606 #else
00607 for (unsigned i = 4 * sizeof (x); i > 0; i /= 2)
00608 x ^= x >> i;
00609 return x & 1;
00610 #endif
00611 }
00612
00613 #ifdef __OS2__
00614 # undef bswap16
00615 # undef bswap32
00616 # undef bswap64
00617 #endif
00618
00619
00620 VLC_USED
00621 static inline uint16_t bswap16 (uint16_t x)
00622 {
00623 return (x << 8) | (x >> 8);
00624 }
00625
00626
00627 VLC_USED
00628 static inline uint32_t bswap32 (uint32_t x)
00629 {
00630 #if VLC_GCC_VERSION(4,3)
00631 return __builtin_bswap32 (x);
00632 #else
00633 return ((x & 0x000000FF) << 24)
00634 | ((x & 0x0000FF00) << 8)
00635 | ((x & 0x00FF0000) >> 8)
00636 | ((x & 0xFF000000) >> 24);
00637 #endif
00638 }
00639
00640
00641 VLC_USED
00642 static inline uint64_t bswap64 (uint64_t x)
00643 {
00644 #if VLC_GCC_VERSION(4,3)
00645 return __builtin_bswap64 (x);
00646 #elif !defined (__cplusplus)
00647 return ((x & 0x00000000000000FF) << 56)
00648 | ((x & 0x000000000000FF00) << 40)
00649 | ((x & 0x0000000000FF0000) << 24)
00650 | ((x & 0x00000000FF000000) << 8)
00651 | ((x & 0x000000FF00000000) >> 8)
00652 | ((x & 0x0000FF0000000000) >> 24)
00653 | ((x & 0x00FF000000000000) >> 40)
00654 | ((x & 0xFF00000000000000) >> 56);
00655 #else
00656 return ((x & 0x00000000000000FFLLU) << 56)
00657 | ((x & 0x000000000000FF00LLU) << 40)
00658 | ((x & 0x0000000000FF0000LLU) << 24)
00659 | ((x & 0x00000000FF000000LLU) << 8)
00660 | ((x & 0x000000FF00000000LLU) >> 8)
00661 | ((x & 0x0000FF0000000000LLU) >> 24)
00662 | ((x & 0x00FF000000000000LLU) >> 40)
00663 | ((x & 0xFF00000000000000LLU) >> 56);
00664 #endif
00665 }
00666
00667
00668
00669 #define FREENULL(a) do { free( a ); a = NULL; } while(0)
00670
00671 #define EMPTY_STR(str) (!str || !*str)
00672
00673 VLC_API char const * vlc_error( int ) VLC_USED;
00674
00675 #include <vlc_arrays.h>
00676
00677
00678
00679
00680 #ifdef WORDS_BIGENDIAN
00681 # define hton16(i) ((uint16_t)(i))
00682 # define hton32(i) ((uint32_t)(i))
00683 # define hton64(i) ((uint64_t)(i))
00684 #else
00685 # define hton16(i) bswap16(i)
00686 # define hton32(i) bswap32(i)
00687 # define hton64(i) bswap64(i)
00688 #endif
00689 #define ntoh16(i) hton16(i)
00690 #define ntoh32(i) hton32(i)
00691 #define ntoh64(i) hton64(i)
00692
00693
00694 VLC_USED
00695 static inline uint16_t U16_AT (const void *p)
00696 {
00697 uint16_t x;
00698
00699 memcpy (&x, p, sizeof (x));
00700 return ntoh16 (x);
00701 }
00702
00703
00704 VLC_USED
00705 static inline uint32_t U32_AT (const void *p)
00706 {
00707 uint32_t x;
00708
00709 memcpy (&x, p, sizeof (x));
00710 return ntoh32 (x);
00711 }
00712
00713
00714 VLC_USED
00715 static inline uint64_t U64_AT (const void *p)
00716 {
00717 uint64_t x;
00718
00719 memcpy (&x, p, sizeof (x));
00720 return ntoh64 (x);
00721 }
00722
00723 #define GetWBE(p) U16_AT(p)
00724 #define GetDWBE(p) U32_AT(p)
00725 #define GetQWBE(p) U64_AT(p)
00726
00727
00728 VLC_USED
00729 static inline uint16_t GetWLE (const void *p)
00730 {
00731 uint16_t x;
00732
00733 memcpy (&x, p, sizeof (x));
00734 #ifdef WORDS_BIGENDIAN
00735 x = bswap16 (x);
00736 #endif
00737 return x;
00738 }
00739
00740
00741 VLC_USED
00742 static inline uint32_t GetDWLE (const void *p)
00743 {
00744 uint32_t x;
00745
00746 memcpy (&x, p, sizeof (x));
00747 #ifdef WORDS_BIGENDIAN
00748 x = bswap32 (x);
00749 #endif
00750 return x;
00751 }
00752
00753
00754 VLC_USED
00755 static inline uint64_t GetQWLE (const void *p)
00756 {
00757 uint64_t x;
00758
00759 memcpy (&x, p, sizeof (x));
00760 #ifdef WORDS_BIGENDIAN
00761 x = bswap64 (x);
00762 #endif
00763 return x;
00764 }
00765
00766
00767 static inline void SetWBE (void *p, uint16_t w)
00768 {
00769 w = hton16 (w);
00770 memcpy (p, &w, sizeof (w));
00771 }
00772
00773
00774 static inline void SetDWBE (void *p, uint32_t dw)
00775 {
00776 dw = hton32 (dw);
00777 memcpy (p, &dw, sizeof (dw));
00778 }
00779
00780
00781 static inline void SetQWBE (void *p, uint64_t qw)
00782 {
00783 qw = hton64 (qw);
00784 memcpy (p, &qw, sizeof (qw));
00785 }
00786
00787
00788 static inline void SetWLE (void *p, uint16_t w)
00789 {
00790 #ifdef WORDS_BIGENDIAN
00791 w = bswap16 (w);
00792 #endif
00793 memcpy (p, &w, sizeof (w));
00794 }
00795
00796
00797 static inline void SetDWLE (void *p, uint32_t dw)
00798 {
00799 #ifdef WORDS_BIGENDIAN
00800 dw = bswap32 (dw);
00801 #endif
00802 memcpy (p, &dw, sizeof (dw));
00803 }
00804
00805
00806 static inline void SetQWLE (void *p, uint64_t qw)
00807 {
00808 #ifdef WORDS_BIGENDIAN
00809 qw = bswap64 (qw);
00810 #endif
00811 memcpy (p, &qw, sizeof (qw));
00812 }
00813
00814
00815 #define VLC_UNUSED(x) (void)(x)
00816
00817
00818
00819 #if defined(WIN32) || defined(UNDER_CE)
00820
00821 # if defined( _MSC_VER ) || !defined( __MINGW32__ )
00822 # define __attribute__(x)
00823 # define S_IFBLK 0x3000
00824 # define S_ISBLK(m) (0)
00825 # define S_ISCHR(m) (0)
00826 # define S_ISFIFO(m) (((m)&_S_IFMT) == _S_IFIFO)
00827 # define S_ISREG(m) (((m)&_S_IFMT) == _S_IFREG)
00828 # endif
00829
00830
00831 # if defined( __MINGW32__ )
00832 # if !defined( _OFF_T_ )
00833 typedef long long _off_t;
00834 typedef _off_t off_t;
00835 # define _OFF_T_
00836 # else
00837 # ifdef off_t
00838 # undef off_t
00839 # endif
00840 # define off_t long long
00841 # endif
00842 # endif
00843
00844 # if defined( _MSC_VER )
00845 # if !defined( _OFF_T_DEFINED )
00846 typedef __int64 off_t;
00847 # define _OFF_T_DEFINED
00848 # else
00849
00850 # define off_t __int64
00851 # endif
00852 # endif
00853
00854 # if defined( __BORLANDC__ )
00855 # undef off_t
00856 # define off_t unsigned __int64
00857 # endif
00858
00859 # ifndef O_NONBLOCK
00860 # define O_NONBLOCK 0
00861 # endif
00862
00863 # ifndef alloca
00864 # define alloca _alloca
00865 # endif
00866
00867 # include <tchar.h>
00868 #endif
00869
00870 VLC_API bool vlc_ureduce( unsigned *, unsigned *, uint64_t, uint64_t, uint64_t );
00871
00872
00873 #ifdef __APPLE__
00874 #include <AvailabilityMacros.h>
00875 #endif
00876
00877 #ifdef WIN32
00878 # include <malloc.h>
00879 # define vlc_memalign(align, size) (__mingw_aligned_malloc(size, align))
00880 # define vlc_free(base) (__mingw_aligned_free(base))
00881 #elif defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6)
00882 static inline void *vlc_memalign(size_t align, size_t size)
00883 {
00884 long diff;
00885 void *ptr;
00886
00887 ptr = malloc(size+align);
00888 if(!ptr)
00889 return ptr;
00890 diff = ((-(long)ptr - 1)&(align-1)) + 1;
00891 ptr = (char*)ptr + diff;
00892 ((char*)ptr)[-1]= diff;
00893 return ptr;
00894 }
00895
00896 static void vlc_free(void *ptr)
00897 {
00898 if (ptr)
00899 free((char*)ptr - ((char*)ptr)[-1]);
00900 }
00901 #else
00902 static inline void *vlc_memalign(size_t align, size_t size)
00903 {
00904 void *base;
00905 if (unlikely(posix_memalign(&base, align, size)))
00906 base = NULL;
00907 return base;
00908 }
00909 # define vlc_free(base) free(base)
00910 #endif
00911
00912 VLC_API void vlc_tdestroy( void *, void (*)(void *) );
00913
00914
00915 VLC_API void * vlc_memcpy( void *, const void *, size_t );
00916 #define vlc_memset memset
00917
00918
00919
00920
00921 VLC_API char *vlc_gettext( const char *msgid ) VLC_FORMAT_ARG(1);
00922 VLC_API char *vlc_ngettext( const char *s, const char *p, unsigned long n ) VLC_FORMAT_ARG(1) VLC_FORMAT_ARG(2);
00923
00924 #define vlc_pgettext( ctx, id ) \
00925 vlc_pgettext_aux( ctx "\004" id, id )
00926
00927 VLC_FORMAT_ARG(2)
00928 static inline const char *vlc_pgettext_aux( const char *ctx, const char *id )
00929 {
00930 const char *tr = vlc_gettext( ctx );
00931 return (tr == ctx) ? id : tr;
00932 }
00933
00934
00935
00936
00937 static inline void *xmalloc (size_t len)
00938 {
00939 void *ptr = malloc (len);
00940 if (unlikely (ptr == NULL))
00941 abort ();
00942 return ptr;
00943 }
00944
00945 static inline void *xrealloc (void *ptr, size_t len)
00946 {
00947 void *nptr = realloc (ptr, len);
00948 if (unlikely (nptr == NULL))
00949 abort ();
00950 return nptr;
00951 }
00952
00953 static inline void *xcalloc (size_t n, size_t size)
00954 {
00955 void *ptr = calloc (n, size);
00956 if (unlikely (ptr == NULL))
00957 abort ();
00958 return ptr;
00959 }
00960
00961
00962
00963
00964 VLC_API const char * VLC_CompileBy( void ) VLC_USED;
00965 VLC_API const char * VLC_CompileHost( void ) VLC_USED;
00966 VLC_API const char * VLC_Compiler( void ) VLC_USED;
00967
00968
00969
00970
00971 #include "vlc_messages.h"
00972 #include "vlc_objects.h"
00973 #include "vlc_variables.h"
00974 #include "vlc_main.h"
00975 #include "vlc_configuration.h"
00976
00977 #if defined( WIN32 ) || defined( UNDER_CE ) || defined( __SYMBIAN32__ ) || defined( __OS2__ )
00978 # define DIR_SEP_CHAR '\\'
00979 # define DIR_SEP "\\"
00980 # define PATH_SEP_CHAR ';'
00981 # define PATH_SEP ";"
00982 #else
00983 # define DIR_SEP_CHAR '/'
00984 # define DIR_SEP "/"
00985 # define PATH_SEP_CHAR ':'
00986 # define PATH_SEP ":"
00987 #endif
00988
00989 #define LICENSE_MSG \
00990 _("This program comes with NO WARRANTY, to the extent permitted by " \
00991 "law.\nYou may redistribute it under the terms of the GNU General " \
00992 "Public License;\nsee the file named COPYING for details.\n" \
00993 "Written by the VideoLAN team; see the AUTHORS file.\n")
00994
00995 #endif