init
This commit is contained in:
1
include/README.md
Normal file
1
include/README.md
Normal file
@@ -0,0 +1 @@
|
||||
# 存放公开的API接口
|
||||
9
include/latch/base/lt-encoding.h
Normal file
9
include/latch/base/lt-encoding.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef __LATCH_ENCODING_H__
|
||||
#define __LATCH_ENCODING_H__
|
||||
|
||||
typedef enum _latch_encoding_type {
|
||||
LT_ENCODING_UTF8 = 0,
|
||||
LT_ENCODING_UTF16LE = 1,
|
||||
} lt_encoding_type_t;
|
||||
|
||||
#endif //__LATCH_ENCODING_H__
|
||||
10
include/latch/base/lt-stats.h
Normal file
10
include/latch/base/lt-stats.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef __LATCH_STATS_H__
|
||||
#define __LATCH_STATS_H__
|
||||
|
||||
typedef enum _latch_error {
|
||||
LT_ERROR_OK = 0,
|
||||
LT_ERROR_MEMORY,
|
||||
LT_ERROR_IO,
|
||||
} lt_error_t;
|
||||
|
||||
#endif // __LATCH_STATS_H__
|
||||
36
include/latch/base/lt-types.h
Normal file
36
include/latch/base/lt-types.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef __LATCH_TYPES_H__
|
||||
#define __LATCH_TYPES_H__
|
||||
|
||||
typedef unsigned char lt_u8;
|
||||
typedef unsigned short lt_u16;
|
||||
typedef unsigned int lt_u32;
|
||||
typedef unsigned long lt_u64;
|
||||
typedef signed char lt_int8;
|
||||
typedef signed short lt_int16;
|
||||
typedef signed int lt_int32;
|
||||
typedef signed long lt_int64;
|
||||
typedef unsigned char lt_byte;
|
||||
typedef lt_u64 lt_size_t;
|
||||
typedef lt_u64 lt_time_t;
|
||||
|
||||
typedef lt_u8 lt_bool;
|
||||
#define true 1
|
||||
#define false 0
|
||||
#define LT_NULL 0
|
||||
#define LT_NULL_PTR ((void *)0)
|
||||
|
||||
typedef union {
|
||||
lt_u8 u8;
|
||||
lt_u16 u16;
|
||||
lt_u32 u32;
|
||||
lt_u64 u64;
|
||||
lt_int8 i8;
|
||||
lt_int16 i16;
|
||||
lt_int32 i32;
|
||||
lt_int64 i64;
|
||||
lt_byte byte;
|
||||
lt_bool bool;
|
||||
lt_size_t size_t;
|
||||
} lt_any_type_t;
|
||||
|
||||
#endif // __LATCH_TYPES_H__
|
||||
12
include/latch/container/lt-bytes.h
Normal file
12
include/latch/container/lt-bytes.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef __LATCH_CONTAINER_BYTES_H__
|
||||
#define __LATCH_CONTAINER_BYTES_H__
|
||||
|
||||
#include "latch/base/lt-types.h"
|
||||
|
||||
typedef struct __lt_bytes {
|
||||
lt_size_t length;
|
||||
lt_byte *data;
|
||||
void (*close)(struct __lt_bytes *self);
|
||||
} LT_Bytes;
|
||||
|
||||
#endif // __LATCH_CONTAINER_BYTES_H__
|
||||
0
include/latch/container/lt-dlist.h
Normal file
0
include/latch/container/lt-dlist.h
Normal file
0
include/latch/container/lt-map.h
Normal file
0
include/latch/container/lt-map.h
Normal file
0
include/latch/container/lt-slist.h
Normal file
0
include/latch/container/lt-slist.h
Normal file
18
include/latch/container/lt-string.h
Normal file
18
include/latch/container/lt-string.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef __LATCH_CONTAINER_STRING_H__
|
||||
#define __LATCH_CONTAINER_STRING_H__
|
||||
|
||||
#include "latch/base/lt-types.h"
|
||||
|
||||
typedef struct __lt_string {
|
||||
lt_size_t length;
|
||||
char *data;
|
||||
void (*close)(struct __lt_string *self);
|
||||
} LT_String;
|
||||
|
||||
|
||||
LT_String *lt_string_new(const char *data);
|
||||
void lt_string_reNew(LT_String* str, const char *data);
|
||||
LT_String *lt_string_reverse(LT_String *self);
|
||||
LT_String *lt_string_cut(LT_String *self, lt_int64 start, lt_int64 end, lt_int64 step);
|
||||
|
||||
#endif // __LATCH_CONTAINER_STRING_H__
|
||||
0
include/latch/hash/lt-sha.h
Normal file
0
include/latch/hash/lt-sha.h
Normal file
11
include/latch/http/lt-http.h
Normal file
11
include/latch/http/lt-http.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef __LT_HTTP_H__
|
||||
#define __LT_HTTP_H__
|
||||
|
||||
typedef enum __lt_http_code{
|
||||
LT_HTTP_OK = 200,
|
||||
LT_HTTP_BAD_REQUEST = 400,
|
||||
LT_HTTP_NOT_FOUND = 404,
|
||||
} lt_http_status_code;
|
||||
|
||||
|
||||
#endif //__LT_HTTP_H__
|
||||
0
include/latch/http/lt-https.h
Normal file
0
include/latch/http/lt-https.h
Normal file
37
include/latch/io/lt-file.h
Normal file
37
include/latch/io/lt-file.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef __LATCH_FILE_H__
|
||||
#define __LATCH_FILE_H__
|
||||
|
||||
#include "latch/base/lt-stats.h"
|
||||
#include "latch/base/lt-types.h"
|
||||
#include "latch/container/lt-bytes.h"
|
||||
#include "latch/container/lt-string.h"
|
||||
#include <stdio.h>
|
||||
|
||||
typedef enum {
|
||||
LT_FILE_SENK_BEG = 0,
|
||||
LT_FILE_SENK_CUR,
|
||||
LT_FILE_SENK_END,
|
||||
} lt_file_senk_flag_t;
|
||||
|
||||
typedef struct __LT_File {
|
||||
LT_String *name;
|
||||
LT_String *path;
|
||||
lt_size_t size;
|
||||
lt_time_t create_time;
|
||||
lt_time_t modify_time;
|
||||
FILE *fp;
|
||||
lt_error_t *(*read_bytes)(struct __LT_File *self, lt_size_t size,
|
||||
LT_Bytes *read_buffer);
|
||||
lt_error_t (*write_bytes)(struct __LT_File *self, LT_Bytes *write_buffer);
|
||||
void (*seek)(struct __LT_File *self, lt_int64 offset,
|
||||
lt_file_senk_flag_t flag);
|
||||
void (*close)(struct __LT_File *self);
|
||||
} LT_File;
|
||||
|
||||
LT_File *lt_file_open(const char *path, const char *mode);
|
||||
lt_bool lt_file_copy(const char *src, const char *dst); //TODO 文件复制
|
||||
lt_bool lt_file_remove(const char *path); //TODO 文件删除
|
||||
lt_bool lt_file_create(const char *path, const char *mode); //TODO 文件创建
|
||||
lt_bool lt_file_chmod(const char *path, lt_u32 mode); //TODO 文件权限修改
|
||||
|
||||
#endif // __LATCH_FILE_H__
|
||||
23
include/latch/latch.h
Normal file
23
include/latch/latch.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef __LATCH_H__
|
||||
#define __LATCH_H__
|
||||
|
||||
#include "latch/lt-version.h"
|
||||
|
||||
//基础
|
||||
#include "latch/base/lt-types.h"
|
||||
#include "latch/base/lt-stats.h"
|
||||
|
||||
//容器
|
||||
#include "latch/container/lt-string.h"
|
||||
#include "latch/container/lt-bytes.h"
|
||||
#include "latch/container/lt-dlist.h"
|
||||
#include "latch/container/lt-map.h"
|
||||
#include "latch/container/lt-slist.h"
|
||||
|
||||
|
||||
#include "latch/memory/lt-memory.h"
|
||||
|
||||
#include "latch/io/lt-file.h"
|
||||
|
||||
|
||||
#endif
|
||||
10
include/latch/lt-version.h
Normal file
10
include/latch/lt-version.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef __LATCH_VERSION_H__
|
||||
#define __LATCH_VERSION_H__
|
||||
|
||||
#define LATCH_MAJOR_VERSION 0
|
||||
#define LATCH_MINOR_VERSION 1
|
||||
#define LATCH_PATCH_VERSION 0
|
||||
|
||||
#define LATCH_VERSION "0.1.0"
|
||||
|
||||
#endif // __LATCH_VERSION_H__
|
||||
18
include/latch/memory/lt-memory.h
Normal file
18
include/latch/memory/lt-memory.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef __LATCH_MEMORY_H__
|
||||
#define __LATCH_MEMORY_H__
|
||||
|
||||
#include "latch/base/lt-types.h"
|
||||
|
||||
typedef enum lt_memory_type {
|
||||
LT_MEMORY_TYPE_LIBC = 1,
|
||||
LT_MEMORY_TYPE_POOL,
|
||||
} lt_memory_type_e;
|
||||
|
||||
void *lt_malloc(lt_size_t size);
|
||||
void *lt_calloc(lt_size_t nmemb, lt_size_t size);
|
||||
void *lt_realloc(void *ptr, lt_size_t size);
|
||||
void lt_free(void *ptr);
|
||||
|
||||
void lt_set_default_memory_type(lt_memory_type_e type);
|
||||
|
||||
#endif // __LATCH_MEMORY_H__
|
||||
5
include/latch/os/lt-os.h
Normal file
5
include/latch/os/lt-os.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#ifndef __LATCH_OS_H__
|
||||
#define __LATCH_OS_H__
|
||||
|
||||
|
||||
#endif // __LATCH_OS_H__
|
||||
10
include/latch/os/lt-path.h
Normal file
10
include/latch/os/lt-path.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef __LATCH_PATH_H__
|
||||
#define __LATCH_PATH_H__
|
||||
|
||||
#include "latch/base/lt-types.h"
|
||||
|
||||
lt_bool lt_path_is_file(const char *path);
|
||||
lt_bool lt_path_is_dir(const char *path);
|
||||
lt_bool lt_path_exists(const char *path);
|
||||
|
||||
#endif // __LATCH_PATH_H__
|
||||
0
include/latch/socket/lt-tcp.h
Normal file
0
include/latch/socket/lt-tcp.h
Normal file
0
include/latch/socket/lt-udp.h
Normal file
0
include/latch/socket/lt-udp.h
Normal file
Reference in New Issue
Block a user