Commit e9e44c6b authored by Martin Hurton's avatar Martin Hurton

Merge pull request #558 from hintjens/master

stdint.h isn't available on all platforms
parents 5d2a8b18 31ee92f2
...@@ -23,7 +23,7 @@ options. Which peer binds, and which connects, is not relevant. ...@@ -23,7 +23,7 @@ options. Which peer binds, and which connects, is not relevant.
NOTE: this isn't implemented and not fully defined. The server keypair NOTE: this isn't implemented and not fully defined. The server keypair
needs to be persistent, and it would be sensible to define a format for needs to be persistent, and it would be sensible to define a format for
this in CurveZMQ this as a CurveZMQ RFC.
SEE ALSO SEE ALSO
......
...@@ -27,7 +27,6 @@ extern "C" { ...@@ -27,7 +27,6 @@ extern "C" {
#if !defined _WIN32_WCE #if !defined _WIN32_WCE
#include <errno.h> #include <errno.h>
#endif #endif
#include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
#if defined _WIN32 #if defined _WIN32
...@@ -53,6 +52,21 @@ extern "C" { ...@@ -53,6 +52,21 @@ extern "C" {
# endif # endif
#endif #endif
/* Define integer types needed for event interface */
#if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_OPENVMS
# include <inttypes.h>
#elif defined _MSC_VER && _MSC_VER < 1600
# ifndef int32_t
typedef __int32 int32_t;
# endif
# ifndef uint16_t
typedef unsigned __int16 uint16_t;
# endif
#else
# include <stdint.h>
#endif
/******************************************************************************/ /******************************************************************************/
/* 0MQ versioning support. */ /* 0MQ versioning support. */
/******************************************************************************/ /******************************************************************************/
......
...@@ -20,8 +20,7 @@ ...@@ -20,8 +20,7 @@
#ifndef __ZMQ_MECHANISM_HPP_INCLUDED__ #ifndef __ZMQ_MECHANISM_HPP_INCLUDED__
#define __ZMQ_MECHANISM_HPP_INCLUDED__ #define __ZMQ_MECHANISM_HPP_INCLUDED__
#include <stdint.h> #include "stdint.hpp"
#include "options.hpp" #include "options.hpp"
#include "blob.hpp" #include "blob.hpp"
......
...@@ -125,19 +125,20 @@ int zmq::plain_mechanism_t::hello_command (msg_t *msg_) const ...@@ -125,19 +125,20 @@ int zmq::plain_mechanism_t::hello_command (msg_t *msg_) const
const std::string password = options.plain_password; const std::string password = options.plain_password;
zmq_assert (password.length () < 256); zmq_assert (password.length () < 256);
const size_t command_size = 8 + 1 + username.length () + const size_t command_size = 8 + 1 + username.length ()
1 + password.length (); + 1 + password.length ();
const int rc = msg_->init_size (command_size); const int rc = msg_->init_size (command_size);
errno_assert (rc == 0); errno_assert (rc == 0);
unsigned char *ptr = static_cast<unsigned char*> (msg_->data ()); unsigned char *ptr = static_cast <unsigned char *> (msg_->data ());
memcpy (ptr, "HELLO ", 8); memcpy (ptr, "HELLO ", 8);
ptr += 8; ptr += 8;
*ptr++ = static_cast <unsigned char> (username.length ()); *ptr++ = static_cast <unsigned char> (username.length ());
memcpy (ptr, username.c_str (), username.length ()); memcpy (ptr, username.c_str (), username.length ());
ptr += username.length (); ptr += username.length ();
*ptr++ = static_cast <unsigned char> (password.length ()); *ptr++ = static_cast <unsigned char> (password.length ());
memcpy (ptr, password.c_str (), password.length ()); memcpy (ptr, password.c_str (), password.length ());
ptr += password.length (); ptr += password.length ();
...@@ -155,7 +156,6 @@ int zmq::plain_mechanism_t::process_hello_command (msg_t *msg_) ...@@ -155,7 +156,6 @@ int zmq::plain_mechanism_t::process_hello_command (msg_t *msg_)
errno = EPROTO; errno = EPROTO;
return -1; return -1;
} }
ptr += 8; ptr += 8;
bytes_left -= 8; bytes_left -= 8;
...@@ -195,6 +195,7 @@ int zmq::plain_mechanism_t::process_hello_command (msg_t *msg_) ...@@ -195,6 +195,7 @@ int zmq::plain_mechanism_t::process_hello_command (msg_t *msg_)
} }
// TODO: Add user authentication // TODO: Add user authentication
// Note: maybe use RFC 27 (ZAP) for this
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment