invalid style error

This commit is contained in:
mpc
2004-08-26 21:42:56 +00:00
committed by zzz
parent d8eb1a0a4f
commit aaa328950e
2 changed files with 9 additions and 4 deletions

View File

@ -97,7 +97,8 @@ typedef enum { /* see sam_strerror() for detailed descriptions of these */
SAM_INVALID_KEY, SAM_KEY_NOT_FOUND, SAM_PEER_NOT_FOUND, SAM_TIMEOUT, SAM_INVALID_KEY, SAM_KEY_NOT_FOUND, SAM_PEER_NOT_FOUND, SAM_TIMEOUT,
SAM_UNKNOWN, SAM_UNKNOWN,
/* error codes from LibSAM */ /* error codes from LibSAM */
SAM_BAD_VERSION, SAM_CALLBACKS_UNSET, SAM_SOCKET_ERROR, SAM_TOO_BIG SAM_BAD_STYLE, SAM_BAD_VERSION, SAM_CALLBACKS_UNSET, SAM_SOCKET_ERROR,
SAM_TOO_BIG
} samerr_t; } samerr_t;
/* /*

View File

@ -118,6 +118,7 @@ bool sam_close(sam_sess_t *session)
* samport - SAM port * samport - SAM port
* destname - destination name for this program, or "TRANSIENT" for a random * destname - destination name for this program, or "TRANSIENT" for a random
* dest * dest
* style - the connection style (stream, datagram, or raw)
* 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)
* *
@ -145,9 +146,10 @@ samerr_t sam_connect(sam_sess_t *session, const char *samhost, uint16_t samport,
return SAM_CALLBACKS_UNSET; return SAM_CALLBACKS_UNSET;
} }
} else if (style == SAM_RAW) { } else if (style == SAM_RAW) {
assert(false); /* not implemented yet */ abort(); /* not implemented yet */
} else { } else {
assert(false); /* unknown style */ SAMLOGS("Unknown connection style");
return SAM_BAD_STYLE;
} }
#ifdef WINSOCK #ifdef WINSOCK
@ -857,7 +859,7 @@ static samerr_t sam_session_create(sam_sess_t *session, const char *destname,
"tunnels.depthOutbound=%u\n", "tunnels.depthOutbound=%u\n",
destname, tunneldepth, tunneldepth); destname, tunneldepth, tunneldepth);
} else { /* SAM_RAW */ } else { /* SAM_RAW */
assert(false); /* unimplemented */ abort(); /* unimplemented */
} }
sam_write(session, cmd, strlen(cmd)); sam_write(session, cmd, strlen(cmd));
@ -1115,6 +1117,8 @@ const char *sam_strerror(samerr_t code)
/* /*
* SAM_UNKNOWN deliberately left out (goes to default) * SAM_UNKNOWN deliberately left out (goes to default)
*/ */
case SAM_BAD_STYLE: /* Style must be stream, datagram, or raw */
return "Bad connection style";
case SAM_BAD_VERSION: /* sam_hello() had an unexpected reply */ case SAM_BAD_VERSION: /* sam_hello() had an unexpected reply */
return "Bad SAM version"; return "Bad SAM version";
case SAM_CALLBACKS_UNSET: /* Some callbacks are still set to NULL */ case SAM_CALLBACKS_UNSET: /* Some callbacks are still set to NULL */