003 File Manager
Current Path:
/usr/src/contrib/sendmail/libsm
usr
/
src
/
contrib
/
sendmail
/
libsm
/
📁
..
📄
Makefile
(346 B)
📄
Makefile.m4
(1.92 KB)
📄
README
(4.42 KB)
📄
assert.c
(4.13 KB)
📄
assert.html
(13.86 KB)
📄
b-strcmp.c
(3.4 KB)
📄
b-strl.c
(5 KB)
📄
cdefs.html
(2.39 KB)
📄
cf.c
(1.97 KB)
📄
clock.c
(13.89 KB)
📄
clrerr.c
(872 B)
📄
config.c
(4.47 KB)
📄
debug.c
(8.91 KB)
📄
debug.html
(7.68 KB)
📄
errstring.c
(6.03 KB)
📄
exc.c
(13.05 KB)
📄
exc.html
(23.27 KB)
📄
fclose.c
(3.13 KB)
📄
feof.c
(961 B)
📄
ferror.c
(932 B)
📄
fflush.c
(3.1 KB)
📄
fget.c
(2.37 KB)
📄
findfp.c
(10.65 KB)
📄
flags.c
(1.27 KB)
📄
fopen.c
(8.3 KB)
📄
fpos.c
(3.12 KB)
📄
fprintf.c
(1.35 KB)
📄
fpurge.c
(1.15 KB)
📄
fput.c
(1.25 KB)
📄
fread.c
(2.28 KB)
📄
fscanf.c
(1.34 KB)
📄
fseek.c
(7.25 KB)
📄
fvwrite.c
(6.24 KB)
📄
fvwrite.h
(740 B)
📄
fwalk.c
(1.41 KB)
📄
fwrite.c
(1.54 KB)
📄
gen.html
(910 B)
📄
get.c
(1.12 KB)
📄
glue.h
(731 B)
📄
heap.c
(17.29 KB)
📄
heap.html
(13.07 KB)
📄
index.html
(5.95 KB)
📄
inet6_ntop.c
(1.1 KB)
📄
io.html
(26.6 KB)
📄
ldap.c
(35.72 KB)
📄
local.h
(9.42 KB)
📄
makebuf.c
(3.36 KB)
📄
match.c
(2.77 KB)
📄
mbdb.c
(16.61 KB)
📄
memstat.c
(5.13 KB)
📄
mpeix.c
(13.84 KB)
📄
niprop.c
(4.64 KB)
📄
notify.c
(3.32 KB)
📄
put.c
(1.61 KB)
📄
refill.c
(7.09 KB)
📄
rewind.c
(1.08 KB)
📄
rpool.c
(11.54 KB)
📄
rpool.html
(6.08 KB)
📄
sem.c
(4.41 KB)
📄
setvbuf.c
(4.2 KB)
📄
shm.c
(2.62 KB)
📄
signal.c
(6.75 KB)
📄
smstdio.c
(6.14 KB)
📄
snprintf.c
(2.29 KB)
📄
sscanf.c
(2.26 KB)
📄
stdio.c
(9.7 KB)
📄
strcasecmp.c
(3.14 KB)
📄
strdup.c
(2.79 KB)
📄
strerror.c
(1.27 KB)
📄
strexit.c
(2.76 KB)
📄
string.c
(1.29 KB)
📄
stringf.c
(1.77 KB)
📄
strio.c
(9.18 KB)
📄
strl.c
(7.52 KB)
📄
strrevcmp.c
(1.61 KB)
📄
strto.c
(5.45 KB)
📄
syslogio.c
(4.11 KB)
📄
t-cf.c
(934 B)
📄
t-event.c
(1.79 KB)
📄
t-exc.c
(2.75 KB)
📄
t-fget.c
(1.71 KB)
📄
t-float.c
(1.78 KB)
📄
t-fopen.c
(875 B)
📄
t-heap.c
(1.3 KB)
📄
t-inet6_ntop.c
(1.4 KB)
📄
t-match.c
(1.1 KB)
📄
t-memstat.c
(2.17 KB)
📄
t-notify.c
(1.81 KB)
📄
t-path.c
(742 B)
📄
t-qic.c
(5.43 KB)
📄
t-rpool.c
(1.5 KB)
📄
t-scanf.c
(1.38 KB)
📄
t-sem.c
(5.85 KB)
📄
t-shm.c
(4.42 KB)
📄
t-smstdio.c
(1.55 KB)
📄
t-string.c
(968 B)
📄
t-strio.c
(775 B)
📄
t-strl.c
(3.53 KB)
📄
t-strrevcmp.c
(994 B)
📄
t-types.c
(2.7 KB)
📄
test.c
(2.73 KB)
📄
ungetc.c
(3.93 KB)
📄
util.c
(4.46 KB)
📄
vasprintf.c
(2.91 KB)
📄
vfprintf.c
(24.09 KB)
📄
vfscanf.c
(18.76 KB)
📄
vprintf.c
(999 B)
📄
vsnprintf.c
(1.87 KB)
📄
wbuf.c
(2.51 KB)
📄
wsetup.c
(1.88 KB)
📄
xtrap.c
(653 B)
Editing: debug.c
/* * Copyright (c) 2000, 2001, 2003, 2004 Proofpoint, Inc. and its suppliers. * All rights reserved. * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the sendmail distribution. */ #include <sm/gen.h> SM_RCSID("@(#)$Id: debug.c,v 1.33 2013-11-22 20:51:42 ca Exp $") /* ** libsm debugging and tracing ** For documentation, see debug.html. */ #include <ctype.h> #include <stdlib.h> #if _FFR_DEBUG_PID_TIME #include <unistd.h> #include <sm/types.h> #include <sm/time.h> #include <time.h> #endif /* _FFR_DEBUG_PID_TIME */ #include <setjmp.h> #include <sm/io.h> #include <sm/assert.h> #include <sm/conf.h> #include <sm/debug.h> #include <sm/string.h> #include <sm/varargs.h> #include <sm/heap.h> static void sm_debug_reset __P((void)); static const char *parse_named_setting_x __P((const char *)); /* ** Abstractions for printing trace messages. */ /* ** The output file to which trace output is directed. ** There is a controversy over whether this variable ** should be process global or thread local. ** To make the interface more abstract, we've hidden the ** variable behind access functions. */ static SM_FILE_T *SmDebugOutput = smioout; /* ** SM_DEBUG_FILE -- Returns current debug file pointer. ** ** Parameters: ** none. ** ** Returns: ** current debug file pointer. */ SM_FILE_T * sm_debug_file() { return SmDebugOutput; } /* ** SM_DEBUG_SETFILE -- Sets debug file pointer. ** ** Parameters: ** fp -- new debug file pointer. ** ** Returns: ** none. ** ** Side Effects: ** Sets SmDebugOutput. */ void sm_debug_setfile(fp) SM_FILE_T *fp; { SmDebugOutput = fp; } /* ** SM_DEBUG_CLOSE -- Close debug file pointer. ** ** Parameters: ** none. ** ** Returns: ** none. ** ** Side Effects: ** Closes SmDebugOutput. */ void sm_debug_close() { if (SmDebugOutput != NULL && SmDebugOutput != smioout) { sm_io_close(SmDebugOutput, SM_TIME_DEFAULT); SmDebugOutput = NULL; } } /* ** SM_DPRINTF -- printf() for debug output. ** ** Parameters: ** fmt -- format for printf() ** ** Returns: ** none. */ #if _FFR_DEBUG_PID_TIME SM_DEBUG_T SmDBGPidTime = SM_DEBUG_INITIALIZER("sm_trace_pid_time", "@(#)$Debug: sm_trace_pid_time - print pid and time in debug $"); #endif void #if SM_VA_STD sm_dprintf(char *fmt, ...) #else /* SM_VA_STD */ sm_dprintf(fmt, va_alist) char *fmt; va_dcl #endif /* SM_VA_STD */ { SM_VA_LOCAL_DECL #if _FFR_DEBUG_PID_TIME static struct timeval lasttv; #endif if (SmDebugOutput == NULL) return; #if _FFR_DEBUG_PID_TIME /* note: this is ugly if the output isn't a full line! */ if (sm_debug_active(&SmDBGPidTime, 3)) { struct timeval tv, tvd; gettimeofday(&tv, NULL); if (timerisset(&lasttv)) timersub(&tv, &lasttv, &tvd); else timerclear(&tvd); sm_io_fprintf(SmDebugOutput, SmDebugOutput->f_timeout, "%ld: %ld.%06ld ", (long) getpid(), (long) tvd.tv_sec, (long) tvd.tv_usec); lasttv = tv; } else if (sm_debug_active(&SmDBGPidTime, 2)) { struct timeval tv; gettimeofday(&tv, NULL); sm_io_fprintf(SmDebugOutput, SmDebugOutput->f_timeout, "%ld: %ld.%06ld ", (long) getpid(), (long) tv.tv_sec, (long) tv.tv_usec); } else if (sm_debug_active(&SmDBGPidTime, 1)) { static char str[32] = "[1900-00-00/00:00:00] "; struct tm *tmp; time_t currt; currt = time((time_t *)0); tmp = localtime(&currt); snprintf(str, sizeof(str), "[%d-%02d-%02d/%02d:%02d:%02d] ", 1900 + tmp->tm_year, /* HACK */ tmp->tm_mon + 1, tmp->tm_mday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec); sm_io_fprintf(SmDebugOutput, SmDebugOutput->f_timeout, "%ld: %s ", (long) getpid(), str); } #endif /* _FFR_DEBUG_PID_TIME */ SM_VA_START(ap, fmt); sm_io_vfprintf(SmDebugOutput, SmDebugOutput->f_timeout, fmt, ap); SM_VA_END(ap); } /* ** SM_DFLUSH -- Flush debug output. ** ** Parameters: ** none. ** ** Returns: ** none. */ void sm_dflush() { sm_io_flush(SmDebugOutput, SM_TIME_DEFAULT); } /* ** This is the internal database of debug settings. ** The semantics of looking up a setting in the settings database ** are that the *last* setting specified in a -d option on the sendmail ** command line that matches a given SM_DEBUG structure is the one that is ** used. That is necessary to conform to the existing semantics of ** the sendmail -d option. We store the settings as a linked list in ** reverse order, so when we do a lookup, we take the *first* entry ** that matches. */ typedef struct sm_debug_setting SM_DEBUG_SETTING_T; struct sm_debug_setting { const char *ds_pattern; unsigned int ds_level; SM_DEBUG_SETTING_T *ds_next; }; SM_DEBUG_SETTING_T *SmDebugSettings = NULL; /* ** We keep a linked list of SM_DEBUG structures that have been initialized, ** for use by sm_debug_reset. */ SM_DEBUG_T *SmDebugInitialized = NULL; const char SmDebugMagic[] = "sm_debug"; /* ** SM_DEBUG_RESET -- Reset SM_DEBUG structures. ** ** Reset all SM_DEBUG structures back to the uninitialized state. ** This is used by sm_debug_addsetting to ensure that references to ** SM_DEBUG structures that occur before sendmail processes its -d flags ** do not cause those structures to be permanently forced to level 0. ** ** Parameters: ** none. ** ** Returns: ** none. */ static void sm_debug_reset() { SM_DEBUG_T *debug; for (debug = SmDebugInitialized; debug != NULL; debug = debug->debug_next) { debug->debug_level = SM_DEBUG_UNKNOWN; } SmDebugInitialized = NULL; } /* ** SM_DEBUG_ADDSETTING_X -- add an entry to the database of debug settings ** ** Parameters: ** pattern -- a shell-style glob pattern (see sm_match). ** WARNING: the storage for 'pattern' will be owned by ** the debug package, so it should either be a string ** literal or the result of a call to sm_strdup_x. ** level -- a non-negative integer. ** ** Returns: ** none. ** ** Exceptions: ** F:sm_heap -- out of memory */ void sm_debug_addsetting_x(pattern, level) const char *pattern; int level; { SM_DEBUG_SETTING_T *s; SM_REQUIRE(pattern != NULL); SM_REQUIRE(level >= 0); s = sm_malloc_x(sizeof(SM_DEBUG_SETTING_T)); s->ds_pattern = pattern; s->ds_level = (unsigned int) level; s->ds_next = SmDebugSettings; SmDebugSettings = s; sm_debug_reset(); } /* ** PARSE_NAMED_SETTING_X -- process a symbolic debug setting ** ** Parameters: ** s -- Points to a non-empty \0 or , terminated string, ** of which the initial character is not a digit. ** ** Returns: ** pointer to terminating \0 or , character. ** ** Exceptions: ** F:sm.heap -- out of memory. ** ** Side Effects: ** adds the setting to the database. */ static const char * parse_named_setting_x(s) const char *s; { const char *pat, *endpat; int level; pat = s; while (*s != '\0' && *s != ',' && *s != '.') ++s; endpat = s; if (*s == '.') { ++s; level = 0; while (isascii(*s) && isdigit(*s)) { level = level * 10 + (*s - '0'); ++s; } if (level < 0) level = 0; } else level = 1; sm_debug_addsetting_x(sm_strndup_x(pat, endpat - pat), level); /* skip trailing junk */ while (*s != '\0' && *s != ',') ++s; return s; } /* ** SM_DEBUG_ADDSETTINGS_X -- process a list of debug options ** ** Parameters: ** s -- a list of debug settings, eg the argument to the ** sendmail -d option. ** ** The syntax of the string s is as follows: ** ** <settings> ::= <setting> | <settings> "," <setting> ** <setting> ::= <categories> | <categories> "." <level> ** <categories> ::= [a-zA-Z_*?][a-zA-Z0-9_*?]* ** ** However, note that we skip over anything we don't ** understand, rather than report an error. ** ** Returns: ** none. ** ** Exceptions: ** F:sm.heap -- out of memory ** ** Side Effects: ** updates the database of debug settings. */ void sm_debug_addsettings_x(s) const char *s; { for (;;) { if (*s == '\0') return; if (*s == ',') { ++s; continue; } s = parse_named_setting_x(s); } } /* ** SM_DEBUG_LOADLEVEL -- Get activation level of the specified debug object. ** ** Parameters: ** debug -- debug object. ** ** Returns: ** Activation level of the specified debug object. ** ** Side Effects: ** Ensures that the debug object is initialized. */ int sm_debug_loadlevel(debug) SM_DEBUG_T *debug; { if (debug->debug_level == SM_DEBUG_UNKNOWN) { SM_DEBUG_SETTING_T *s; for (s = SmDebugSettings; s != NULL; s = s->ds_next) { if (sm_match(debug->debug_name, s->ds_pattern)) { debug->debug_level = s->ds_level; goto initialized; } } debug->debug_level = 0; initialized: debug->debug_next = SmDebugInitialized; SmDebugInitialized = debug; } return (int) debug->debug_level; } /* ** SM_DEBUG_LOADACTIVE -- Activation level reached? ** ** Parameters: ** debug -- debug object. ** level -- level to check. ** ** Returns: ** true iff the activation level of the specified debug ** object >= level. ** ** Side Effects: ** Ensures that the debug object is initialized. */ bool sm_debug_loadactive(debug, level) SM_DEBUG_T *debug; int level; { return sm_debug_loadlevel(debug) >= level; }
Upload File
Create Folder