I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 2547d4b3 authored by mpc's avatar mpc Committed by zzz
Browse files

*** empty log message ***

parent 892786bf
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,7 @@ extern "C" { ...@@ -35,6 +35,7 @@ extern "C" {
#endif #endif
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h>
#include <stdint.h> #include <stdint.h>
/* /*
......
...@@ -122,8 +122,7 @@ bool sam_close(sam_sess_t *session) ...@@ -122,8 +122,7 @@ bool sam_close(sam_sess_t *session)
* tunneldepth - length of the I2P tunnels created by this program (longer is * tunneldepth - length of the I2P tunnels created by this program (longer is
* more anonymous, but slower) * more anonymous, but slower)
* *
* Returns: True on success, false on failure. If true, `session' will be ready * Returns: SAM error code. If SAM_OK, `session' will be ready for use.
* for use.
*/ */
samerr_t sam_connect(sam_sess_t *session, const char *samhost, uint16_t samport, samerr_t sam_connect(sam_sess_t *session, const char *samhost, uint16_t samport,
const char *destname, sam_conn_t style, uint_t tunneldepth) const char *destname, sam_conn_t style, uint_t tunneldepth)
...@@ -791,39 +790,6 @@ void sam_sendq_flush(sam_sess_t *session, sam_sid_t stream_id, ...@@ -791,39 +790,6 @@ void sam_sendq_flush(sam_sess_t *session, sam_sid_t stream_id,
return; return;
} }
/*
* Allocates memory for the session and sets its default values
*
* session - pointer to a previously allocated sam_sess_t to initalise, or NULL
* if you want memory to be allocated by this function
*/
sam_sess_t *sam_session_init(sam_sess_t *session)
{
if (session == NULL) {
session = malloc(sizeof(sam_sess_t));
if (session == NULL) {
SAMLOGS("Out of memory");
abort();
}
}
session->connected = false;
session->prev_id = 0;
return session;
}
/*
* Frees memory used by the session and sets the pointer to NULL
*
* session - pointer to a pointer to a sam_sess_t
*/
void sam_session_free(sam_sess_t **session)
{
assert(*session != NULL);
free(*session);
*session = NULL;
}
/* /*
* Sends the second SAM handshake command and checks the reply * Sends the second SAM handshake command and checks the reply
* *
...@@ -880,6 +846,39 @@ static samerr_t sam_session_create(sam_sess_t *session, const char *destname, ...@@ -880,6 +846,39 @@ static samerr_t sam_session_create(sam_sess_t *session, const char *destname,
return SAM_UNKNOWN; return SAM_UNKNOWN;
} }
/*
* Allocates memory for the session and sets its default values
*
* session - pointer to a previously allocated sam_sess_t to initalise, or NULL
* if you want memory to be allocated by this function
*/
sam_sess_t *sam_session_init(sam_sess_t *session)
{
if (session == NULL) {
session = malloc(sizeof(sam_sess_t));
if (session == NULL) {
SAMLOGS("Out of memory");
abort();
}
}
session->connected = false;
session->prev_id = 0;
return session;
}
/*
* Frees memory used by the session and sets the pointer to NULL
*
* session - pointer to a pointer to a sam_sess_t
*/
void sam_session_free(sam_sess_t **session)
{
assert(*session != NULL);
free(*session);
*session = NULL;
}
/* /*
* Connects to a remote host and returns a connected descriptor * Connects to a remote host and returns a connected descriptor
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment