X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Futils.c;h=fd213c2044725993565f8352d9e6e05959d70292;hb=4e2c49755175d05f7f4a3c1c70a42d2eef9d7839;hp=f81c8cf7a118470d9bac799561d31af6b740836c;hpb=344014dd4126727fa3f3f409a9e4a6ccc6a5e28b;p=ppp.git diff --git a/pppd/utils.c b/pppd/utils.c index f81c8cf..fd213c2 100644 --- a/pppd/utils.c +++ b/pppd/utils.c @@ -28,6 +28,10 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -325,6 +329,7 @@ vslprintf(char *buf, int buflen, char *fmt, va_list args) OUTCHAR(c); } continue; +#ifndef UNIT_TEST case 'P': /* print PPP packet */ bufinfo.ptr = buf; bufinfo.len = buflen + 1; @@ -334,6 +339,7 @@ vslprintf(char *buf, int buflen, char *fmt, va_list args) buf = bufinfo.ptr; buflen = bufinfo.len - 1; continue; +#endif case 'B': p = va_arg(args, unsigned char *); for (n = prec; n > 0; --n) { @@ -428,6 +434,7 @@ log_packet(u_char *p, int len, char *prefix, int level) } #endif /* unused */ +#ifndef UNIT_TEST /* * format_packet - make a readable representation of a packet, * calling `printer(arg, format, ...)' to output it. @@ -473,6 +480,7 @@ format_packet(u_char *p, int len, printer_func printer, void *arg) else printer(arg, "%.*B", len, p); } +#endif /* UNIT_TEST */ /* * init_pr_log, end_pr_log - initialize and finish use of pr_log. @@ -599,6 +607,7 @@ logit(int level, char *fmt, va_list args) log_write(level, buf); } +#ifndef UNIT_TEST static void log_write(int level, char *buf) { @@ -613,6 +622,13 @@ log_write(int level, char *buf) log_to_fd = -1; } } +#else +static void +log_write(int level, char *buf) +{ + printf("<%d>: %s\n", level, buf); +} +#endif /* * fatal - log an error message and die horribly. @@ -627,7 +643,11 @@ fatal(char *fmt, ...) logit(LOG_ERR, fmt, pvar); va_end(pvar); +#ifndef UNIT_TEST die(1); /* as promised */ +#else + exit(-1); +#endif } /* @@ -731,6 +751,8 @@ dump_packet(const char *tag, unsigned char *p, int len) dbglog("%s %P", tag, p, len); } + +#ifndef UNIT_TEST /* * complete_read - read a full `count' bytes from fd, * unless end-of-file or an error other than EINTR is encountered. @@ -756,6 +778,7 @@ complete_read(int fd, void *buf, size_t count) } return done; } +#endif /* Procedures for locking the serial device using a lock file. */ #ifndef LOCK_DIR