* OpenBSD support added to Conky (thanks hifi)
authorBrenden Matthews <brenden1@rty.ca>
Thu, 1 Mar 2007 01:43:43 +0000 (01:43 +0000)
committerBrenden Matthews <brenden1@rty.ca>
Thu, 1 Mar 2007 01:43:43 +0000 (01:43 +0000)
    * Updated mboxscan stuff (thanks calmar)

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@848 7f574dfc-610e-0410-a909-a81674777703

AUTHORS
ChangeLog
configure.ac.in
src/Makefile.am
src/conky.c
src/conky.h
src/mboxscan.c
src/mixer.c

diff --git a/AUTHORS b/AUTHORS
index 92f698d..ea0ed57 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -75,6 +75,9 @@ Gwenhael LE MOINE <cycojesus at yahoo dot fr>
 Hannu Saransaari <hipo at users dot sourceforge dot net>
   Main code
 
+hifi <anon>
+  OpenBSD support
+
 Jason Mitchell <jason.mitchell03 at saintleo dot edu>
   developer
   UTF8 fix
index 2961707..b7a476a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
 # $Id$
 
 2007-02-25
+       * OpenBSD support added to Conky (thanks hifi)
+       * Updated mboxscan stuff (thanks calmar)
+
+2007-02-25
        * Created branch/1.5 copy of trunk/conky1.  Removing all experimental
          network code from trunk/conky1.
 
index 7b23aab..af8bb32 100644 (file)
@@ -59,10 +59,10 @@ case $uname in
 #    WANT_OSSLIB=yes
 #    ;;
 
-#  OpenBSD*)
-#    WANT_KVM=yes
-#    WANT_OSSLIB=yes
-#    ;;
+  OpenBSD*)
+    WANT_KVM=yes
+    WANT_OSSLIB=yes
+    ;;
 
 # Solaris doesn't work at all right now
 #  SunOS*)
@@ -80,7 +80,7 @@ AM_CONDITIONAL(BUILD_LINUX, test x$uname = xLinux)
 #AM_CONDITIONAL(BUILD_SOLARIS, test x$uname = xSunOS)
 AM_CONDITIONAL(BUILD_FREEBSD, test x$uname = xFreeBSD)
 #AM_CONDITIONAL(BUILD_NETBSD, test x$uname = xNetBSD)
-# AM_CONDITIONAL(BUILD_OPENBSD, test x$uname = xOpenBSD)
+AM_CONDITIONAL(BUILD_OPENBSD, test x$uname = xOpenBSD)
 
 BUILD_DATE=$(LANG=en_US LC_ALL=en_US LOCALE=en_US date)
 BUILD_ARCH="$(uname -sr) ($(uname -m))"
index 3e63d75..72b323a 100644 (file)
@@ -34,6 +34,11 @@ endif
 #netbsd = netbsd.c
 #endif
 
+if BUILD_OPENBSD
+openbsd = openbsd.c
+PTHREAD_LIBS =  -pthread
+endif
+
 if BUILD_PORT_MONITORS
 port_monitors = libtcp-portmon.h libtcp-portmon.c
 endif
@@ -60,6 +65,7 @@ conky_SOURCES =               \
        mixer.c                 \
        $(mpd)                  \
        $(netbsd)               \
+       $(openbsd)              \
        $(port_monitors)        \
        $(solaris)              \
        timed_thread.c          \
@@ -84,6 +90,7 @@ EXTRA_DIST =                  \
        libtcp-portmon.h        \
        mpd.c                   \
        netbsd.c                \
+       openbsd.c               \
        solaris.c               \
        top.h                   \
        x11.c                   \
index 53fd0bc..07984de 100644 (file)
@@ -313,6 +313,10 @@ static int maximum_width;
 
 #endif /* X11 */
 
+#ifdef __OpenBSD__
+static int sensor_device;
+#endif
+
 /* maximum number of special things, e.g. fonts, offsets, aligns, etc. */
 static unsigned int max_specials = MAX_SPECIALS_DEFAULT;
 
@@ -565,6 +569,18 @@ long fwd_fcharfind(FILE* fp, char val, unsigned int step) {
 #undef BUFSZ
 }
 
+#ifdef __OpenBSD__
+void *
+memrchr (const void *buffer, int c, size_t n)
+{
+       const unsigned char *p = buffer;
+
+       for (p += n; n ; n--)
+               if (*--p == c)
+                       return p;
+       return NULL;
+}
+#endif
 long rev_fcharfind(FILE* fp, char val, unsigned int step) {
 #define BUFSZ 0x1000
        long ret = -1;
@@ -1037,6 +1053,13 @@ enum text_object_type {
        OBJ_apm_battery_time,
        OBJ_apm_battery_life,
 #endif /* __FreeBSD__ */
+#ifdef __OpenBSD__
+       OBJ_obsd_sensors_temp,
+       OBJ_obsd_sensors_fan,
+       OBJ_obsd_sensors_volt,
+       OBJ_obsd_vendor,
+       OBJ_obsd_product,
+#endif /* __OpenBSD__ */
 #ifdef MPD
        OBJ_mpd_title,
        OBJ_mpd_artist,
@@ -2167,6 +2190,37 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
                 }
 
 #endif /* __linux__ */
+#if defined(__OpenBSD__)
+       END OBJ(obsd_sensors_temp, 0);
+               if(!arg) {
+                       CRIT_ERR("obsd_sensors_temp: needs an argument");
+               }
+               if(!isdigit(arg[0]) || atoi(&arg[0]) < 0 || atoi(&arg[0]) > OBSD_MAX_SENSORS-1) {
+                       obj->data.sensor=0;
+                       ERR("Invalid temperature sensor number!");
+               }
+                       obj->data.sensor = atoi(&arg[0]);
+       END OBJ(obsd_sensors_fan, 0);
+               if(!arg) {
+                       CRIT_ERR("obsd_sensors_fan: needs 2 arguments (device and sensor number)");
+               }
+               if(!isdigit(arg[0]) || atoi(&arg[0]) < 0 || atoi(&arg[0]) > OBSD_MAX_SENSORS-1) {
+                       obj->data.sensor=0;
+                       ERR("Invalid fan sensor number!");
+               }
+                       obj->data.sensor = atoi(&arg[0]);
+       END OBJ(obsd_sensors_volt, 0);
+               if(!arg) {
+                       CRIT_ERR("obsd_sensors_volt: needs 2 arguments (device and sensor number)");
+               }
+               if(!isdigit(arg[0]) || atoi(&arg[0]) < 0 || atoi(&arg[0]) > OBSD_MAX_SENSORS-1) {
+                       obj->data.sensor=0;
+                       ERR("Invalid voltage sensor number!");
+               }
+                       obj->data.sensor = atoi(&arg[0]);
+       END OBJ(obsd_vendor, 0);
+       END OBJ(obsd_product, 0);
+#endif /* __OpenBSD__ */
                END OBJ(buffers, INFO_BUFFERS)
                END OBJ(cached, INFO_BUFFERS)
                END OBJ(cpu, INFO_CPU)
@@ -2667,6 +2721,8 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
                END OBJ(mboxscan, 0)
                obj->data.mboxscan.args = (char*)malloc(TEXT_BUFFER_SIZE);
                obj->data.mboxscan.output = (char*)malloc(text_buffer_size);
+               /* if '1' (in mboxscan.c) then there was SIGUSR1, hmm */
+               obj->data.mboxscan.output[0] = 1;
                strncpy(obj->data.mboxscan.args, arg, TEXT_BUFFER_SIZE);
                END OBJ(mem, INFO_MEM)
                END OBJ(memmax, INFO_MEM)
@@ -3450,6 +3506,37 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                 }
 #endif /* __linux__ */
 
+#ifdef __OpenBSD__
+                               OBJ(obsd_sensors_temp) {
+                                       obsd_sensors.device = sensor_device;
+                                       update_obsd_sensors();
+                                       snprintf(p, p_max_size, "%.1f",
+                                               obsd_sensors.temp[obsd_sensors.device][obj->data.sensor]);
+                               }
+
+                               OBJ(obsd_sensors_fan) {
+                                       obsd_sensors.device = sensor_device;
+                                       update_obsd_sensors();
+                                       snprintf(p, p_max_size, "%d",
+                                               obsd_sensors.fan[obsd_sensors.device][obj->data.sensor]);
+                               }
+
+                               OBJ(obsd_sensors_volt) {
+                                       obsd_sensors.device = sensor_device;
+                                       update_obsd_sensors();
+                                       snprintf(p, p_max_size, "%.2f",
+                                               obsd_sensors.volt[obsd_sensors.device][obj->data.sensor]);
+                               }
+
+                               OBJ(obsd_vendor) {
+                                       get_obsd_vendor(p, p_max_size);
+                               }
+
+                               OBJ(obsd_product) {
+                                       get_obsd_product(p, p_max_size);
+                               }
+#endif /* __OpenBSD__ */
+
 #ifdef X11
                                OBJ(font) {
                                        new_font(p, obj->data.s);
@@ -4174,7 +4261,7 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                snprintf(p, p_max_size, "%d", cur->mail_count);
                        }
                        OBJ(mboxscan) {
-                               mbox_scan(obj->data.mboxscan.args, obj->data.mboxscan.output, text_buffer_size);
+                mbox_scan(obj->data.mboxscan.args, obj->data.mboxscan.output, TEXT_BUFFER_SIZE);
                                snprintf(p, p_max_size, "%s", obj->data.mboxscan.output);
                        }
                        OBJ(new_mails) {
@@ -6461,6 +6548,14 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
                                CONF_ERR;
                }
 #endif
+#ifdef __OpenBSD__
+               CONF("sensor_device") {
+                       if(value)
+                               sensor_device = strtol(value, 0, 0);
+                       else
+                               CONF_ERR;
+               }
+#endif
                CONF("cpu_avg_samples") {
                        if (value) {
                                cpu_avg_samples = strtol(value, 0, 0);
index 4d157ad..a9c0650 100644 (file)
 #include <machine/apm_bios.h>
 #endif /* __FreeBSD__ */
 
+#if defined(__OpenBSD__)
+#include <sys/sysctl.h>
+#include <sys/sensors.h>
+#endif /* __OpenBSD__ */
+
 #ifdef AUDACIOUS
 #include "audacious.h"
 #endif
@@ -488,6 +493,22 @@ struct ibm_acpi_struct {
 
 struct ibm_acpi_struct ibm_acpi;
 
+#if defined(__OpenBSD__)
+void update_obsd_sensors(void);
+void get_obsd_vendor(char *buf, size_t client_buffer_size);
+void get_obsd_product(char *buf, size_t client_buffer_size);
+
+#define OBSD_MAX_SENSORS 256
+struct obsd_sensors_struct {
+       int device;
+       float temp[MAXSENSORDEVICES][OBSD_MAX_SENSORS];
+       unsigned int fan[MAXSENSORDEVICES][OBSD_MAX_SENSORS];
+       float volt[MAXSENSORDEVICES][OBSD_MAX_SENSORS];
+};
+struct obsd_sensors_struct obsd_sensors;
+#endif /* __OpenBSD__ */
+
+
 enum { PB_BATT_STATUS, PB_BATT_PERCENT, PB_BATT_TIME};
 void get_powerbook_batt_info(char*, size_t, int);
 
index d11bd0f..7387441 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * $Id$
  * 
- * Licence: http://www.opensource.org/licenses/bsd-license.php
- * author: mac@calmar.ws
+ * Licence: see LICENSE
+ * author: mac@calmar.ws Marco Candrian
  * 
  * Modified for use in Conky by Brenden Matthews
  *
  * scanning from top to bottom on a mbox
  * The output as follows:
  * F: FROM_LENGHT S: SUBJECT_LENGHT
- * (PRINT_MAILS or -n NR times)
+ *
+ * Usage: ${mboxscan [-n <number of messages to print>] 
+ *                   [-fw <from width>] [-sw <subject width>] 
+ *                   [-t <minumum delay in sec> "mbox" }
  */
 
 #include "conky.h"
 #include <sys/stat.h>
+#include <sys/time.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -24,6 +28,7 @@
 #define FROM_WIDTH 10
 #define SUBJECT_WIDTH 22
 #define PRINT_MAILS 5
+#define TIME_DELAY 5
 
 struct ring_list {
        char *from;
@@ -32,68 +37,146 @@ struct ring_list {
        struct ring_list *next;
 };
 
+static time_t last_ctime;      /* needed for mutt at least */
+static time_t last_mtime;      /* not sure what to test: testing both now */
+static double last_update;
+
+static int args_ok = 0;
+static int from_width;
+static int subject_width;
+static int print_mails;
+static int time_delay;
+
+/*
+ * I don't know what to use: TEXT_BUFFER_SIZE or text_buffer_size
+ * text_buffer_size is the maximum output in chars
+ * TEXT_BUFFER_SIZE actually something like a allowed size
+ * for things in the config, below 'TEXT'. Or what is more probably
+ * max_user_text. Anyway, I used TEXT_BUFFER_SIZE for not 'output' things here
+ * -- calmar
+ *
+ *  To clarify, TEXT_BUFFER_SIZE is used for buffers of fixed size, and 
+ *  text_buffer_size is used for buffers which can change in size.
+ *  text_buffer_size is just defined as TEXT_BUFFER_SIZE to start,
+ *  so its okay for most things, however if something is allocated
+ *  with text_buffer_size and then text_buffer_size changes but
+ *  the array doesn't, you might have some issues if you are using
+ *  text_buffer_size to determine the size of the array.
+ *  -- brenden
+ */
+
+static char mbox_mail_spool[TEXT_BUFFER_SIZE];
+
 void mbox_scan(char *args, char *output, size_t max_len)
 {
        int i, u, flag;
-       int from_width, subject_width, print_mails;
+       int force_rescan = 0;
        char buf[text_buffer_size];
+       struct stat statbuf;
+
+       /* output was set to 1 after malloc'ing in conky.c */
+       /* -> beeing able to test it here for catching SIGUSR1 */
+       if (output[0] == 1) {
+               force_rescan = 1;
+               output[0] = '\0';
+       }
+
+       if (!args_ok || force_rescan) {
 
-       char *substr = strstr(args, "-n");
-       if (substr) {
-               if (sscanf(substr, "-n %i", &print_mails) != 1) {
+               char *substr = strstr(args, "-n");
+               if (substr) {
+                       if (sscanf(substr, "-n %i", &print_mails) != 1) {
+                               print_mails = PRINT_MAILS;
+                       }
+               } else {
                        print_mails = PRINT_MAILS;
                }
-       } else {
-               print_mails = PRINT_MAILS;
-       }
-       substr = strstr(args, "-fw");
-       if (substr) {
-               if (sscanf(substr, "-fw %i", &from_width) != 1) {
+               if (print_mails < 1)
+                       print_mails = 1;
+
+               substr = strstr(args, "-t");
+               if (substr) {
+                       if (sscanf(substr, "-t %i", &time_delay) != 1) {
+                               time_delay = TIME_DELAY;
+                       }
+               } else {
+                       time_delay = TIME_DELAY;
+               }
+
+               substr = strstr(args, "-fw");
+               if (substr) {
+                       if (sscanf(substr, "-fw %i", &from_width) != 1) {
+                               from_width = FROM_WIDTH;
+                       }
+               } else {
                        from_width = FROM_WIDTH;
                }
-       } else {
-               from_width = FROM_WIDTH;
-       }
-       substr = strstr(args, "-sw");
-       if (substr) {
-               if (sscanf(substr, "-sw %i", &subject_width) != 1) {
+
+               substr = strstr(args, "-sw");
+               if (substr) {
+                       if (sscanf(substr, "-sw %i", &subject_width) != 1) {
+                               subject_width = SUBJECT_WIDTH;
+                       }
+               } else {
                        subject_width = SUBJECT_WIDTH;
                }
-       } else {
-               subject_width = SUBJECT_WIDTH;
-       }
-       char current_mail_spool[text_buffer_size];
-       if (args[strlen(args) - 1] == '"') { // encapsulated with "'s
-               // find first occurrence of "
-               strncpy(current_mail_spool, args, text_buffer_size);
-               char *start = strchr(current_mail_spool, '"') + 1;
-               start[(long)(strrchr(current_mail_spool, '"') - start)] = '\0';
-               strncpy(current_mail_spool, start, text_buffer_size);
-       } else {
-               char *tmp = strtok(args, " ");
-               char *start = tmp;
-               while (tmp) {
-                       tmp = strtok(NULL, " ");
-                       if (tmp) {
-                               start = tmp;
+               /* encapsulated with "'s find first occurrence of " */
+               if (args[strlen(args) - 1] == '"') {
+                       strncpy(mbox_mail_spool, args, TEXT_BUFFER_SIZE);
+                       char *start = strchr(mbox_mail_spool, '"') + 1;
+                       start[(long)(strrchr(mbox_mail_spool, '"') - start)] = '\0';
+                       strncpy(mbox_mail_spool, start, TEXT_BUFFER_SIZE);
+               } else {
+                       char *copy_args = strdup(args);
+                       char *tmp = strtok(copy_args, " ");
+                       char *start = tmp;
+                       while (tmp) {
+                               tmp = strtok(NULL, " ");
+                               if (tmp) {
+                                       start = tmp;
+                               }
                        }
+                       strncpy(mbox_mail_spool, start, TEXT_BUFFER_SIZE);
+                       free(copy_args);
                }
-               strncpy(current_mail_spool, start, text_buffer_size);
-       }
-       //printf("'%s', %i, %i, %i\n", current_mail_spool, subject_width, from_width, print_mails);
-       if (strlen(current_mail_spool) < 1) {
-               CRIT_ERR("Usage: ${mboxscan [-n <number of messages to print>] [-fw <from width>] [-sw <subject width>] mbox}");
+               if (strlen(mbox_mail_spool) < 1) {
+                       CRIT_ERR("Usage: ${mboxscan [-n <number of messages to print>] [-fw <from width>] [-sw <subject width>] [-t <delay in sec> mbox}");
+               }
+
+               /* allowing $MAIL in the config */
+               if (!strcmp(mbox_mail_spool, "$MAIL")) {
+                       strcpy(mbox_mail_spool, current_mail_spool);
+               }
+
+               if (stat(mbox_mail_spool, &statbuf)) {
+                       CRIT_ERR("can't stat %s: %s", mbox_mail_spool, strerror(errno));
+               }
+               args_ok = 1;    /* args-computing necessary only once */
        }
 
-       struct stat statbuf;
+       /* if time_delay not yet reached, then return */
+       if (current_update_time - last_update < time_delay && !force_rescan)
+               return;
+
+       last_update = current_update_time;
+
+       /* mbox still exists? and get stat-infos */
+       if (stat(mbox_mail_spool, &statbuf)) {
+               ERR("can't stat %s: %s", mbox_mail_spool, strerror(errno));
+               output[0] = '\0';       /* delete any output */
+               return;
+       }
 
-       if (stat(current_mail_spool, &statbuf)) {
-               CRIT_ERR("can't stat %s: %s", current_mail_spool, strerror(errno));
+       /* modification time has not changed, so skip scanning the box */
+       if (statbuf.st_ctime == last_ctime && statbuf.st_mtime == last_mtime && !force_rescan) {
+               return;
        }
-       /* end - argument checking */
 
-       /* build up double-linked ring-list to hold data, while scanning down the mbox */
-       struct ring_list *curr=0, *prev=0, *start=0;
+       last_ctime = statbuf.st_ctime;
+       last_mtime = statbuf.st_mtime;
+
+       /* build up double-linked ring-list to hold data, while scanning down * the mbox */
+       struct ring_list *curr = 0, *prev = 0, *startlist = 0;
 
        for (i = 0; i < print_mails; i++) {
                curr = (struct ring_list *)malloc(sizeof(struct ring_list));
@@ -103,7 +186,7 @@ void mbox_scan(char *args, char *output, size_t max_len)
                curr->subject[0] = '\0';
 
                if (i == 0)
-                       start = curr;
+                       startlist = curr;
                if (i > 0) {
                        curr->previous = prev;
                        prev->next = curr;
@@ -112,18 +195,18 @@ void mbox_scan(char *args, char *output, size_t max_len)
        }
 
        /* connect end to start for an endless loop-ring */
-       start->previous = curr;
-       curr->next = start;
+       startlist->previous = curr;
+       curr->next = startlist;
 
        /* mbox */
        FILE *fp;
 
-       fp = fopen(current_mail_spool, "r");
+       fp = fopen(mbox_mail_spool, "r");
        if (!fp) {
                return;
        }
 
-       flag = 1;               /* frist find a "From " to set it to 0 for header-sarchings */
+       flag = 1;               /* first find a "From " to set it to 0 for header-sarchings */
        while (!feof(fp)) {
                if (fgets(buf, text_buffer_size, fp) == NULL)
                        break;
@@ -146,6 +229,7 @@ void mbox_scan(char *args, char *output, size_t max_len)
                if (buf[0] == '\n') {
                        /* beyond the headers now (empty line), skip until \n */
                        /* then search for new mail ("From ") */
+
                        while (strchr(buf, '\n') == NULL && !feof(fp))
                                fgets(buf, text_buffer_size, fp);
                        flag = 1;       /* in the body now */
@@ -157,17 +241,17 @@ void mbox_scan(char *args, char *output, size_t max_len)
 
                        /* Mail was read or something, so skip that message */
                        flag = 1;       /* search for next From */
-                       curr->subject[0] = '0';
-                       curr->from[0] = '0';
-                       curr = curr->previous;  /* (will get current again on new 'From ' finding) */
+                       curr->subject[0] = '\0';
+                       curr->from[0] = '\0';
+                       curr = curr->previous;  /* (will get current again on new * 'From ' finding) */
                        /* Skip until \n */
                        while (strchr(buf, '\n') == NULL && !feof(fp))
                                fgets(buf, text_buffer_size, fp);
                        continue;
                }
 
-               /* that covers ^From: and ^from: */
-               if (strncmp(buf + 1, "rom: ", 5) == 0) {
+               /* that covers ^From: and ^from: ^From:<tab> */
+               if (strncmp(buf + 1, "rom:", 4) == 0) {
 
                        i = 0;
                        u = 6;  /* no "From: " string needed, so skip */
@@ -178,7 +262,7 @@ void mbox_scan(char *args, char *output, size_t max_len)
                                        continue;
                                }
 
-                               if (buf[u] == '<' && i > 1) {   /* some are: From: <foo@bar.com> */
+                               if (buf[u] == '<' && i > 1) {   /* some are: From: * <foo@bar.com> */
 
                                        curr->from[i] = '\0';
                                        /* skip until \n */
@@ -210,8 +294,8 @@ void mbox_scan(char *args, char *output, size_t max_len)
                        }
                }
 
-               /* that covers ^Subject and ^subject */
-               if (strncmp(buf + 1, "ubject: ", 8) == 0) {
+               /* that covers ^Subject: and ^subject: and ^Subjec:<tab> */
+               if (strncmp(buf + 1, "ubject:", 7) == 0) {
 
                        i = 0;
                        u = 9;  /* no "Subject: " string needed, so skip */
@@ -243,20 +327,28 @@ void mbox_scan(char *args, char *output, size_t max_len)
 
        fclose(fp);
 
-       i = print_mails;
        output[0] = '\0';
-       while (curr->from[0] != '\0') {
-               snprintf(buf, text_buffer_size, "F: %-*s S: %-*s\n", from_width, curr->from, subject_width, curr->subject);
+       struct ring_list *tmp;
+       i = print_mails;
+       while (i) {
+               if (curr->from[0] != '\0') {
+                       if (i != print_mails) {
+                               snprintf(buf, text_buffer_size, "\nF: %-*s S: %-*s", from_width, curr->from, subject_width, curr->subject);
+                       } else {        /* first time - no \n in front */
+                               snprintf(buf, text_buffer_size, "F: %-*s S: %-*s", from_width, curr->from, subject_width, curr->subject);
+                       }
+
+               } else {
+                       snprintf(buf, text_buffer_size, "\n");
+               }
                strncat(output, buf, max_len - strlen(output));
-/*             printf("F: %-*s", from_width, curr->from);
-               printf(" S: %-*s\n", subject_width, curr->subject);*/
-               free(curr->from);
-               free(curr->subject);
-               struct ring_list *old = curr;
-               free(old);
+
+               tmp = curr;
                curr = curr->previous;
-               if (--i == 0) {
-                       break;
-               }
+               free(tmp->from);
+               free(tmp->subject);
+               free(tmp);
+
+               i--;
        }
 }
index 3c85ffd..d5950de 100644 (file)
 #ifdef HAVE_LINUX_SOUNDCARD_H
 #include <linux/soundcard.h>
 #else
+#ifdef __OpenBSD__
+#include <soundcard.h>
+#else
 #include <sys/soundcard.h>
+#endif                         /* __OpenBSD__ */
 #endif                         /* HAVE_LINUX_SOUNDCARD_H */
 
 #define MIXER_DEV "/dev/mixer"