Added silc_mime_steal_data.
@LINK=silcmemory.html:SILC Memory Interface
@LINK=silcthread.html:SILC Thread Interface
@LINK=silcmutex.html:SILC Mutex Interface
-@LINK=silccondvar.html:SILC Conditional Variable Interface
+@LINK=silccond.html:SILC Conditional Variable Interface
@LINK=silcnet.html:SILC Network Interface
@LINK=silcschedule.html:SILC Schedule Interface
@LINK=silcsockconn.html:SILC Socket Interface
/*
- silccondvar.h
+ silccond.h
Author: Pekka Riikonen <priikone@silcnet.org>
*
***/
-#ifndef SILCCONDVAR_H
-#define SILCCONDVAR_H
+#ifndef SILCCOND_H
+#define SILCCOND_H
-/****s* silcutil/SilcCondVarAPI/SilcCondVar
+/****s* silcutil/SilcCondAPI/SilcCond
*
* NAME
*
- * typedef struct SilcCondVarStruct *SilcCondVar;
+ * typedef struct SilcCondStruct *SilcCond;
*
* DESCRIPTION
*
* This context is the actual conditional variable and is allocated
- * by silc_condvar_alloc and given as argument to all silc_condvar_*
- * functions. It is freed by the silc_condvar_free function.
+ * by silc_cond_alloc and given as argument to all silc_cond_*
+ * functions. It is freed by the silc_cond_free function.
*
***/
-typedef struct SilcCondVarStruct *SilcCondVar;
+typedef struct SilcCondStruct *SilcCond;
-/****s* silcutil/SilcCondVarAPI/silc_condvar_alloc
+/****s* silcutil/SilcCondAPI/silc_cond_alloc
*
* SYNOPSIS
*
- * SilcBool silc_condvar_alloc(SilcCondVar *cond);
+ * SilcBool silc_cond_alloc(SilcCond *cond);
*
* DESCRIPTION
*
* Allocates SILC Conditional variable context. The conditional must
* be allocated before it can be used. It is freed by the
- * silc_condvar_free function. This returns TRUE and allocated
+ * silc_cond_free function. This returns TRUE and allocated
* conditional in to the `cond' pointer and FALSE on error.
*
***/
-SilcBool silc_condvar_alloc(SilcCondVar *cond);
+SilcBool silc_cond_alloc(SilcCond *cond);
-/****s* silcutil/SilcCondVarAPI/silc_condvar_free
+/****s* silcutil/SilcCondAPI/silc_cond_free
*
* SYNOPSIS
*
- * void silc_condvar_free(SilcCondVar cond);
+ * void silc_cond_free(SilcCond cond);
*
* DESCRIPTION
*
* has no effect.
*
***/
-void silc_condvar_free(SilcCondVar cond);
+void silc_cond_free(SilcCond cond);
-/****s* silcutil/SilcCondVarAPI/silc_condvar_wait
+/****s* silcutil/SilcCondAPI/silc_cond_wait
*
* SYNOPSIS
*
- * void silc_condvar_wait(SilcCondVar cond, SilcMutex mutex);
+ * void silc_cond_wait(SilcCond cond, SilcMutex mutex);
*
* DESCRIPTION
*
*
* silc_mutex_lock(lock);
* while (c->a == NULL)
- * silc_condvar_wait(cond, lock);
+ * silc_cond_wait(cond, lock);
* ...
* silc_mutex_unlock(lock);
*
***/
-void silc_condvar_wait(SilcCondVar cond, SilcMutex mutex);
+void silc_cond_wait(SilcCond cond, SilcMutex mutex);
-/****s* silcutil/SilcCondVarAPI/silc_condvar_timedwait
+/****s* silcutil/SilcCondAPI/silc_cond_timedwait
*
* SYNOPSIS
*
- * void silc_condvar_timedwait(SilcCondVar cond, SilcMutex mutex,
- * struct timespec *timeout);
+ * void silc_cond_timedwait(SilcCond cond, SilcMutex mutex, int timeout);
*
* DESCRIPTION
*
* state again.
*
***/
-SilcBool silc_condvar_timedwait(SilcCondVar cond, SilcMutex mutex,
- int timeout);
+SilcBool silc_cond_timedwait(SilcCond cond, SilcMutex mutex, int timeout);
-/****s* silcutil/SilcCondVarAPI/silc_condvar_signal
+/****s* silcutil/SilcCondAPI/silc_cond_signal
*
* SYNOPSIS
*
- * void silc_condvar_signal(SilcCondVar cond);
+ * void silc_cond_signal(SilcCond cond);
*
* DESCRIPTION
*
* Signals a waiting thread and wakes it up. If there are no waiters
* this function has no effect. In case of multiple waiters only one
- * is signalled. To signal all of them use silc_condvar_broadcast.
+ * is signalled. To signal all of them use silc_cond_broadcast.
*
* NOTES
*
- * Before calling this function the mutex used with the silc_condvar_wait
+ * Before calling this function the mutex used with the silc_cond_wait
* must be acquired.
*
* EXAMPLE
*
* silc_mutex_lock(lock);
* c->a = context;
- * silc_condvar_signal(cond);
+ * silc_cond_signal(cond);
* silc_mutex_unlock(lock);
*
***/
-void silc_condvar_signal(SilcCondVar cond);
+void silc_cond_signal(SilcCond cond);
-/****s* silcutil/SilcCondVarAPI/silc_condvar_broadcast
+/****s* silcutil/SilcCondAPI/silc_cond_broadcast
*
* SYNOPSIS
*
- * void silc_condvar_broadcast(SilcCondVar cond);
+ * void silc_cond_broadcast(SilcCond cond);
*
* DESCRIPTION
*
*
* NOTES
*
- * Before calling this function the mutex used with the silc_condvar_wait
+ * Before calling this function the mutex used with the silc_cond_wait
* must be acquired.
*
***/
-void silc_condvar_broadcast(SilcCondVar cond);
+void silc_cond_broadcast(SilcCond cond);
-#endif /* SILCCONDVAR_H */
+#endif /* SILCCOND_H */
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2005 Pekka Riikonen
+ Copyright (C) 2005 - 2006 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
return mime->data;
}
+/* Steal data */
+
+unsigned char *silc_mime_steal_data(SilcMime mime, SilcUInt32 *data_len)
+{
+ unsigned char *data;
+
+ if (!mime)
+ return NULL;
+
+ if (data_len)
+ *data_len = mime->data_len;
+
+ data = mime->data;
+
+ mime->data = NULL;
+ mime->data_len = 0;
+
+ return data;
+}
+
/* Returns TRUE if partial message */
SilcBool silc_mime_is_partial(SilcMime mime)
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2005 Pekka Riikonen
+ Copyright (C) 2005 - 2006 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
***/
const unsigned char *silc_mime_get_data(SilcMime mime, SilcUInt32 *data_len);
+/****f* silcutil/SILCMIMEAPI/silc_mime_steal_data
+ *
+ * SYNOPSIS
+ *
+ * unsigned char *
+ * silc_mime_steal_data(SilcMime mime, SilcUInt32 *data_len);
+ *
+ * DESCRIPTION
+ *
+ * Returns the MIME data from the `mime' message. The data will be
+ * removed from the `mime' and the caller is responsible of freeing the
+ * returned pointer.
+ *
+ ***/
+unsigned char *silc_mime_steal_data(SilcMime mime, SilcUInt32 *data_len);
+
/****f* silcutil/SILCMIMEAPI/silc_mime_is_partial
*
* SYNOPSIS
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2005 Pekka Riikonen
+ Copyright (C) 2005 - 2006 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*
* Callback function of this type is called after the socket stream
* creation is completed. If the `stream' is NULL the socket stream could
- * not be created of the socket connection is not otherwise allowed. The
+ * not be created or the socket connection is not otherwise allowed. The
* `status' will indicate the error status. The `stream' is socket stream
* representing the socket connection and silc_socket_stream_* functions
* can be used to access the stream. All other silc_stream_* functions
* and silc_stream_read. The creation process is asynchronous since
* socket connection information, such as hostname and IP address are
* resolved, so SilcAsyncOperation is returned which can be used to cancel
- * the creationg process. The `callback' will be called to return the
+ * the creation process. The `callback' will be called to return the
* created socket stream. To destroy the stream call silc_stream_destroy.
*
* If the `lookup' is TRUE then this will performed IP and hostname lookup
SilcSocketStreamCallback callback,
void *context);
+SilcAsyncOperation
+silc_socket_tcp_stream_create(int sock, SilcBool lookup,
+ SilcBool require_fqdn,
+ SilcSchedule schedule,
+ SilcSocketStreamCallback callback,
+ void *context);
+
+SilcAsyncOperation
+silc_socket_udp_stream_create(int sock, SilcBool lookup,
+ SilcBool require_fqdn,
+ SilcSchedule schedule,
+ SilcSocketStreamCallback callback,
+ void *context);
+
/****f* silcutil/SilcSocketStreamAPI/silc_socket_stream_get_info
*
* SYNOPSIS
}
-/**************************** SILC CondVar API ******************************/
+/**************************** SILC Cond API ******************************/
/* SILC Conditional Variable context */
-struct SilcCondVarStruct {
+struct SilcCondStruct {
#ifdef SILC_THREADS
pthread_cond_t cond;
#else
#endif /* SILC_THREADS*/
};
-SilcBool silc_condvar_alloc(SilcCondVar *cond)
+SilcBool silc_cond_alloc(SilcCond *cond)
{
#ifdef SILC_THREADS
*cond = silc_calloc(1, sizeof(**cond));
#endif /* SILC_THREADS*/
}
-void silc_condvar_free(SilcCondVar cond)
+void silc_cond_free(SilcCond cond)
{
#ifdef SILC_THREADS
pthread_cond_destroy(&cond->cond);
#endif /* SILC_THREADS*/
}
-void silc_condvar_signal(SilcCondVar cond)
+void silc_cond_signal(SilcCond cond)
{
#ifdef SILC_THREADS
pthread_cond_signal(&cond->cond);
#endif /* SILC_THREADS*/
}
-void silc_condvar_broadcast(SilcCondVar cond)
+void silc_cond_broadcast(SilcCond cond)
{
#ifdef SILC_THREADS
pthread_cond_broadcast(&cond->cond);
#endif /* SILC_THREADS*/
}
-void silc_condvar_wait(SilcCondVar cond, SilcMutex mutex)
+void silc_cond_wait(SilcCond cond, SilcMutex mutex)
{
#ifdef SILC_THREADS
pthread_cond_wait(&cond->cond, &mutex->mutex);
#endif /* SILC_THREADS*/
}
-SilcBool silc_condvar_timedwait(SilcCondVar cond, SilcMutex mutex,
- int timeout)
+SilcBool silc_cond_timedwait(SilcCond cond, SilcMutex mutex,
+ int timeout)
{
#ifdef SILC_THREADS
struct timespec t;
}
-/**************************** SILC CondVar API ******************************/
+/**************************** SILC Cond API ******************************/
/* SILC Conditional Variable context */
-struct SilcCondVarStruct {
+struct SilcCondStruct {
#ifdef SILC_THREADS
HANDLE event;
#endif /* SILC_THREADS*/
unsigned int signal : 1;
};
-SilcBool silc_condvar_alloc(SilcCondVar *cond)
+SilcBool silc_cond_alloc(SilcCond *cond)
{
#ifdef SILC_THREADS
*cond = silc_calloc(1, sizeof(**cond));
#endif /* SILC_THREADS*/
}
-void silc_condvar_free(SilcCondVar cond)
+void silc_cond_free(SilcCond cond)
{
#ifdef SILC_THREADS
CloseHandle(cond->event);
#endif /* SILC_THREADS*/
}
-void silc_condvar_signal(SilcCondVar cond)
+void silc_cond_signal(SilcCond cond)
{
#ifdef SILC_THREADS
cond->signal = TRUE;
#endif /* SILC_THREADS*/
}
-void silc_condvar_broadcast(SilcCondVar cond)
+void silc_cond_broadcast(SilcCond cond)
{
#ifdef SILC_THREADS
cond->signal = TRUE;
#endif /* SILC_THREADS*/
}
-void silc_condvar_wait(SilcCondVar cond, SilcMutex mutex)
+void silc_cond_wait(SilcCond cond, SilcMutex mutex)
{
#ifdef SILC_THREADS
- silc_condvar_timedwait(cond, mutex, NULL);
+ silc_cond_timedwait(cond, mutex, NULL);
#endif /* SILC_THREADS*/
}
-SilcBool silc_condvar_timedwait(SilcCondVar cond, SilcMutex mutex,
- int timeout)
+SilcBool silc_cond_timedwait(SilcCond cond, SilcMutex mutex,
+ int timeout)
{
#ifdef SILC_THREADS
DWORD ret, t = INFINITE;