📄 dmtxutil.c
字号:
#include <stdlib.h>#include <stdio.h>#include <stdarg.h>#include <string.h>#include <ctype.h>#include <errno.h>#include <assert.h>#include "../../dmtx.h"#include "dmtxutil.h"extern char *programName;/** * @brief Display error message and exit with error status * @param errorCode error code returned to OS * @param fmt error message format for printing * @return void */extern voidFatalError(int errorCode, char *fmt, ...){ va_list va; va_start(va, fmt); fprintf(stderr, "%s: ", programName); vfprintf(stderr, fmt, va); va_end(va); fprintf(stderr, "\n\n"); fflush(stderr); exit(errorCode);}/** * @brief Convert character string to integer * @param numberInt pointer to converted integer * @param numberString string to be converted * @param terminate pointer to first invalid address * @return DMTX_SUCCESS | DMTX_FAILURE */extern intStringToInt(int *numberInt, char *numberString, char **terminate){ long numberLong; if(!isdigit(*numberString)) { *numberInt = -1; return DMTX_FAILURE; } errno = 0; numberLong = strtol(numberString, terminate, 10); while(isspace((int)**terminate)) (*terminate)++; if(errno != 0 || (**terminate != '\0' && **terminate != '%')) { *numberInt = -1; return DMTX_FAILURE; } *numberInt = (int)numberLong; return DMTX_SUCCESS;}/** * @brief XXX * @param path * @return pointer to adjusted path string */extern char *Basename(char *path){ assert(path); if(strrchr(path, '/')) path = strrchr(path, '/') + 1; if(strrchr(path, '\\')) path = strrchr(path, '\\') + 1; return path;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -