⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utils.h

📁 dtelent是开源的开发项目
💻 H
字号:
/* utils.h
 * Copyright (c) 1997 David Cole
 *
 * Miscellaneous utilities
 */
#ifndef __utils_h
#define __utils_h

#define USE_ASSERT

/* Convert a character to ^character */
#define CTRL(c) ((c) & 0x1f)

/* Determine the number of elements in an array */
#define numElem(a) (sizeof(a)/sizeof(a[0]))

/* Concatenate strings, return combined length */
int strlcat(char* dst, const char* src, int siz);
/* Copy a string, return copied length */
int strlcpy(char* dst, const char* src, int siz);
/* Separate a string into tokens, like strtok */
char* strsep(char** stringp, const char* delim);

/* Allocate some memory - abort program on failure */
void* xmalloc(int size);
/* Resize some previously allocated memory - abort program on failure */
void* xrealloc(void* ptr, int size);
/* Frees memory allocated using xmalloc or xrealloc. */
void xfree(void* ptr);
/* Allocates memory using xmalloc, and copies the string into that memory. */
char* xstrdup(const char *str);

/* Determine the the directory that the application was started from */
void getExePath(HINSTANCE instance, char* path);

/* Split a string into a number of fields using delimiter */
int split(char* str, char delim, char** fields, int maxFields);

/* Check if a string is non-blank */
BOOL isNonBlank(char* str);

#ifdef USE_ASSERT
void assertFail(char* str, char* file, int line);
#define ASSERT(exp) { if (!(exp)) assertFail(#exp, __FILE__, __LINE__); }
#else
#define ASSERT(exp)
#endif

#ifdef USE_ODS
void ods(char* fmt, ...);
#endif

extern int  fromhex(char hex);
extern int  escape (const char *from, int len, char* to, int maxlen);
extern int  unescape (const char* from, int len, char* to, int maxlen);

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -