William Giokas avatar William Giokas committed 7543fd3

Replace tabs with spaces

It just gets annoying. Hell, I'm the only person who cares about this
thing anyway, and I use spaces.

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

Comments (0)

Files changed (1)

 char *
 smprintf(char *fmt, ...)
 {
-	va_list fmtargs;
-	char *ret;
-	int len;
+    va_list fmtargs;
+    char *ret;
+    int len;
 
-	va_start(fmtargs, fmt);
-	len = vsnprintf(NULL, 0, fmt, fmtargs);
-	va_end(fmtargs);
+    va_start(fmtargs, fmt);
+    len = vsnprintf(NULL, 0, fmt, fmtargs);
+    va_end(fmtargs);
 
-	ret = malloc(++len);
-	if (ret == NULL) {
-		perror("malloc");
-		exit(1);
-	}
+    ret = malloc(++len);
+    if (ret == NULL) {
+        perror("malloc");
+        exit(1);
+    }
 
-	va_start(fmtargs, fmt);
-	vsnprintf(ret, len, fmt, fmtargs);
-	va_end(fmtargs);
+    va_start(fmtargs, fmt);
+    vsnprintf(ret, len, fmt, fmtargs);
+    va_end(fmtargs);
 
-	return ret;
+    return ret;
 }
 
 void
 settz(char *tzname)
 {
-	setenv("TZ", tzname, 1);
+    setenv("TZ", tzname, 1);
 }
 
 char *
 mktimes(char *fmt, char *tzname)
 {
-	char buf[129];
-	time_t tim;
-	struct tm *timtm;
-
-	memset(buf, 0, sizeof(buf));
-	settz(tzname);
-	tim = time(NULL);
-	timtm = localtime(&tim);
-	if (timtm == NULL) {
-		perror("localtime");
-		exit(1);
-	}
-
-	if (!strftime(buf, sizeof(buf)-1, fmt, timtm)) {
-		fprintf(stderr, "strftime == 0\n");
-		exit(1);
-	}
-
-	return smprintf("%s", buf);
+    char buf[129];
+    time_t tim;
+    struct tm *timtm;
+
+    memset(buf, 0, sizeof(buf));
+    settz(tzname);
+    tim = time(NULL);
+    timtm = localtime(&tim);
+    if (timtm == NULL) {
+        perror("localtime");
+        exit(1);
+    }
+
+    if (!strftime(buf, sizeof(buf)-1, fmt, timtm)) {
+        fprintf(stderr, "strftime == 0\n");
+        exit(1);
+    }
+
+    return smprintf("%s", buf);
 }
 
 void
 setstatus(char *str)
 {
-	XStoreName(dpy, DefaultRootWindow(dpy), str);
-	XSync(dpy, False);
+    XStoreName(dpy, DefaultRootWindow(dpy), str);
+    XSync(dpy, False);
 }
 
 char *
 loadavg(void)
 {
-	double avgs[3];
+    double avgs[3];
 
-	if (getloadavg(avgs, 3) < 0) {
-		perror("getloadavg");
-		exit(1);
-	}
+    if (getloadavg(avgs, 3) < 0) {
+        perror("getloadavg");
+        exit(1);
+    }
 
-	return smprintf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]);
+    return smprintf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]);
 }
 
 char *
 readfile(char *base, char *file)
 {
-	char *path, line[513];
-	FILE *fd;
+    char *path, line[513];
+    FILE *fd;
 
-	memset(line, 0, sizeof(line));
+    memset(line, 0, sizeof(line));
 
-	path = smprintf("%s/%s", base, file);
-	fd = fopen(path, "r");
-	if (fd == NULL)
-		return NULL;
-	free(path);
+    path = smprintf("%s/%s", base, file);
+    fd = fopen(path, "r");
+    if (fd == NULL)
+        return NULL;
+    free(path);
 
-	if (fgets(line, sizeof(line)-1, fd) == NULL)
-		return NULL;
-	fclose(fd);
+    if (fgets(line, sizeof(line)-1, fd) == NULL)
+        return NULL;
+    fclose(fd);
 
-	return smprintf("%s", line);
+    return smprintf("%s", line);
 }
 
 int
 char *
 getbattery(char *base)
 {
-	char *co;
+    char *co;
     char *stat;
     char *ret;
     char status;
-	int descap;
+    int descap;
     int remcap;
     float remaining;
     float using;
     float voltage;
     float current;
 
-	descap = -1;
-	remcap = -1;
+    descap = -1;
+    remcap = -1;
     using  = -1;
     remaining = -1;
     stat = "Not Charging";
 
-	co = readfile(base, "present");
-	if (co == NULL || co[0] != '1') {
-		if (co != NULL) free(co);
-		return smprintf("not present");
-	}
-	free(co);
+    co = readfile(base, "present");
+    if (co == NULL || co[0] != '1') {
+        if (co != NULL) free(co);
+        return smprintf("not present");
+    }
+    free(co);
 
     co = readfile(base, "status");
     if (co == NULL) {
     sscanf(co, "%s", &status);
     free(co);
 
-	co = readfile(base, "charge_full_design");
-	if (co == NULL) {
-		co = readfile(base, "energy_full_design");
-		if (co == NULL)
-			return smprintf("");
-	}
-	sscanf(co, "%d", &descap);
-	free(co);
-
-	co = readfile(base, "charge_now");
-	if (co == NULL) {
-		co = readfile(base, "energy_now");
-		if (co == NULL)
-			return smprintf("");
-	}
-	sscanf(co, "%d", &remcap);
-	free(co);
+    co = readfile(base, "charge_full_design");
+    if (co == NULL) {
+        co = readfile(base, "energy_full_design");
+        if (co == NULL)
+            return smprintf("");
+    }
+    sscanf(co, "%d", &descap);
+    free(co);
+
+    co = readfile(base, "charge_now");
+    if (co == NULL) {
+        co = readfile(base, "energy_now");
+        if (co == NULL)
+            return smprintf("");
+    }
+    sscanf(co, "%d", &remcap);
+    free(co);
 
     co = readfile(base, "power_now"); /* µWattage being used */
     if (co == NULL) {
         free(co);
     }
 
-	if (remcap < 0 || descap < 0)
-		return smprintf("invalid");
+    if (remcap < 0 || descap < 0)
+        return smprintf("invalid");
 
     /* Getting time remaining */
     if (status == 'D') {
 int 
 parse_netdev(unsigned long long int *receivedabs, unsigned long long int *sentabs, char *netdevice)
 {
-	char *buf;
+    char *buf;
     char *netstart;
-	static int bufsize;
-	FILE *devfd;
+    static int bufsize;
+    FILE *devfd;
 
-	buf = (char *) calloc(255, 1);
-	bufsize = 255;
-	devfd = fopen("/proc/net/dev", "r");
+    buf = (char *) calloc(255, 1);
+    bufsize = 255;
+    devfd = fopen("/proc/net/dev", "r");
 
-	/* ignore the first two lines of the file */
-	fgets(buf, bufsize, devfd);
-	fgets(buf, bufsize, devfd);
+    /* ignore the first two lines of the file */
+    fgets(buf, bufsize, devfd);
+    fgets(buf, bufsize, devfd);
 
-	while (fgets(buf, bufsize, devfd)) {
-	    if ((netstart = strstr(buf, netdevice)) != NULL) {
+    while (fgets(buf, bufsize, devfd)) {
+        if ((netstart = strstr(buf, netdevice)) != NULL) {
             int 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",\
-		           receivedabs, sentabs);
-		    fclose(devfd);
-    		free(buf);
-    		return 0;
-	    }
-	}
-	fclose(devfd);
-	free(buf);
-	return 1;
+            sscanf(netstart + netdevlength, "%llu  %*d     %*d  %*d  %*d  %*d   %*d        %*d       %llu",\
+                   receivedabs, sentabs);
+            fclose(devfd);
+            free(buf);
+            return 0;
+        }
+    }
+    fclose(devfd);
+    free(buf);
+    return 1;
 }
 
 char *
 get_netusage(char *netdevice)
 {
-	unsigned long long int oldrec, oldsent, newrec, newsent;
-	double downspeed, upspeed;
-	char *downspeedstr, *upspeedstr;
-	char *retstr;
-	int retval;
-
-	downspeedstr = (char *) malloc(15);
-	upspeedstr = (char *) malloc(15);
-	retstr = (char *) malloc(42);
-
-	retval = parse_netdev(&oldrec, &oldsent, netdevice);
-	if (retval) {
-	    fprintf(stdout, "Error when parsing /proc/net/dev file.\n");
-	    exit(1);
-	}
-
-	sleep(1);
-	retval = parse_netdev(&newrec, &newsent, netdevice);
-	if (retval) {
-	    fprintf(stdout, "Error when parsing /proc/net/dev file.\n");
-	    exit(1);
-	}
-
-	downspeed = (newrec - oldrec) / 1024.0;
-	if (downspeed > 1024.0) {
-	    downspeed /= 1024.0;
-	    sprintf(downspeedstr, "%.3f MB/s", downspeed);
-	} else {
-	    sprintf(downspeedstr, "%.2f KB/s", downspeed);
-	}
-
-	upspeed = (newsent - oldsent) / 1024.0;
-	if (upspeed > 1024.0) {
-	    upspeed /= 1024.0;
-	    sprintf(upspeedstr, "%.3f MB/s", upspeed);
-	} else {
-	    sprintf(upspeedstr, "%.2f KB/s", upspeed);
-	}
-	sprintf(retstr, "%s: d: %s u: %s", netdevice, downspeedstr, upspeedstr);
-
-	free(downspeedstr);
-	free(upspeedstr);
-	return retstr;
+    unsigned long long int oldrec, oldsent, newrec, newsent;
+    double downspeed, upspeed;
+    char *downspeedstr, *upspeedstr;
+    char *retstr;
+    int retval;
+
+    downspeedstr = (char *) malloc(15);
+    upspeedstr = (char *) malloc(15);
+    retstr = (char *) malloc(42);
+
+    retval = parse_netdev(&oldrec, &oldsent, netdevice);
+    if (retval) {
+        fprintf(stdout, "Error when parsing /proc/net/dev file.\n");
+        exit(1);
+    }
+
+    sleep(1);
+    retval = parse_netdev(&newrec, &newsent, netdevice);
+    if (retval) {
+        fprintf(stdout, "Error when parsing /proc/net/dev file.\n");
+        exit(1);
+    }
+
+    downspeed = (newrec - oldrec) / 1024.0;
+    if (downspeed > 1024.0) {
+        downspeed /= 1024.0;
+        sprintf(downspeedstr, "%.3f MB/s", downspeed);
+    } else {
+        sprintf(downspeedstr, "%.2f KB/s", downspeed);
+    }
+
+    upspeed = (newsent - oldsent) / 1024.0;
+    if (upspeed > 1024.0) {
+        upspeed /= 1024.0;
+        sprintf(upspeedstr, "%.3f MB/s", upspeed);
+    } else {
+        sprintf(upspeedstr, "%.2f KB/s", upspeed);
+    }
+    sprintf(retstr, "%s: d: %s u: %s", netdevice, downspeedstr, upspeedstr);
+
+    free(downspeedstr);
+    free(upspeedstr);
+    return retstr;
 }
 
 char *
 int
 status()
 {
-	char *status = NULL;
-	char *avgs = NULL;
+    char *status = NULL;
+    char *avgs = NULL;
     char *time = NULL;
     char *batt = NULL;
     char *net = NULL;
     time_t count60 = 0;
     time_t count10 = 0;
 
-	if (!(dpy = XOpenDisplay(NULL))) {
-		fprintf(stderr, "dwmstatus: cannot open display.\n");
-		return 1;
-	}
+    if (!(dpy = XOpenDisplay(NULL))) {
+        fprintf(stderr, "dwmstatus: cannot open display.\n");
+        return 1;
+    }
 
-	for (;;sleep(1)) {
+    for (;;sleep(1)) {
         /* Update every minute */
         if (runevery(&count60, 60)) {
             free(time);
 
-		    time  = mktimes("%Y/%m/%d %H:%M", TIMEZONE);
+            time  = mktimes("%Y/%m/%d %H:%M", TIMEZONE);
         }
         /* Update every 10 seconds */
         if (runevery(&count10, 10)) {
                 free(ipaddr);
             }
 
-		    avgs   = loadavg();
+            avgs   = loadavg();
             batt   = getbattery(BATT_PATH);
             temp   = gettemperature(TEMP_SENSOR_PATH, TEMP_SENSOR_UNIT);
             ipaddr = get_ip_addr(NET_DEVICE);
         net    = get_netusage(NET_DEVICE);
 
         /* Format of display */
-		status = smprintf("%s (%s) | %s | [%s] | T: %s | %s",
-				net, ipaddr, batt, avgs, temp, time);
+        status = smprintf("%s (%s) | %s | [%s] | T: %s | %s",
+                net, ipaddr, batt, avgs, temp, time);
         free(net);
-		setstatus(status);
+        setstatus(status);
         free(status);
-	}
+    }
     return 0;
 }
 
     }
     else
         status();
-	XCloseDisplay(dpy);
+    XCloseDisplay(dpy);
     return 0;
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.