here comes the big header include rewrite
[monky] / src / smapi.c
index e534e3f..e0ca9e1 100644 (file)
@@ -1,7 +1,7 @@
 /* smapi.c:  conky support for IBM Thinkpad smapi
  *
  * Copyright (C) 2007 Phil Sutter <Phil@nwl.cc>
- * 
+ *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
  * USA.
  *
- * $Id$
- *
  */
-#include "conky.h"
+#define _GNU_SOURCE
+#include "conky.h"     /* text_buffer_size, PACKAGE_NAME, maybe more */
+#include "smapi.h"
+#include "logging.h"
 #include <stdio.h>
-#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 
 #define SYS_SMAPI_PATH "/sys/devices/platform/smapi"
 
@@ -50,7 +53,7 @@ char *smapi_read_str(const char *path)
                fscanf(fp, "%255s\n", str);
                fclose(fp);
        }
-       return strdup(str);
+       return strndup(str, text_buffer_size);
 }
 
 int smapi_read_int(const char *path)