123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- #ifndef __SP_DEF_H__
- #define __SP_DEF_H__
- #pragma once
- #include "precompile.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include "ErrorCode.h"
- #define SP_LOG_MAX_LEN 1023
- #define SP_PKT_TSX 0x00000000 // for sp_tsx
- #define SP_PKT_RPC 0x10000000 // for sp_rpc
- #define SP_PKT_LOG 0x20000000 // for sp_log
- #define SP_PKT_VAR 0x30000000 // for sp_var
- #define SP_PKT_MOD 0x40000000 // for sp_mod
- #define SP_PKT_SES 0x50000000 // for sp_ses
- #define SP_PKT_BCM 0x60000000 // for sp_bcm
- #define SP_PKT_NUM 7
- #define SP_PKT_MAX_NUM 15
- #define SP_GET_TYPE(x) ((x) & 0x0fffffff)
- #define SP_GET_PKT_TYPE(x) ((x) & 0xf0000000)
- #define SP_TYPE_SHIFT 28
- #define SP_INVALID_MOD_ID -1
- #define SP_INVALID_SVC_ID -1
- #define SP_INVALID_PKT_ID -1
- #define SP_SHELL_MOD_ID 0
- #define SP_SHELL_SVC_ID 0
- #define SP_MAX_MODULE 127
- #define SP_MAX_ENTITY 127
- #define SP_MAX_SYSEVT 127
- typedef struct sp_version_t {
- int major;
- int minor;
- int revision;
- int build;
- }sp_version_t;
- static __inline void sp_version_fulfill(sp_version_t* v, int major, int minor, int revision, int build)
- {
- v->major = major;
- v->minor = minor;
- v->revision = revision;
- v->build = build;
- }
- static __inline void sp_version_init(sp_version_t* v)
- {
- sp_version_fulfill(v, 0, 0, 0, 0);
- }
- static __inline void sp_version_copy(sp_version_t *dst, const sp_version_t *src)
- {
- dst->major = src->major;
- dst->minor = src->minor;
- dst->revision = src->revision;
- dst->build = src->build;
- }
- static __inline int sp_version_cmp(const sp_version_t *x, const sp_version_t *y)
- {
- if (x->major == y->major) {
- if (x->minor == y->minor) {
- if (x->revision == y->revision) {
- return x->build - y->build;
- } else {
- return x->revision - y->revision;
- }
- } else {
- return x->minor - y->minor;
- }
- } else {
- return x->major - y->major;
- }
- }
- static __inline int sp_version_equal(const sp_version_t *x, const sp_version_t *y)
- {
- return x->major == y->major && x->minor == y->minor && x->revision == y->revision && x->build == y->build;
- }
- static __inline int sp_version_equal_1(const sp_version_t *x, const sp_version_t *y)
- {
- return x->major == y->major;
- }
- static __inline int sp_version_equal_2(const sp_version_t *x, const sp_version_t *y)
- {
- return x->major == y->major && x->minor == y->minor;
- }
- static __inline int sp_version_equal_3(const sp_version_t *x, const sp_version_t *y)
- {
- return x->major == y->major && x->minor == y->minor && x->revision == y->revision;
- }
- static __inline int sp_version_is_valid(const sp_version_t *v)
- {
- return v->major + v->minor + v->revision + v->build;
- }
- /** prefer to using: void sp_dir_get_cur_drive(char* path) */
- //static __inline void sp_get_current_drive(char* drivePath)
- //{
- // char drive[_MAX_DRIVE] = "", dir[_MAX_DIR] = "", fname[_MAX_FNAME] = "", ext[_MAX_EXT] = "", chpath[MAX_PATH] = "";
- // GetModuleFileNameA(NULL, (LPSTR)chpath, sizeof(chpath));
- // _splitpath(chpath, drive, dir, fname, ext);
- // memcpy(drivePath, drive, sizeof(drive));
- //}
- #define sp_version_equal_4 sp_version_equal
- SPBASE_API const char* sp_strerror(int err);
- #ifdef __cplusplus
- } // extern "C" {
- #endif
- #endif //__SP_DEF_H__
|