Source

netplug / lib.c

Diff from to

File lib.c

  *
  * Copyright 2003 PathScale, Inc.
  * Copyright 2003, 2004 Bryan O'Sullivan
+ * Copyright 2003 Jeremy Fitzhardinge
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License,
     va_list ap;
     va_start(ap, fmt);
 
+    if (pri == LOG_DEBUG && !debug)
+        return;
+
     if (use_syslog) {
         vsyslog(pri, fmt, ap);
     } else {
         case LOG_NOTICE:
             fputs("Notice: ", fp);
             break;
+        case LOG_CRIT:
         case LOG_ERR:
             fputs("Error: ", fp);
             break;
         return pid;
     }
 
-    setpgrp();			/* become group leader */
+    setpgrp();                  /* become group leader */
 
-    do_log(LOG_INFO, "%s %s %s -> %d", NP_SCRIPT, ifname, action, getpid());
+    do_log(LOG_INFO, "%s %s %s -> pid %d",
+           NP_SCRIPT, ifname, action, getpid());
 
     execl(NP_SCRIPT, NP_SCRIPT, ifname, action, NULL);
 
     return WIFEXITED(status) ? WEXITSTATUS(status) : -WTERMSIG(status);
 }
 
-/* 
+
+/*
    Synchronously kill a script
 
    Assumes the pid is actually a leader of a group.  Kills first with
     sigset_t mask, origmask;
 
     if (pid == -1)
-	return;
+        return;
 
     assert(pid > 0);
-    
+
     /* Block SIGCHLD while we go around killing things, so the SIGCHLD
        handler doesn't steal things behind our back. */
     sigemptyset(&mask);
 
     /* ask nicely */
     if (killpg(pid, SIGTERM) == -1) {
-	do_log(LOG_ERR, "Can't kill script pgrp %d: %m", pid);
-	goto done;
+        do_log(LOG_ERR, "Can't kill script pgrp %d: %m", pid);
+        goto done;
     }
 
     sleep(1);
     ret = waitpid(pid, &status, WNOHANG);
 
     if (ret == -1) {
-	do_log(LOG_ERR, "Failed to wait for %d: %m?!", pid);
-	goto done;
+        do_log(LOG_ERR, "Failed to wait for %d: %m?!", pid);
+        goto done;
     } else if (ret == 0) {
-	/* no more Mr. nice guy */
-	if (killpg(pid, SIGKILL) == -1) {
-	    do_log(LOG_ERR, "2nd kill %d failed: %m?!", pid);
-	    goto done;
-	}
-	ret = waitpid(pid, &status, 0);
-    } 
+        /* no more Mr. nice guy */
+        if (killpg(pid, SIGKILL) == -1) {
+            do_log(LOG_ERR, "2nd kill %d failed: %m?!", pid);
+            goto done;
+        }
+        ret = waitpid(pid, &status, 0);
+    }
 
     assert(ret == pid);
 
     sigprocmask(SIG_SETMASK, &origmask, NULL);
 }
 
+
 void *
 xmalloc(size_t n)
 {
 }
 
 
+void
+__assert_fail(const char *assertion, const char *file,
+              unsigned int line, const char *function)
+{
+    do_log(LOG_CRIT, "%s:%u: %s%sAssertion `%s' failed",
+           file, line,
+           function ? function : "",
+           function ? ": " : "",
+           assertion);
+
+    abort();
+}
+
+
 /*
  * Local variables:
  * c-file-style: "stroustrup"