00001 #ifndef IX_TOOLS_H
00002 #define IX_TOOLS_H
00003
00081 #include <sys/time.h>
00082 #include <netinet/in.h>
00083
00084 #ifdef __cplusplus
00085 extern "C" {
00086 #endif
00087
00088
00090 #define IX_PATH_ENV "IX_PATH"
00092 #define IX_PATH "/var/ix"
00093
00095 #define IX_GLOBAL_PATH_ENV "IX_GLOBAL_PATH"
00097 #define IX_GLOBAL_PATH "/var/ix/global"
00098
00100 #define IX_SEM "sem"
00101
00103 #define IX_TABLE_ENV "IX_TABLE_PATH"
00105 #define IX_TABLE "table"
00106
00107
00108
00109
00110
00111
00112
00113
00125 typedef enum {
00127 IX_V_LOG = 0x000,
00129 IX_V_ERROR = 0x001,
00131 IX_V_PLAIN = 0x80000000,
00132 IX_V_ALL = 0xFFFFFFFF
00133 } ix_verbose_e;
00134
00142 void ix_log( unsigned long flag, char *text, ... );
00143
00144
00149 void ix_log_level( unsigned long int mask );
00150
00155 unsigned long int ix_log_getlevel( void );
00156
00161 void ix_log_name( char *name );
00162
00167 void ix_log_node( int node );
00168
00176 void ix_log_sys( int flag );
00177
00184 int ix_log_getsys( void );
00185
00186
00190 typedef struct ix_log_s ix_log_t;
00191
00200 ix_log_t *ix_logfac_new( char *facility, unsigned long int errlevel );
00201
00205 void ix_logfac_free( ix_log_t *plog );
00206
00213 void ix_logfac_log( ix_log_t *plog, unsigned long flag, char *text, ... );
00214
00220 void ix_logfac_level( ix_log_t *plog, unsigned long int mask );
00221
00227 unsigned long int ix_logfac_getlevel( ix_log_t *plog );
00228
00237 int ix_log_mask64( uint64_t v, char *buffer, int len );
00238
00247 int ix_log_mask32( uint32_t v, char *buffer, int len );
00248
00257 int ix_snprint( char *buffer, size_t buflen, char *str );
00258
00268 int ix_hexnprint( char *buf, size_t buflen,
00269 unsigned char *byte, size_t len );
00270
00271
00274
00275
00276
00277
00282
00291 int ix_make_udp_socket ( int port);
00292
00301 int ix_make_tcp_socket (int port);
00302
00310 int ix_make_tcp_dyn_socket ( int *port);
00311
00324 int ix_connect_remote( int socket, struct in_addr *addr, unsigned short port );
00325
00335 int ix_socket_join_multicast( int socket, struct in_addr addr );
00336
00339
00340
00341
00342
00349
00351 typedef int (*IX_LIST_CMP_FCT) (const void *, const void *);
00352
00354 typedef int (*IX_LIST_TRAVERSE_FCT) (const void *, void *);
00355
00357
00364 typedef struct ix_list_s ix_list_t;
00366
00369 typedef struct ix_list_s ix_queue_t;
00371
00374 typedef struct ix_list_s ix_stack_t;
00375
00390 ix_list_t *ix_list_new( IX_LIST_CMP_FCT cmp, void *mem, size_t size);
00391
00399 int ix_list_lock( ix_list_t *plist );
00407 int ix_list_unlock( ix_list_t *plist );
00408
00418 void *ix_list_search( ix_list_t *plist, void *ptr);
00419
00428 int ix_list_delete( ix_list_t *plist, void *ptr );
00429
00439 int ix_list_delete_ret( ix_list_t *plist, void *ptr, void **ret );
00440
00448 int ix_list_free( ix_list_t *plist );
00449
00457 int ix_list_sort( ix_list_t *plist );
00458
00467 int ix_list_insert( ix_list_t *plist, void *ptr );
00468
00480 int ix_list_add( ix_list_t *plist, void *ptr, void **pret );
00481
00489 void *ix_list_first( ix_list_t *plist );
00490
00498 void *ix_list_head( ix_list_t *plist );
00499
00507 void *ix_list_tail( ix_list_t *plist );
00508
00516 void *ix_list_last( ix_list_t *plist );
00517
00525 int ix_list_count( ix_list_t *plist );
00526
00534 int ix_list_overrun( ix_list_t *plist );
00535
00543 int ix_list_fills( ix_list_t *plist );
00544
00545
00556 int ix_list_traverse( ix_list_t *plist, IX_LIST_TRAVERSE_FCT fct, void *arg );
00557
00569 int ix_list_traverse_del( ix_list_t *plist, IX_LIST_TRAVERSE_FCT fct,
00570 void *arg );
00571
00573 #define ix_stack_new( b,c ) ix_list_new( NULL, (b), (c) )
00575 #define ix_stack_free(a) ix_list_free((a))
00577 #define ix_stack_push ix_list_insert
00579 #define ix_stack_pop ix_list_last
00580
00582 #define ix_queue_new( b,c ) ix_list_new( NULL, (b), (c) )
00584 #define ix_queue_free(a) ix_list_free((a))
00586 #define ix_queue_add ix_list_add
00588 #define ix_queue_insert ix_list_insert
00590 #define ix_queue_eat ix_list_first
00591
00592
00593
00594
00595
00596
00597
00598
00600
00603 typedef struct ix_hash_s ix_hash_t;
00604
00605 typedef struct
00606 {
00607 char *key;
00608 void *data;
00609 } ix_entry_t;
00610
00618 ix_hash_t * ix_hash_new( int nel );
00619
00624 void ix_hash_free( ix_hash_t *ph );
00625
00637 int ix_hash_add( ix_hash_t *ph, char *key, void *data, void **retdata );
00638
00647 void * ix_hash_find( ix_hash_t *ph, char *key );
00648
00649
00650
00651
00653
00661 typedef struct ix_rb_s ix_rb_t;
00662
00666 typedef enum
00667 {
00668 IX_RB_DEFAULT,
00669 IX_RB_KEEP,
00670 } ix_rb_e;
00671
00680 ix_rb_t *ix_rb_new( size_t len, int flag );
00681
00691 int ix_rb_read( ix_rb_t *prb, char *buf, int len );
00692
00702 int ix_rb_write( ix_rb_t *prb, char *buf, int len );
00703
00708 void ix_rb_free( ix_rb_t *prb );
00709
00717 int ix_rb_no( ix_rb_t *prb );
00718
00719
00722
00723
00724
00725
00726 struct ix_xfer_entry_s
00727 {
00728 unsigned long off;
00729 unsigned long len;
00730 };
00731
00732 typedef struct ix_xfer_entry_s ix_xfer_entry_t;
00733
00734 #define ix_xfer_off(__p) ((unsigned long)(__p))
00735
00736
00737 #define ix_xfer_set(x,data,xlen) \
00738 {\
00739 (x)->off = ix_xfer_off(data);\
00740 (x)->len = (xlen);\
00741 }
00742
00743
00744 #define ix_xfer_getlen(x) ((x)->len)
00745
00746
00747
00748
00749 int ix_xfer_encode( unsigned char *buf, int len, ix_xfer_entry_t *pe,
00750 unsigned long ne );
00751
00752
00753
00754 int ix_xfer_decode( unsigned char *buf, unsigned long len,
00755 ix_xfer_entry_t *pe, unsigned long ne, unsigned long *ne_read);
00756
00757
00758
00759
00760
00761
00767
00769 #define IX_KEY_LEN 54
00770
00772 #define IX_DATA_LEN 447
00773
00777 int ix_key_sizeofkey(void);
00778
00782 int ix_key_sizeofdata(void);
00783
00793 int ix_key_env_get( char *key, char *buffer, int bufferlen );
00794
00803 int ix_key_env_set( char *key, char *buffer );
00804
00812 int ix_key_env_unset( char *key );
00813
00825 int ix_key_file_get( char *path, char *key, char *buffer, int bufferlen,
00826 int *pflag );
00837 int ix_key_file_set( char *path, char *key, char *buffer, int flag );
00838
00847 int ix_key_file_unset( char *path, char *key );
00848
00856 int ix_key_file_clear( char *path );
00859
00860
00861
00862
00863
00864 int ix_key_info_set( char *key, char *table, char *buffer );
00865 int ix_key_info_unset( char *key, char *table );
00866 int ix_key_info_get( char *key, char *table,
00867 char *buffer, int bufferlen );
00868 int ix_key_info_clear( char *table );
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00890 int16_t te16( int16_t s, int flag );
00896 int32_t te32( int32_t i, int flag );
00902 int64_t te64( int64_t l, int flag );
00908 float tefloat( float in, int flag );
00914 double tedouble( double in, int flag );
00919
00920
00921
00933 int ix_daemon( char *dir );
00934
00938 void *memdup( void *src, size_t len );
00939
00943 char *ix_path(void);
00944
00948 char *ix_stralloc( char *s, int len );
00949
00954 char *ix_strncpy( char *d, char *s, int len );
00955
00957 #define IX_SPAWN_DEFAULT 0
00958
00960 #define IX_SPAWN_SESSION 1
00961
00973 pid_t ix_spawn( char *cmd, int opt, int f[3], char *env[] );
00974
00976
00985 int ix_getpidof( char *proc, pid_t pid[], int maxpid );
00986
00987 int ix_read_block( int fd, void *buffer, int len, int tio );
00988
00989 int ix_write_block( int sd, void *buffer, int len, int tio );
00993
00994
00995
01004
01007
01008 typedef struct ix_cs_s ix_cs_t;
01009
01011 typedef enum
01012 {
01013 IX_CS_FAST,
01014 IX_CS_RECURSIVE,
01015 IX_CS_ERROR,
01016 } ix_cs_e;
01017
01025 ix_cs_t * ix_cs_new( ix_cs_e cs_type );
01026
01034 int ix_cs_enter( ix_cs_t *pcs );
01035
01044 int ix_cs_tryenter( ix_cs_t *pcs );
01045
01053 int ix_cs_leave( ix_cs_t *pcs );
01054
01062 int ix_cs_free( ix_cs_t *pcs );
01065
01066
01067
01088
01094
01095 #define IX_EV_DEFAULT 0x00
01097 #define IX_EV_MANUAL 0x01
01099 #define IX_EV_CUMULATIVE 0x02
01101 #define IX_EV_INIT 0x04
01102
01104 typedef struct ix_event_s ix_event_t;
01105
01106
01108 typedef struct ix_evl_s ix_evl_t;
01109
01115 typedef int ( * IX_EVENT_HOOK_FCT)( ix_event_t *pev );
01116
01126 ix_event_t *ix_event_new( int id, int flag, void *userdata );
01127
01138 ix_event_t *ix_event_i_new( int flags, void *userdata );
01139
01147 int ix_event_set_hook( IX_EVENT_HOOK_FCT hook );
01148
01156 int ix_event_free( ix_event_t *pe );
01157
01165 ix_event_t* ix_event_get( int id );
01166
01174 int ix_event_id( ix_event_t *pev );
01175
01176
01184 int ix_event_set( ix_event_t *pe );
01185
01193 int ix_event_check( ix_event_t *pe );
01194
01202 int ix_event_isset( ix_event_t *pe );
01203
01212 int ix_event_reset( ix_event_t *pe );
01213
01214
01215
01216
01217 int ix_event_add_evl( ix_event_t *pe, struct ix_evl_s *pevl );
01218 int ix_event_del_evl( ix_event_t *pe, struct ix_evl_s *pevl );
01219
01226 void *ix_event_data( ix_event_t *pe );
01227
01234 void *ix_event_set_data( ix_event_t *pe, void *userdata );
01235
01242 int ix_event_getnewid(void);
01243
01245 #define IX_EV(id) ix_event_get((id))
01246
01248 #define IX_ID(pev) ix_event_id((pev))
01249
01252
01253
01254
01260
01270 typedef enum
01271 {
01272 IX_SEM_LOCAL = 0x01,
01273 IX_SEM_GLOBAL = 0x02,
01274 IX_SEM_FD = 0x03
01275 } ix_sem_e;
01276
01280 typedef struct ix_sem_s ix_sem_t;
01281
01291 ix_sem_t *ix_sem_new( int id, ix_sem_e mode );
01292
01299 int ix_sem_v( ix_sem_t *psem );
01300
01307 int ix_sem_p( ix_sem_t *psem );
01308
01315 int ix_sem_free( ix_sem_t *psem );
01319
01320
01321
01336 struct ix_cond_s
01337 {
01338 pthread_mutex_t mut;
01339 pthread_cond_t cond;
01340 int wait;
01341 };
01342
01346 typedef struct ix_cond_s ix_cond_t;
01347
01349 typedef int (*IX_COND_CHECK_FCT) (void *);
01350
01352 typedef int (*IX_COND_SET_FCT) (void *);
01353
01361 int ix_cond_init( ix_cond_t *psync );
01362
01370 int ix_cond_is_wait( ix_cond_t *psync );
01371
01390 int ix_cond_wait( ix_cond_t *psync, int sec, IX_COND_CHECK_FCT cond_check, void *arg );
01391
01400 void ix_cond_set( ix_cond_t *psync, IX_COND_SET_FCT cond_set, void *arg );
01401
01405
01406
01407
01413
01414 typedef struct ix_shm_s ix_shm_t;
01415
01417 typedef enum
01418 {
01419 IX_SHM_CRMP = 0x01,
01420 IX_SHM_MP = 0x02
01421 } ix_shm_type_e;
01422
01434 ix_shm_t *ix_shm_new( char *shm_name, void *adr, int len, ix_shm_type_e flag );
01435 ix_shm_t *ix_shm_new_sv( char *shm_name, void *adr, int len, ix_shm_type_e flag );
01436
01441 void ix_shm_free( ix_shm_t *psm );
01442 void ix_shm_free_sv( ix_shm_t *psm );
01443
01453 int ix_shm_adr( ix_shm_t *psm, void **padr, int *plen );
01454
01462 ix_shm_t *ix_shm_get( char *name );
01463
01466
01467
01468
01476
01477 typedef struct ix_fd_s ix_fd_t;
01478
01480 typedef enum
01481 {
01482 IX_FD_U = 0x00,
01483 IX_FD_R = 0x01,
01484 IX_FD_W = 0x02,
01485 IX_FD_E = 0x04
01486 } ix_fd_type_e;
01487
01489 typedef int ( * IX_FD_FCT)( void *userdata, ix_fd_type_e type );
01490
01504 ix_fd_t *ix_fd_new( ix_event_t *pev, int fd, int flag, IX_FD_FCT cb,
01505 void *userdata );
01506
01514 int ix_fd_free( ix_fd_t *pfd );
01515
01518
01519
01520
01527
01528 typedef int ( * IX_SIGNAL_FCT)( int signal, void *userdata );
01529
01531 typedef struct ix_signal_s ix_signal_t;
01532
01533
01544 ix_signal_t *ix_signal_new( ix_event_t *pev, int signal, IX_SIGNAL_FCT cb,
01545 void *userdata );
01546
01554 int ix_signal_free( ix_signal_t *psig );
01555
01560
01561
01562
01578
01579 typedef struct ix_evs_s ix_evs_t;
01580
01587 ix_evs_t *ix_evs_new();
01588
01597 int ix_evs_free( ix_evs_t *pevs );
01598
01610 int ix_evs_wait( ix_evs_t *mask, ix_evs_t *result, int msec );
01611
01620 ix_event_t * ix_evs_add( ix_evs_t *pevs, ix_event_t * pev );
01621
01630 int ix_evs_isset( ix_evs_t *pevs, ix_event_t *pev );
01631
01640 ix_event_t * ix_evs_rem( ix_evs_t *pevs, ix_event_t * pev);
01641
01649 ix_event_t * ix_evs_pop( ix_evs_t *pevs );
01650
01658 int ix_evs_clear( ix_evs_t *pevs );
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673
01674 int ix_event_cluster_wait( ix_evs_t *pevs, int evn, unsigned int mask );
01675
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685 int ix_event_cluster_isset( int evn, unsigned int mask );
01686
01687
01688
01689
01690
01691
01692
01693
01694
01695
01696 int ix_event_cluster_read( int evn, unsigned int *state );
01697
01698
01699
01700
01701
01702
01703
01704
01705 int ix_event_cluster_set( int evn );
01706
01707
01708
01709
01710
01716
01717 typedef void * ( * IX_START_FCT)(void *);
01718
01720 typedef void ( * IX_EXIT_FCT)(void *pt);
01721
01723 typedef struct ix_thread_s ix_thread_t;
01724
01725
01737 ix_thread_t *ix_thread_new( IX_START_FCT sfct, IX_EXIT_FCT efct,
01738 void *parg, char *name );
01739
01747 int ix_thread_stop( ix_thread_t *pt );
01748
01749
01755 void ix_thread_exit( ix_thread_t *pt );
01756
01761 void ix_thread_free( ix_thread_t *pt );
01762
01763
01771 void *ix_thread_getarg( ix_thread_t *pt );
01772
01779 char *ix_thread_getname( ix_thread_t *pt );
01780
01783
01784
01785
01786
01787
01788
01789 typedef struct ix_appl_s ix_appl_t;
01790
01791
01792
01793
01806
01807 typedef enum
01808 {
01810 IX_TIMER_ABSOLUTE = 0x20,
01812 IX_TIMER_PERIODIC = 0x40,
01814 IX_TIMER_ONESHOT = 0x80,
01816 IX_TIMER_NORMAL = 0x100
01817 } ix_timer_type_e;
01818
01820 typedef struct ix_timer_s ix_timer_t;
01821
01823 typedef struct itimerval ix_timer_val_t;
01824
01825
01836 int ix_timer_val_init( ix_timer_val_t *ptv, int v_sec, int v_usec,
01837 int i_sec, int i_usec );
01838
01843 void ix_get_timenow( struct timeval *ptv );
01844
01852 struct timeval ix_timer_add( struct timeval *pt1, struct timeval *pt2 );
01853
01869 ix_timer_t *ix_timer_new( ix_event_t *pev, ix_timer_type_e type,
01870 unsigned long userid, void (*cb)(void *parg), void *parg,
01871
01872 ix_timer_val_t *pitv );
01873
01881 int ix_timer_free( ix_timer_t *pt );
01882
01892 int ix_timer_cancel( ix_timer_t *pt );
01893
01904 int ix_timer_restart( ix_timer_t *pt, ix_event_t *pev, ix_timer_type_e type,
01905
01906 ix_timer_val_t *pitv );
01907
01916 int ix_timer_id_free( unsigned long id );
01917
01920
01921
01922
01927
01931 typedef struct
01932 {
01933 union
01934 {
01935 unsigned char *pbuf;
01936 long long int align;
01937 };
01938 unsigned int buflen;
01939 unsigned int len;
01940 } ix_buffer_t;
01941
01950 ix_buffer_t *ix_buffer_new( unsigned char *pbuf, unsigned int len );
01951
01960 int ix_buffer_resize( ix_buffer_t *pb, unsigned int len );
01961
01969 unsigned char * ix_buffer_reset( ix_buffer_t *pb );
01970
01977 unsigned char * ix_buffer_renew( ix_buffer_t *pb );
01978
01988 int ix_buffer_add( ix_buffer_t *pb, char *padr, size_t len );
01989
01997 int ix_buffer_len( ix_buffer_t *pb );
01998
02007 unsigned char * ix_buffer_freeadr( ix_buffer_t *pb, unsigned int *pfree );
02008
02016 unsigned char * ix_buffer_adr( ix_buffer_t *pb );
02017
02018
02023 void ix_buffer_free( ix_buffer_t *pb );
02024
02027
02028
02029
02039
02040 typedef struct ix_msg_queue_s ix_msg_queue_t;
02041
02049 ix_msg_queue_t * ix_msg_queue_new( ix_event_t *pev );
02050
02059 ix_msg_queue_t * ix_msg_queue_size_new( ix_event_t *pev, size_t size );
02060
02069 int ix_msg_queue_overrun( ix_msg_queue_t *pmq );
02070
02079 int ix_msg_queue_count( ix_msg_queue_t *pmq );
02080
02085 void ix_msg_queue_free( ix_msg_queue_t *pmq );
02086
02094 void *ix_msg_queue_eat( ix_msg_queue_t *pmq );
02095
02105 int ix_msg_queue_add( ix_msg_queue_t *pmq, void *pb, void **pret );
02108
02109
02110
02124 typedef struct ix_qio_s ix_qio_t;
02125
02129 typedef enum
02130 {
02131 IX_QIO_MAXLEN = 0x01,
02132 IX_QIO_DELIM = 0x02
02133 } ix_qio_ctrl_e;
02134
02138 typedef union
02139 {
02140 int maxlen;
02141 char *delim;
02142 } ix_qio_ctrl_t;
02143
02147 typedef enum
02148 {
02149 IX_QIO_HOOK_BUFFER_REUSE = 0x01,
02150 IX_QIO_HOOK_BUFFER_LOCKED = 0x02,
02151 IX_QIO_HOOK_ERROR = 0xF0000
02152 } ix_qio_hook_e;
02153
02164 typedef ix_qio_hook_e ( *IX_QIO_SAVE_FCT )( unsigned char *input, int len, void *userarg );
02165
02176 ix_qio_t * ix_qio_new( int fd, int ctrl_tag, ix_qio_ctrl_t ctrl_info,
02177 size_t maxlen );
02178
02187 int ix_qio_reopen(ix_qio_t *pqio, int fd );
02188
02201 int ix_qio_receive( ix_qio_t *pqio, IX_QIO_SAVE_FCT save_fct, void *userarg );
02202
02214 int ix_qio_msg( ix_qio_t *pqio, ix_msg_queue_t *pmq );
02215
02225 ix_msg_queue_t * ix_qio_getmsg( ix_qio_t *pqio );
02226
02235 int ix_qio_issetup( ix_qio_t *pqio );
02236
02244 int ix_qio_isvalid( ix_qio_t *pqio );
02245
02255 int ix_qio_getfd( ix_qio_t *pqio );
02256
02261 void ix_qio_free( ix_qio_t *pqio );
02262
02278
02279
02280
02290
02291 #define IX_PROCNAME_LEN 12
02292
02296 typedef struct
02297 {
02298 struct in_addr addr;
02299 unsigned short nport;
02300 char proc[IX_PROCNAME_LEN];
02301 unsigned int nnode;
02302 } ix_adr_t;
02303
02312 int ix_adr_init( ix_adr_t *padr, char *hostip, unsigned short hport );
02313
02322 int ix_adr_initin( ix_adr_t *padr, void *ip, unsigned short hport );
02323
02330 int ix_adr_ip( ix_adr_t *padr, char *ip, int len );
02331
02338 int ix_adr_port( ix_adr_t *padr );
02339
02346 int ix_adr_getip( ix_adr_t *padr, void *ip );
02347
02354 int ix_adr_getnode( ix_adr_t *padr );
02355
02362 char *ix_adr_getproc( ix_adr_t *padr );
02363
02372 char *ix_adr_getnodeproc( ix_adr_t *padr, char *buf, int buflen );
02373
02374
02381 int ix_adr_str( ix_adr_t *padr, char *str, int len );
02382
02388 char *ix_adr_str2( ix_adr_t *padr, char *str, int len );
02389
02390
02397 int ix_adr_hostandport( ix_adr_t *padr, char *str, int len );
02398
02406 void ix_adr_proc( ix_adr_t *padr, char *proc, int node );
02407
02408
02409
02410
02411
02412
02417 typedef struct ix_netinfo_s
02418 {
02419 int flag;
02420 int socket;
02421 } ix_netinfo_t;
02422
02426 typedef struct ix_net_s ix_net_t;
02427
02437 ix_net_t *ix_net_new( char *tohost, unsigned short toport );
02438
02445 void ix_net_free( ix_net_t *pnet );
02446
02453 int ix_net_setto( ix_net_t *pnet, ix_adr_t *toadr );
02454
02461 typedef int( * IX_SERVER_DISCONNECT_FCT)( ix_adr_t *padr, int fd );
02462
02463
02471 int ix_net_setcb( ix_net_t *pnet, IX_SERVER_DISCONNECT_FCT cb );
02472
02476 int ix_net_event( ix_net_t *pnet, unsigned int evid );
02477
02484 int ix_net_trigger( ix_net_t *pnet, unsigned int evid );
02485
02493 int ix_net_send( ix_net_t *pnet );
02494
02503 int ix_tcp_packet( int sd, ix_net_t *pnet );
02504
02505
02509 int ix_udp_msg( ix_net_t *pnet, unsigned char *buf, int buflen );
02510
02522 int ix_tcp_msg( ix_net_t *pnet, unsigned char *buf, int buflen );
02523
02536 int ix_send( ix_net_t *pnet, unsigned char *buf, int buflen, ix_net_t *preply);
02537
02542 ix_buffer_t *ix_net_getmsg( ix_net_t *pnet );
02543
02548 ix_adr_t *ix_net_getfrom( ix_net_t *pnet );
02549
02554 ix_adr_t *ix_net_getto( ix_net_t *pnet );
02555
02560 ix_netinfo_t *ix_net_getinfo( ix_net_t *pnet );
02561
02568 int ix_net_setinfo( ix_net_t *pnet, ix_netinfo_t *pinfo );
02569
02576 int ix_net_tef( ix_net_t *pnet );
02577
02581
02582
02583
02588
02589
02590
02598 int ix_set_name( char *proc_name );
02599
02605 char *ix_get_name( void );
02606
02613 int ix_set_node( int node );
02614
02620 int ix_get_node( void );
02621
02630
02631
02632
02633
02634
02640 typedef struct ix_tcp_client_s ix_tcp_client_t;
02641
02645 int ix_connect_udp( unsigned short myport );
02646
02654 int ix_connect_tcp( int myport );
02655
02662 int ix_tcp_get_port( void );
02663
02671 ix_adr_t *ix_tcp_client_getsender( ix_tcp_client_t *pcl );
02672
02680 int ix_tcp_client_getfd( ix_tcp_client_t *pcl );
02681
02689 int ix_tcp_client_isdata( ix_tcp_client_t *pcl );
02690
02691
02699 int ix_tcp_client_cs_enter( ix_tcp_client_t *pcl );
02700
02708 int ix_tcp_client_cs_leave( ix_tcp_client_t *pcl );
02709
02718 int ix_tcp_client_setuserdata( ix_tcp_client_t *pcl, void *data );
02719
02727 void *ix_tcp_client_getuserdata( ix_tcp_client_t *pcl );
02728
02736 int ix_tcp_client_rm_byfd( int fd );
02737
02745 int ix_tcp_client_rm( ix_tcp_client_t *ptcp );
02746
02747
02748 #define IX_TCP_CLIENT_PERMANENT 0
02749
02759 int ix_tcp_client_set_timeout_byfd( int fd, int timeout );
02760
02771 int ix_tcp_client_set_timeout( ix_tcp_client_t *ptcp, int timeout );
02772
02773
02783 typedef int ( *IX_AST_PACKET_FCT)( ix_net_t *pnet );
02784
02794 int ix_ast_receive( IX_AST_PACKET_FCT fct );
02795
02807 int ix_ast_add_hook( int key, IX_AST_PACKET_FCT hook );
02808
02821 ix_net_t *ix_receive(void);
02822
02823
02831 typedef int ( * IX_CLIENT_CONNECT_FCT)( ix_tcp_client_t *pcl );
02832
02840 int ix_set_client_connect_cb( IX_CLIENT_CONNECT_FCT cb );
02841
02842
02859 typedef int ( * IX_CLIENT_REPLY_FCT)( ix_tcp_client_t *pcl,
02860 unsigned char *sendbuf, int sendbuflen, unsigned char *replybuf, int replybuflen );
02868 int ix_set_client_reply_cb( IX_CLIENT_REPLY_FCT cb );
02869
02881 typedef int ( * IX_CLIENT_DATA_FCT)( ix_tcp_client_t *pcl );
02882
02890 int ix_set_client_data_cb( IX_CLIENT_DATA_FCT cb );
02891
02892
02900 typedef int( * IX_CLIENT_DISCONNECT_FCT)( ix_tcp_client_t *pcl );
02901
02909 int ix_set_client_disconnect_cb( IX_CLIENT_DISCONNECT_FCT cb );
02920
02930 int ix_set_server_disconnect_cb( IX_SERVER_DISCONNECT_FCT cb );
02931
02932
02941 int ix_open_data( struct in_addr *addr, unsigned short port );
02942
02950
02957 int ix_init( void );
02958
02963 #ifdef __cplusplus
02964 }
02965 #endif
02966
02967
02968 #endif