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

📄 diag.c

📁 This a good VPN source
💻 C
字号:
/* * Diagnostic builder * Copyright (C) 1998-2003  D. Hugh Redelmeier  * Copyright (C) 2004       Michael Richardson <mcr@xelerance.com> * * alg_info.c,v 1.1.2.1 2003/11/21 18:12:23 jjo Exp * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License * for more details. */#include <stdarg.h>#include <openswan.h>#include "constants.h"#include "oswlog.h"/* Build up a diagnostic in a static buffer. * Although this would be a generally useful function, it is very * hard to come up with a discipline that prevents different uses * from interfering.  It is intended that by limiting it to building * diagnostics, we will avoid this problem. * Juggling is performed to allow an argument to be a previous * result: the new string may safely depend on the old one.  This * restriction is not checked in any way: violators will produce * confusing results (without crashing!). */char diag_space[sizeof(diag_space)];/** Build up a diagnostic in a static buffer. * * Although this would be a generally useful function, it is very * hard to come up with a discipline that prevents different uses * from interfering.  It is intended that by limiting it to building * diagnostics, we will avoid this problem. * Juggling is performed to allow an argument to be a previous * result: the new string may safely depend on the old one.  This * restriction is not checked in any way: violators will produce * confusing results (without crashing!). * * @param fmt String format * @param ... strings * @return err_t  */err_tbuilddiag(const char *fmt, ...){    static char diag_space[LOG_WIDTH];	/* longer messages will be truncated */    char t[sizeof(diag_space)];	/* build result here first */    va_list args;    va_start(args, fmt);    t[0] = '\0';	/* in case nothing terminates string */    vsnprintf(t, sizeof(t), fmt, args);    va_end(args);    strcpy(diag_space, t);    return diag_space;}

⌨️ 快捷键说明

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