Commits

William Giokas committed 5effae1

Added information to functions.

Formatted a few things to be the less than 80 char wide.
2 line -v output.

Signed-off-by: William Giokas <1007380@gmail.com>

Comments (0)

Files changed (5)

 main(int argc, char *argv[])
 {
     if(argc == 2 && !strcmp("-v", argv[1])) {
-        printf("dwmstatus %s © 2012-2013 William Giokas. See LICENSE for more info.\n",
+        printf(
+            "dwmstatus %s © 2012-2013 William Giokas.\n\
+              See LICENSE for more details.\n",
                 VERSION);
         return 0;
     }

include/battery.h

  * according to a random scheme. So just check for both possibilities.
  */
 
+/**
+ * Calculates the battery useage and time remaining
+ * Takes the base directory to find your battery information
+ * as an argument.
+ */
+
 char *
 getbattery(char *base)
 {
     if (seconds < 0 || minutes < 0 || hours < 0)
         ret = smprintf("%s: Calculating...", stat);
     else
-        ret = smprintf("%s: %.2lf%% %02d:%02d:%02d", stat, (((double)remcap / (double)descap) * 100), hours, minutes, seconds);
+        ret = smprintf("%s: %.2lf%% %02d:%02d:%02d", stat,
+            (((double)remcap / (double)descap) * 100), hours, minutes, seconds);
     if(!stat) { free(stat); }
     return ret;
 }

include/network.h

         char *host, size_t hostlen,
         char *serv, size_t servlen, int flags);
 
+/**
+ * Used to parse the /proc/net/dev file to get the network useage.
+ */
+
 int 
-parse_netdev(unsigned long long int *receivedabs, unsigned long long int *sentabs, char *netdevice)
+parse_netdev(unsigned long long int *receivedabs,
+    unsigned long long int *sentabs, char *netdevice)
 {
     char *buf;
     char *netstart;
     while (fgets(buf, bufsize, devfd)) {
         if ((netstart = strstr(buf, netdevice)) != NULL) {
             netdevlength = sizeof(netdevice) / sizeof(char);
-            /* With thanks to the conky project at http://conky.sourceforge.net/ */
-            sscanf(netstart + netdevlength, "%llu  %*d     %*d  %*d  %*d  %*d   %*d        %*d       %llu",\
+            /* Thanks to the conky project: http://conky.sourceforge.net/ */
+            sscanf(netstart + netdevlength,
+                "%llu  %*d     %*d  %*d  %*d  %*d   %*d        %*d       %llu",
                    receivedabs, sentabs);
             fclose(devfd);
             free(buf);
     return 1;
 }
 
+/**
+ * Calculates the per second network useage.
+ * Note: This function takes 1 (one) second to execute,
+ * so take that into account in your status formatting.
+ * (Subtract one from the refresh rate you want to get
+ * the refresh rate you should be using.
+ */
+
 char *
 get_netusage(char *netdevice)
 {
     return retstr;
 }
 
+/**
+ * Gets your current ip address on 'interface'
+ * Shamelessly taken from i3status, because i3status is
+ * pretty awesome.
+ */
 char *
 get_ip_addr(const char *interface)
 {
             }
 
         int ret;
-    if ((ret = getnameinfo(addrp->ifa_addr, len, part, sizeof(part), NULL, 0, NI_NUMERICHOST)) != 0) {
-            fprintf(stderr, "dwmstatus: getnameinfo(): %s\n", gai_strerror(ret));
+    if ((ret = getnameinfo(addrp->ifa_addr, len, part, sizeof(part), NULL, 0,
+            NI_NUMERICHOST)) != 0) {
+            fprintf(stderr, "dwmstatus: getnameinfo(): %s\n",
+                gai_strerror(ret));
             freeifaddrs(ifaddr);
             return "no IP";
         }
 /*
  * TEMPERATURE STUFF
  */
+
+/**
+ * Gets the temperature of your system.
+ * Takes the sensor base and sensor as arguments.
+ */
+
 char *
 gettemperature(char *base, char *sensor)
 {
 #include <sys/time.h>
 #include <time.h>
 
-
 static Display *dpy;
 
+/**
+ * return formatted string
+ * see printf(3)
+ */
+
 char *
 smprintf(char *fmt, ...)
 {
     return ret;
 }
 
+/**
+ * sets your timezone
+ */
+
 void
 settz(char *tzname)
 {
     setenv("TZ", tzname, 1);
 }
 
+/**
+ * returns the actual time
+ */
+
 char *
 mktimes(char *fmt, char *tzname)
 {
     return smprintf("%s", buf);
 }
 
+/**
+ * for setting the status
+ */
+
 void
 setstatus(char *str)
 {
     XSync(dpy, False);
 }
 
+/**
+ * gets and returns the load average as a set of three
+ * space separated values
+ */
+
 char *
 loadavg(void)
 {
     return smprintf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]);
 }
 
+/**
+ * read a file and return the contents
+ * used in battery.h
+ */
+
 char *
 readfile(char *base, char *file)
 {
     return smprintf("%s", line);
 }
 
+/**
+ * used to run a command at different intervals than the main
+ * status command.
+ */
+
 int
 runevery(time_t *ltime, int sec)
 {