MCPcopy Create free account
hub / github.com/apache/httpd / log_file_line

Function log_file_line

server/log.c:746–787  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

744}
745
746static int log_file_line(const ap_errorlog_info *info, const char *arg,
747 char *buf, int buflen)
748{
749 if (info->file == NULL) {
750 return 0;
751 }
752 else {
753 const char *file = info->file;
754#if defined(_OSD_POSIX) || defined(WIN32) || defined(__MVS__)
755 char tmp[256];
756 char *e = strrchr(file, '/');
757#ifdef WIN32
758 if (!e) {
759 e = strrchr(file, '\\');
760 }
761#endif
762
763 /* In OSD/POSIX, the compiler returns for __FILE__
764 * a string like: __FILE__="*POSIX(/usr/include/stdio.h)"
765 * (it even returns an absolute path for sources in
766 * the current directory). Here we try to strip this
767 * down to the basename.
768 */
769 if (e != NULL && e[1] != '\0') {
770 apr_snprintf(tmp, sizeof(tmp), "%s", &e[1]);
771 e = &tmp[strlen(tmp)-1];
772 if (*e == ')') {
773 *e = '\0';
774 }
775 file = tmp;
776 }
777#else /* _OSD_POSIX || WIN32 */
778 const char *p;
779 /* On Unix, __FILE__ may be an absolute path in a
780 * VPATH build. */
781 if (file[0] == '/' && (p = ap_strrchr_c(file, '/')) != NULL) {
782 file = p + 1;
783 }
784#endif /*_OSD_POSIX || WIN32 */
785 return apr_snprintf(buf, buflen, "%s(%d)", file, info->line);
786 }
787}
788
789static int log_apr_status(const ap_errorlog_info *info, const char *arg,
790 char *buf, int buflen)

Callers 1

do_errorlog_defaultFunction · 0.85

Calls 1

ap_strrchr_cFunction · 0.85

Tested by

no test coverage detected