sfsnprintfappend.c

来自「linux下IDS软件,来源于snort社团.」· C语言 代码 · 共 57 行

C
57
字号
/***  sfsnprintfappend.h**  snprintf that appends to destination buffer**  Copyright (C) 2004 Sourcefire, Inc.**  Author: Steven Sturges**/#ifdef HAVE_CONFIG_H#include "config.h"#endif#include <stdio.h>#include <stdlib.h>#include <stdarg.h>#include <unistd.h>#include <string.h>/**************************************************************************** * * Function: sfsnprintfappend * * Purpose: snprintf that appends to destination buffer * *          Appends the snprintf format string and arguments to dest *          without going beyond dsize bounds.  Assumes dest has *          been properly allocated, and is of dsize in length. * * Arguments: dest      ==> pointer to string buffer to append to *            dsize     ==> size of buffer dest *            format    ==> snprintf format string *            ...       ==> arguments for printf * * Returns: number of characters added to the buffer * ****************************************************************************/int sfsnprintfappend(char *dest, int dsize, const char *format, ...){    int currLen, appendLen;    va_list ap;    if (!dest || dsize == 0)        return -1;    currLen = strlen(dest);    va_start(ap, format);    appendLen = vsnprintf(dest+currLen, dsize-currLen, format, ap);    va_end(ap);    return appendLen;}

⌨️ 快捷键说明

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