defined QSE_PATH_MAX

added more operators to qse_ip4ad_t for c++
This commit is contained in:
2018-01-17 04:38:21 +00:00
parent 825cf63d04
commit 8ce346e1ed
10 changed files with 141 additions and 13 deletions

View File

@ -29,6 +29,7 @@
#include <qse/types.h>
#include <qse/macros.h>
#include <qse/cmn/hton.h>
typedef struct qse_ip4ad_t qse_ip4ad_t;
typedef struct qse_ip6ad_t qse_ip6ad_t;
@ -37,13 +38,88 @@ typedef struct qse_ip6ad_t qse_ip6ad_t;
struct qse_ip4ad_t
{
qse_uint32_t value;
#if defined(__cplusplus)
bool operator== (const qse_ip4ad_t& peer) const { return this->value == peer.value; }
bool operator!= (const qse_ip4ad_t& peer) const { return this->value != peer.value; }
bool operator< (const qse_ip4ad_t& peer) const { return qse_ntoh32(this->value) < qse_ntoh32(peer.value); }
bool operator<= (const qse_ip4ad_t& peer) const { return qse_ntoh32(this->value) <= qse_ntoh32(peer.value); }
bool operator> (const qse_ip4ad_t& peer) const { return qse_ntoh32(this->value) > qse_ntoh32(peer.value); }
bool operator>= (const qse_ip4ad_t& peer) const { return qse_ntoh32(this->value) >= qse_ntoh32(peer.value); }
/* i don't define a constructor so that it can be used within a struct
* with no constructor.
* struct xxx { qse_ip4ad_t addr; }
* since xxx doesn't have a constructor, some compilers complain of
* ill-formed constructor or deleted default contructor.
*/
qse_ip4ad_t& operator= (qse_ip4ad_t v)
{
this->value = v.value;
return *this;
}
qse_ip4ad_t& operator+= (qse_ip4ad_t v)
{
this->value = qse_hton32(qse_ntoh32(this->value) + qse_ntoh32(v.value));
return *this;
}
qse_ip4ad_t& operator-= (qse_ip4ad_t v)
{
this->value = qse_hton32(qse_ntoh32(this->value) - qse_ntoh32(v.value));
return *this;
}
qse_ip4ad_t operator+ (qse_ip4ad_t v) const
{
qse_ip4ad_t x;
x.value = qse_hton32(qse_ntoh32(this->value) + qse_ntoh32(v.value));
return x;
}
qse_ip4ad_t operator- (qse_ip4ad_t v) const
{
qse_ip4ad_t x;
x.value = qse_hton32(qse_ntoh32(this->value) - qse_ntoh32(v.value));
return x;
}
qse_ip4ad_t& operator= (qse_uint32_t v)
{
this->value = qse_hton32(v);
return *this;
}
qse_ip4ad_t& operator+= (qse_uint32_t v)
{
this->value = qse_hton32(qse_ntoh32(this->value) + v);
return *this;
}
qse_ip4ad_t& operator-= (qse_uint32_t v)
{
this->value = qse_hton32(qse_ntoh32(this->value) - v);
return *this;
}
qse_ip4ad_t operator+ (qse_uint32_t v) const
{
qse_ip4ad_t x;
x.value = qse_hton32(qse_ntoh32(this->value) + v);
return x;
}
qse_ip4ad_t operator- (qse_uint32_t v) const
{
qse_ip4ad_t x;
x.value = qse_hton32(qse_ntoh32(this->value) - v);
return x;
}
#endif
};
struct qse_ip6ad_t
{
qse_uint8_t value[16];
};
#include <qse/unpack.h>
#define QSE_IP4AD_IN_LOOPBACK(addr) ((((addr)->value) & QSE_CONST_HTON32(0xFF000000)) == QSE_CONST_HTON32(0x7F000000))
#if defined(__cplusplus)
extern "C" {
#endif

View File

@ -172,8 +172,6 @@ QSE_EXPORT qse_char_t* qse_getcliparams (
int index
);
#if defined(QSE_HAVE_INLINE)
static QSE_INLINE int qse_getncliparams (qse_cli_t* cli) { return cli->nparams; }
#else

View File

@ -34,6 +34,10 @@
#include <qse/types.h>
#include <qse/macros.h>
#if !defined(QSE_PATH_MAX)
# define QSE_PATH_MAX 1024
#endif
enum qse_canonpath_flag_t
{
/** if the final output is . logically, return an empty path */

View File

@ -945,6 +945,9 @@
/* Patch level */
#undef QSE_PACKAGE_VERSION_PATCH
/* PATH_MAX */
#undef QSE_PATH_MAX
/* Define if pthread_cond_t is signed */
#undef QSE_PTHREAD_MUTEX_T_IS_SIGNED

View File

@ -316,9 +316,11 @@ QSE_EXPORT void* qse_fs_getxtn (
qse_fs_t* fs
);
QSE_EXPORT qse_fs_errnum_t qse_fs_geterrnum (
qse_fs_t* fs
);
#if defined(QSE_HAVE_INLINE)
static QSE_INLINE qse_fs_errnum_t qse_fs_geterrnum (qse_fs_t* fs) { return fs->errnum; }
#else
# define qse_fs_geterrnum(fs) ((fs)->errnum)
#endif
QSE_EXPORT int qse_fs_getopt (
qse_fs_t* fs,

View File

@ -149,14 +149,14 @@ QSE_EXPORT qse_sio_t* qse_sio_open (
qse_mmgr_t* mmgr, /**< memory manager */
qse_size_t xtnsize, /**< extension size in bytes */
const qse_char_t* file, /**< file name */
int flags /**< number OR'ed of #qse_sio_flag_t */
int flags /**< number OR'ed of #qse_sio_flag_t */
);
QSE_EXPORT qse_sio_t* qse_sio_openstd (
qse_mmgr_t* mmgr, /**< memory manager */
qse_size_t xtnsize, /**< extension size in bytes */
qse_sio_std_t std, /**< standard I/O identifier */
int flags /**< number OR'ed of #qse_sio_flag_t */
int flags /**< number OR'ed of #qse_sio_flag_t */
);
/**