From de2519091c6226ee44eb2fa6935bae2f4f5df44d Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sat, 21 Oct 2006 13:44:01 +0000 Subject: [PATCH] updates. --- lib/silcutil/DIRECTORY | 48 +++++++++++++++----------- lib/silcutil/tests/test_silcatomic.c | 5 +++ lib/silcutil/tests/test_silcfdstream.c | 2 +- lib/silcutil/tests/test_silcnet.c | 24 ++++++------- 4 files changed, 45 insertions(+), 34 deletions(-) diff --git a/lib/silcutil/DIRECTORY b/lib/silcutil/DIRECTORY index 3a7301ae..2b334d5e 100644 --- a/lib/silcutil/DIRECTORY +++ b/lib/silcutil/DIRECTORY @@ -2,27 +2,33 @@ @LIBRARY=SILC Utility Library @FILENAME=silcutillib.html @LINK=silctypes.html:Basic SILC Types -@LINK=silcbuffer.html:SILC Buffer Interface -@LINK=silcbuffmt.html:SILC Buffer Format Interface -@LINK=silchashtable.html:SILC Hash Table Interface -@LINK=silclog.html:SILC Logging Interface -@LINK=silcmemory.html:SILC Memory Interface -@LINK=silcthread.html:SILC Thread Interface -@LINK=silcmutex.html:SILC Mutex Interface -@LINK=silccond.html:SILC Conditional Variable Interface -@LINK=silcatomic.html:SILC Atomic Operations Interface -@LINK=silcnet.html:SILC Network Interface -@LINK=silcschedule.html:SILC Schedule Interface -@LINK=silcsockconn.html:SILC Socket Interface -@LINK=silcprotocol.html:SILC Protocol Interface -@LINK=silcconfig.html:SILC Config Interface -@LINK=silcfileutil.html:SILC File Util Interface -@LINK=silcstrutil.html:SILC String Util Interface -@LINK=silcutf8.html:SILC UTF-8 Interface -@LINK=silcstringprep.html:SILC Stringprep Interface -@LINK=silcutil.html:SILC Util Interface -@LINK=silclist.html:SILC List Interface -@LINK=silcdlist.html:SILC Dynamic List Interface +@LINK=silcbuffer.html:Data Buffer Interface +@LINK=silcbuffmt.html:Data Buffer Format Interface +@LINK=silchashtable.html:Hash Table Interface +@LINK=silcmemory.html:Memory Allocation Interface +@LINK=silcstack.html:Data Stack (memory pool) Interface +@LINK=silcthread.html:Thread Interface +@LINK=silcmutex.html:Mutual Exclusion Lock Interface +@LINK=silccond.html:Conditional Variable Interface +@LINK=silcatomic.html:Atomic Operations Interface +@LINK=silcnet.html:Network (TCP and UDP) Interface +@LINK=silcschedule.html:Scheduler Interface +@LINK=silcsocketstream.html:Socket Stream Interface +@LINK=silcfdstream.html:File Descriptor Stream Interface +@LINK=silcstream.html:Abstract Stream Interface +@LINK=silcfsm.html:Finite State Machine Interface +@LINK=silcfileutil.html:File Utility Functions +@LINK=silcstrutil.html:String Utility Interface +@LINK=silcutf8.html:UTF-8 String Interface +@LINK=silcstringprep.html:Stringprep Interface +@LINK=silcutil.html:Utility Functions +@LINK=silclist.html:List Interface +@LINK=silcdlist.html:Dynamic List Interface +@LINK=silcasync.html:Asynchronous Operation Interface +@LINK=silcmime.html:MIME Interface +@LINK=silctime.html:Time Utility Functions +@LINK=silclog.html:Logging Interface +@LINK=silcconfig.html:Config File Interface --> SILC Utility Library diff --git a/lib/silcutil/tests/test_silcatomic.c b/lib/silcutil/tests/test_silcatomic.c index dc2bac6e..feaf2895 100644 --- a/lib/silcutil/tests/test_silcatomic.c +++ b/lib/silcutil/tests/test_silcatomic.c @@ -39,6 +39,11 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Current value: %d (-513)", silc_atomic_get_int(&ref))); + SILC_LOG_DEBUG(("Swapping -513 with 8739200")); + if (!silc_atomic_cas(&ref, silc_atomic_get_int(&ref), 8739200)) + goto err; + SILC_LOG_DEBUG(("Current value: %d (8739200)", silc_atomic_get_int(&ref))); + silc_atomic_uninit(&ref); success = TRUE; diff --git a/lib/silcutil/tests/test_silcfdstream.c b/lib/silcutil/tests/test_silcfdstream.c index fad7a6dd..e4d53a59 100644 --- a/lib/silcutil/tests/test_silcfdstream.c +++ b/lib/silcutil/tests/test_silcfdstream.c @@ -199,7 +199,7 @@ int main(int argc, char **argv) if (argc > 1 && !strcmp(argv[1], "-d")) { silc_log_debug(TRUE); silc_log_debug_hexdump(TRUE); - silc_log_set_debug_string("fdstream*"); + silc_log_set_debug_string("*fdstream*"); } SILC_LOG_DEBUG(("Allocating scheduler")); diff --git a/lib/silcutil/tests/test_silcnet.c b/lib/silcutil/tests/test_silcnet.c index 19d90a04..91585858 100644 --- a/lib/silcutil/tests/test_silcnet.c +++ b/lib/silcutil/tests/test_silcnet.c @@ -8,7 +8,7 @@ typedef struct { SilcFSM fsm; SilcFSMSemaStruct sema; SilcFSMThreadStruct thread; - SilcNetServer server; + SilcNetListener server; SilcStream client_stream; SilcNetStatus client_status; SilcStream server_stream; @@ -50,7 +50,7 @@ SILC_FSM_STATE(test_st_connect) SILC_LOG_DEBUG(("test_st_connect")); SILC_LOG_DEBUG(("Connecting to server")); - silc_fsm_next(fsm, test_st_connected, NULL); + silc_fsm_next(fsm, test_st_connected); SILC_FSM_CALL(silc_net_tcp_connect(NULL, "localhost", 5000, silc_fsm_get_schedule(fsm), test_connected, f)); @@ -82,24 +82,24 @@ SILC_FSM_STATE(test_st_start) SILC_LOG_DEBUG(("test_st_start")); SILC_LOG_DEBUG(("Creating network listener")); - f->server = silc_net_create_server(NULL, 0, 5000, FALSE, + f->server = silc_net_tcp_create_listener(NULL, 0, 5000, TRUE, TRUE, silc_fsm_get_schedule(fsm), test_accept_connection, f); if (!f->server) { /** Creating network listener failed */ SILC_LOG_DEBUG(("Listener creation failed")); - silc_fsm_next(fsm, test_st_finish, NULL); + silc_fsm_next(fsm, test_st_finish); return SILC_FSM_CONTINUE; } /* Create thread to connect to the listener */ silc_fsm_thread_init(&f->thread, fsm, f, NULL, NULL, FALSE); - silc_fsm_start(&f->thread, test_st_connect, NULL); + silc_fsm_start(&f->thread, test_st_connect); /** Start waiting connection */ SILC_LOG_DEBUG(("Start waiting for incoming connections")); silc_fsm_sema_init(&f->sema, fsm, 0); - silc_fsm_next(fsm, test_st_second, NULL); + silc_fsm_next(fsm, test_st_second); return SILC_FSM_CONTINUE; } @@ -116,17 +116,17 @@ SILC_FSM_STATE(test_st_second) if (f->client_status != SILC_NET_OK) { /** Accepting new connection failed */ SILC_LOG_DEBUG(("Accepting failed %d", f->client_status)); - silc_fsm_next(fsm, test_st_finish, NULL); + silc_fsm_next(fsm, test_st_finish); return SILC_FSM_CONTINUE; } silc_socket_stream_get_info(f->client_stream, NULL, &host, &ip, &port); SILC_LOG_DEBUG(("Accepted new connection %s, %s:%d", host, ip, port)); - /** Finish */ + /** Wait thread to terminate */ f->success = TRUE; - silc_fsm_next(fsm, test_st_finish, NULL); - return SILC_FSM_CONTINUE; + silc_fsm_next(fsm, test_st_finish); + SILC_FSM_THREAD_WAIT(&f->thread); } SILC_FSM_STATE(test_st_finish) @@ -145,7 +145,7 @@ SILC_FSM_STATE(test_st_finish) } SILC_LOG_DEBUG(("Closing network listener")); - silc_net_close_server(f->server); + silc_net_close_listener(f->server); SILC_LOG_DEBUG(("Finish machine")); return SILC_FSM_FINISH; @@ -182,7 +182,7 @@ int main(int argc, char **argv) fsm = silc_fsm_alloc(f, destructor, NULL, schedule); if (!fsm) goto err; - silc_fsm_start(fsm, test_st_start, NULL); + silc_fsm_start(fsm, test_st_start); f->fsm = fsm; SILC_LOG_DEBUG(("Running scheduler")); -- 2.24.0