get rid of stdint.h stuff because it confuses the microsoft compiler

This commit is contained in:
mpc
2004-12-02 22:16:27 +00:00
committed by zzz
parent 8abd99d134
commit a4946272d0
3 changed files with 31 additions and 44 deletions

View File

@ -57,7 +57,6 @@
#endif #endif
#if OS == CYGWIN #if OS == CYGWIN
#define FAST32_IS_LONG
#define INET_ADDRSTRLEN 16 #define INET_ADDRSTRLEN 16
#define NO_GETHOSTBYNAME2 #define NO_GETHOSTBYNAME2
#define NO_INET_NTOP #define NO_INET_NTOP
@ -72,9 +71,8 @@
* Standard C99 includes - if your compiler doesn't have these, it's time to * Standard C99 includes - if your compiler doesn't have these, it's time to
* upgrade * upgrade
*/ */
#include <stdbool.h> #include <stdbool.h> // bool
#include <stddef.h> #include <stddef.h> // size_t
#include <stdint.h>
/* /*
* System includes * System includes
@ -116,6 +114,13 @@
typedef signed long ssize_t; typedef signed long ssize_t;
#endif #endif
/*
* I'm too lazy to type "unsigned"
*/
typedef unsigned char byte;
typedef unsigned int uint;
typedef unsigned short ushort;
/* /*
* Prints out the file name, line number, and function name before log message * Prints out the file name, line number, and function name before log message
*/ */

View File

@ -34,9 +34,12 @@
extern "C" { extern "C" {
#endif #endif
#include <stdbool.h> /*
#include <stddef.h> * Standard C99 includes - if your compiler doesn't have these, it's time to
#include <stdint.h> * upgrade
*/
#include <stdbool.h> // bool
#include <stddef.h> // size_t
/* /*
@ -67,12 +70,6 @@ extern "C" {
* Some LibSAM variable types * Some LibSAM variable types
*/ */
typedef signed char schar_t;
typedef unsigned char uchar_t;
typedef unsigned int uint_t;
typedef unsigned long ulong_t;
typedef unsigned short ushort_t;
#ifdef WINSOCK #ifdef WINSOCK
typedef SOCKET socket_t; typedef SOCKET socket_t;
#else #else
@ -88,7 +85,7 @@ typedef struct {
size_t size; size_t size;
} sam_sendq_t; /* sending queue to encourage large stream packet sizes */ } sam_sendq_t; /* sending queue to encourage large stream packet sizes */
typedef int_fast32_t sam_sid_t; /* stream id number */ typedef long sam_sid_t; /* stream id number */
typedef struct { typedef struct {
socket_t sock; /* the socket used for communications with SAM */ socket_t sock; /* the socket used for communications with SAM */
@ -119,8 +116,8 @@ void sam_session_free(sam_sess_t **session);
/* SAM controls - connection */ /* SAM controls - connection */
bool sam_close(sam_sess_t *session); bool sam_close(sam_sess_t *session);
samerr_t sam_connect(sam_sess_t *session, const char *samhost, samerr_t sam_connect(sam_sess_t *session, const char *samhost,
uint16_t samport, const char *destname, sam_conn_t style, unsigned short samport, const char *destname, sam_conn_t style,
uint_t tunneldepth); unsigned int tunneldepth);
/* SAM controls - utilities */ /* SAM controls - utilities */
void sam_naming_lookup(sam_sess_t *session, const char *name); void sam_naming_lookup(sam_sess_t *session, const char *name);
bool sam_read_buffer(sam_sess_t *session); bool sam_read_buffer(sam_sess_t *session);

View File

@ -28,8 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "platform.h"
#include "sam.h" #include "sam.h"
#include "platform.h"
static bool sam_hello(sam_sess_t *session); static bool sam_hello(sam_sess_t *session);
static void sam_log(const char *format, ...); static void sam_log(const char *format, ...);
@ -40,9 +40,9 @@ static bool sam_readable(sam_sess_t *session);
static sam_sendq_t *sam_sendq_create(); static sam_sendq_t *sam_sendq_create();
static samerr_t sam_session_create(sam_sess_t *session, static samerr_t sam_session_create(sam_sess_t *session,
const char *destname, sam_conn_t style, const char *destname, sam_conn_t style,
uint_t tunneldepth); uint tunneldepth);
static bool sam_socket_connect(sam_sess_t *session, const char *host, static bool sam_socket_connect(sam_sess_t *session, const char *host,
uint16_t port); ushort port);
static bool sam_socket_resolve(const char *hostname, char *ipaddr); static bool sam_socket_resolve(const char *hostname, char *ipaddr);
#ifdef WINSOCK #ifdef WINSOCK
static samerr_t sam_winsock_cleanup(); static samerr_t sam_winsock_cleanup();
@ -146,8 +146,8 @@ bool sam_close(sam_sess_t *session)
* *
* Returns: SAM error code. If SAM_OK, `session' will be ready for use. * Returns: SAM error code. If SAM_OK, `session' will be ready 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, ushort samport,
const char *destname, sam_conn_t style, uint_t tunneldepth) const char *destname, sam_conn_t style, uint tunneldepth)
{ {
assert(session != NULL); assert(session != NULL);
samerr_t rc; samerr_t rc;
@ -723,10 +723,10 @@ static ssize_t sam_read2(sam_sess_t *session, void *buf, size_t n)
p = buf; p = buf;
printf("*RR* "); printf("*RR* ");
for (size_t x = 0; x < n; x++) { for (size_t x = 0; x < n; x++) {
if (isprint(((uchar_t*)p)[x])) if (isprint(((byte*)p)[x]))
printf("%c,", ((uchar_t*)p)[x]); printf("%c,", ((byte*)p)[x]);
else else
printf("%03d,", ((uint8_t*)p)[x]); printf("%03d,", ((byte*)p)[x]);
} }
printf("\n"); printf("\n");
printf("*RR* (read2() read %d bytes)\n", n); printf("*RR* (read2() read %d bytes)\n", n);
@ -877,7 +877,7 @@ void sam_sendq_flush(sam_sess_t *session, sam_sid_t stream_id,
* Returns: SAM error code * Returns: SAM error code
*/ */
static samerr_t sam_session_create(sam_sess_t *session, const char *destname, static samerr_t sam_session_create(sam_sess_t *session, const char *destname,
sam_conn_t style, uint_t tunneldepth) sam_conn_t style, uint tunneldepth)
{ {
assert(session != NULL); assert(session != NULL);
#define SAM_SESSTATUS_REPLY_OK "SESSION STATUS RESULT=OK" #define SAM_SESSTATUS_REPLY_OK "SESSION STATUS RESULT=OK"
@ -963,7 +963,7 @@ void sam_session_free(sam_sess_t **session)
* *
* Returns: true on sucess, false on error, with errno set * Returns: true on sucess, false on error, with errno set
*/ */
bool sam_socket_connect(sam_sess_t *session, const char *host, uint16_t port) bool sam_socket_connect(sam_sess_t *session, const char *host, ushort port)
{ {
assert(session != NULL); assert(session != NULL);
struct sockaddr_in hostaddr; struct sockaddr_in hostaddr;
@ -1080,11 +1080,7 @@ void sam_stream_close(sam_sess_t *session, sam_sid_t stream_id)
assert(session != NULL); assert(session != NULL);
char cmd[SAM_CMD_LEN]; char cmd[SAM_CMD_LEN];
#ifdef FAST32_IS_LONG
snprintf(cmd, sizeof cmd, "STREAM CLOSE ID=%ld\n", stream_id); snprintf(cmd, sizeof cmd, "STREAM CLOSE ID=%ld\n", stream_id);
#else
snprintf(cmd, sizeof cmd, "STREAM CLOSE ID=%d\n", stream_id);
#endif
sam_write(session, cmd, strlen(cmd)); sam_write(session, cmd, strlen(cmd));
return; return;
@ -1103,13 +1099,8 @@ sam_sid_t sam_stream_connect(sam_sess_t *session, const sam_pubkey_t dest)
char cmd[SAM_PKCMD_LEN]; char cmd[SAM_PKCMD_LEN];
session->prev_id++; /* increment the id for the connection */ session->prev_id++; /* increment the id for the connection */
#ifdef FAST32_IS_LONG
snprintf(cmd, sizeof cmd, "STREAM CONNECT ID=%ld DESTINATION=%s\n", snprintf(cmd, sizeof cmd, "STREAM CONNECT ID=%ld DESTINATION=%s\n",
session->prev_id, dest); session->prev_id, dest);
#else
snprintf(cmd, sizeof cmd, "STREAM CONNECT ID=%d DESTINATION=%s\n",
session->prev_id, dest);
#endif
sam_write(session, cmd, strlen(cmd)); sam_write(session, cmd, strlen(cmd));
return session->prev_id; return session->prev_id;
@ -1141,15 +1132,9 @@ samerr_t sam_stream_send(sam_sess_t *session, sam_sid_t stream_id,
return SAM_TOO_BIG; return SAM_TOO_BIG;
} }
#ifdef NO_Z_FORMAT #ifdef NO_Z_FORMAT
#ifdef FAST32_IS_LONG snprintf(cmd, sizeof cmd, "STREAM SEND ID=%ld SIZE=%u\n", stream_id, size);
snprintf(cmd, sizeof cmd, "STREAM SEND ID=%ld SIZE=%u\n",
stream_id, size);
#else
snprintf(cmd, sizeof cmd, "STREAM SEND ID=%d SIZE=%u\n",
stream_id, size);
#endif
#else #else
snprintf(cmd, sizeof cmd, "STREAM SEND ID=%d SIZE=%zu\n", snprintf(cmd, sizeof cmd, "STREAM SEND ID=%ld SIZE=%zu\n",
stream_id, size); stream_id, size);
#endif #endif
sam_write(session, cmd, strlen(cmd)); sam_write(session, cmd, strlen(cmd));
@ -1399,7 +1384,7 @@ static ssize_t sam_write(sam_sess_t *session, const void *buf, size_t n)
return -1; return -1;
} }
#if SAM_WIRETAP #if SAM_WIRETAP
const uchar_t *cp = buf; const byte *cp = buf;
printf("*WW* "); printf("*WW* ");
for (size_t x = 0; x < n; x++) { for (size_t x = 0; x < n; x++) {
if (isprint(cp[x])) if (isprint(cp[x]))