From aaa328950e486a229dc5b9f76f8ca1ab54f943fa Mon Sep 17 00:00:00 2001
From: mpc <mpc>
Date: Thu, 26 Aug 2004 21:42:56 +0000
Subject: [PATCH] invalid style error

---
 apps/sam/c/inc/sam.h |  3 ++-
 apps/sam/c/src/sam.c | 10 +++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/apps/sam/c/inc/sam.h b/apps/sam/c/inc/sam.h
index eaa90d6c55..1b9d0eec4d 100644
--- a/apps/sam/c/inc/sam.h
+++ b/apps/sam/c/inc/sam.h
@@ -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_UNKNOWN,
 	/* 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;
 
 /*
diff --git a/apps/sam/c/src/sam.c b/apps/sam/c/src/sam.c
index e413dac6c7..9f2902f5bc 100644
--- a/apps/sam/c/src/sam.c
+++ b/apps/sam/c/src/sam.c
@@ -118,6 +118,7 @@ bool sam_close(sam_sess_t *session)
  * samport - SAM port
  * destname - destination name for this program, or "TRANSIENT" for a random
  *		dest
+ * style - the connection style (stream, datagram, or raw)
  * tunneldepth - length of the I2P tunnels created by this program (longer is
  *		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;
 		}
 	} else if (style == SAM_RAW) {
-		assert(false);  /* not implemented yet */
+		abort();  /* not implemented yet */
 	} else {
-		assert(false);  /* unknown style */
+		SAMLOGS("Unknown connection style");
+		return SAM_BAD_STYLE;
 	}
 
 #ifdef WINSOCK
@@ -857,7 +859,7 @@ static samerr_t sam_session_create(sam_sess_t *session, const char *destname,
 			"tunnels.depthOutbound=%u\n",
 			destname, tunneldepth, tunneldepth);
 	} else { /* SAM_RAW */
-		assert(false);  /* unimplemented */
+		abort();  /* unimplemented */
 	}
 
 	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)
 		 */
+		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 */
 			return "Bad SAM version";
 		case SAM_CALLBACKS_UNSET:	/* Some callbacks are still set to NULL */
-- 
GitLab