1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 04:06:03 +00:00

fixing up text_buffer_size stuff

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1021 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2008-03-20 21:28:19 +00:00
parent 4fe68fcc04
commit 934c3a94e8
6 changed files with 100 additions and 109 deletions

View File

@ -376,9 +376,7 @@ static unsigned int max_specials = MAX_SPECIALS_DEFAULT;
static unsigned int max_user_text = MAX_USER_TEXT_DEFAULT; static unsigned int max_user_text = MAX_USER_TEXT_DEFAULT;
/* maximum size of individual text buffers, ie $exec buffer size */ /* maximum size of individual text buffers, ie $exec buffer size */
unsigned int small_text_buffer_size = DEFAULT_TEXT_BUFFER_SIZE; unsigned int text_buffer_size = DEFAULT_TEXT_BUFFER_SIZE;
unsigned int large_text_buffer_size = DEFAULT_TEXT_BUFFER_SIZE * 8;
unsigned int p_p_max_size = DEFAULT_TEXT_BUFFER_SIZE * 8; // sorry I couldn't come up with a better var name
#ifdef HAVE_ICONV #ifdef HAVE_ICONV
#define CODEPAGE_LENGTH 20 #define CODEPAGE_LENGTH 20
@ -1923,7 +1921,7 @@ void *threaded_exec(struct text_object *obj)
FILE *fp = popen(obj->data.texeci.cmd, "r"); FILE *fp = popen(obj->data.texeci.cmd, "r");
timed_thread_lock(obj->data.texeci.p_timed_thread); timed_thread_lock(obj->data.texeci.p_timed_thread);
int n2 = fread(p2, 1, small_text_buffer_size, fp); int n2 = fread(p2, 1, text_buffer_size, fp);
pclose(fp); pclose(fp);
p2[n2] = '\0'; p2[n2] = '\0';
@ -2702,7 +2700,7 @@ static struct text_object *construct_text_object(const char *s,
obj->data.s = strdup(buf); obj->data.s = strdup(buf);
} else { } else {
obj->data.execi.cmd = strdup(arg + n); obj->data.execi.cmd = strdup(arg + n);
obj->data.execi.buffer = (char *) calloc(1, small_text_buffer_size); obj->data.execi.buffer = (char *) calloc(1, text_buffer_size);
} }
END OBJ(texeci, 0) END OBJ(texeci, 0)
unsigned int n; unsigned int n;
@ -2716,7 +2714,7 @@ static struct text_object *construct_text_object(const char *s,
obj->data.s = strdup(buf); obj->data.s = strdup(buf);
} else { } else {
obj->data.texeci.cmd = strdup(arg + n); obj->data.texeci.cmd = strdup(arg + n);
obj->data.texeci.buffer = (char *) calloc(1, small_text_buffer_size); obj->data.texeci.buffer = (char *) calloc(1, text_buffer_size);
} }
obj->data.texeci.p_timed_thread = NULL; obj->data.texeci.p_timed_thread = NULL;
END OBJ(pre_exec, 0) END OBJ(pre_exec, 0)
@ -3023,7 +3021,7 @@ static struct text_object *construct_text_object(const char *s,
} }
if (fp || obj->data.tail.fd != -1) { if (fp || obj->data.tail.fd != -1) {
obj->data.tail.logfile = malloc(small_text_buffer_size); obj->data.tail.logfile = malloc(text_buffer_size);
strcpy(obj->data.tail.logfile, buf); strcpy(obj->data.tail.logfile, buf);
obj->data.tail.wantedlines = n1; obj->data.tail.wantedlines = n1;
obj->data.tail.interval = update_interval * 2; obj->data.tail.interval = update_interval * 2;
@ -3068,7 +3066,7 @@ static struct text_object *construct_text_object(const char *s,
} }
if (fp || obj->data.tail.fd != -1) { if (fp || obj->data.tail.fd != -1) {
obj->data.tail.logfile = malloc(small_text_buffer_size); obj->data.tail.logfile = malloc(text_buffer_size);
strcpy(obj->data.tail.logfile, buf); strcpy(obj->data.tail.logfile, buf);
obj->data.tail.wantedlines = n1; obj->data.tail.wantedlines = n1;
obj->data.tail.interval = n2; obj->data.tail.interval = n2;
@ -3087,7 +3085,7 @@ static struct text_object *construct_text_object(const char *s,
return NULL; return NULL;
} }
/* asumming all else worked */ /* asumming all else worked */
obj->data.tail.buffer = malloc(small_text_buffer_size * 20); obj->data.tail.buffer = malloc(text_buffer_size * 20);
END OBJ(head, 0) END OBJ(head, 0)
char buf[64]; char buf[64];
int n1, n2; int n1, n2;
@ -3108,7 +3106,7 @@ static struct text_object *construct_text_object(const char *s,
fp = fopen(buf, "r"); fp = fopen(buf, "r");
if (fp != NULL) { if (fp != NULL) {
obj->data.tail.logfile = malloc(small_text_buffer_size); obj->data.tail.logfile = malloc(text_buffer_size);
strcpy(obj->data.tail.logfile, buf); strcpy(obj->data.tail.logfile, buf);
obj->data.tail.wantedlines = n1; obj->data.tail.wantedlines = n1;
obj->data.tail.interval = update_interval * 2; obj->data.tail.interval = update_interval * 2;
@ -3133,7 +3131,7 @@ static struct text_object *construct_text_object(const char *s,
fp = fopen(buf, "r"); fp = fopen(buf, "r");
if (fp != NULL) { if (fp != NULL) {
obj->data.tail.logfile = malloc(small_text_buffer_size); obj->data.tail.logfile = malloc(text_buffer_size);
strcpy(obj->data.tail.logfile, buf); strcpy(obj->data.tail.logfile, buf);
obj->data.tail.wantedlines = n1; obj->data.tail.wantedlines = n1;
obj->data.tail.interval = n2; obj->data.tail.interval = n2;
@ -3149,7 +3147,7 @@ static struct text_object *construct_text_object(const char *s,
return NULL; return NULL;
} }
/* asumming all else worked */ /* asumming all else worked */
obj->data.tail.buffer = malloc(small_text_buffer_size * 20); obj->data.tail.buffer = malloc(text_buffer_size * 20);
END OBJ(loadavg, INFO_LOADAVG) END OBJ(loadavg, INFO_LOADAVG)
int a = 1, b = 2, c = 3, r = 3; int a = 1, b = 2, c = 3, r = 3;
@ -3253,11 +3251,11 @@ static struct text_object *construct_text_object(const char *s,
obj->data.local_mail.box = strdup(dst); obj->data.local_mail.box = strdup(dst);
obj->data.local_mail.interval = n1; obj->data.local_mail.interval = n1;
END OBJ(mboxscan, 0) END OBJ(mboxscan, 0)
obj->data.mboxscan.args = (char *) malloc(small_text_buffer_size); obj->data.mboxscan.args = (char *) malloc(text_buffer_size);
obj->data.mboxscan.output = (char *) malloc(small_text_buffer_size); obj->data.mboxscan.output = (char *) malloc(text_buffer_size);
/* if '1' (in mboxscan.c) then there was SIGUSR1, hmm */ /* if '1' (in mboxscan.c) then there was SIGUSR1, hmm */
obj->data.mboxscan.output[0] = 1; obj->data.mboxscan.output[0] = 1;
strncpy(obj->data.mboxscan.args, arg, small_text_buffer_size); strncpy(obj->data.mboxscan.args, arg, text_buffer_size);
END OBJ(mem, INFO_MEM) END OBJ(mem, INFO_MEM)
END OBJ(memmax, INFO_MEM) END OBJ(memmax, INFO_MEM)
END OBJ(memperc, INFO_MEM) END OBJ(memperc, INFO_MEM)
@ -3938,7 +3936,7 @@ struct text_object_list *parse_conky_vars(char *text, char *p, struct informatio
struct text_object_list *object_list = struct text_object_list *object_list =
extract_variable_text_internal(text); extract_variable_text_internal(text);
generate_text_internal(p, p_p_max_size, object_list->text_objects, generate_text_internal(p, max_user_text, object_list->text_objects,
object_list->text_object_count, cur); object_list->text_object_count, cur);
return object_list; return object_list;
} }
@ -4721,8 +4719,8 @@ static void generate_text_internal(char *p, int p_max_size,
char *output = obj->data.execi.buffer; char *output = obj->data.execi.buffer;
FILE *fp = popen(obj->data.execi.cmd, "r"); FILE *fp = popen(obj->data.execi.cmd, "r");
// int length = fread(output, 1, small_text_buffer_size, fp); // int length = fread(output, 1, text_buffer_size, fp);
int length = fread(output, 1, small_text_buffer_size, fp); int length = fread(output, 1, text_buffer_size, fp);
pclose(fp); pclose(fp);
output[length] = '\0'; output[length] = '\0';
@ -5280,7 +5278,7 @@ static void generate_text_internal(char *p, int p_max_size,
} }
OBJ(mboxscan) { OBJ(mboxscan) {
mbox_scan(obj->data.mboxscan.args, obj->data.mboxscan.output, mbox_scan(obj->data.mboxscan.args, obj->data.mboxscan.output,
small_text_buffer_size); text_buffer_size);
snprintf(p, p_max_size, "%s", obj->data.mboxscan.output); snprintf(p, p_max_size, "%s", obj->data.mboxscan.output);
} }
OBJ(new_mails) { OBJ(new_mails) {
@ -5815,10 +5813,10 @@ static void generate_text_internal(char *p, int p_max_size,
} }
/* Make sure bsize is at least 1 byte smaller than the /* Make sure bsize is at least 1 byte smaller than the
* buffer max size. */ * buffer max size. */
if (bsize > (long) ((small_text_buffer_size * 20) - 1)) { if (bsize > (long) ((text_buffer_size * 20) - 1)) {
fseek(fp, bsize - small_text_buffer_size * 20 - 1, fseek(fp, bsize - text_buffer_size * 20 - 1,
SEEK_CUR); SEEK_CUR);
bsize = small_text_buffer_size * 20 - 1; bsize = text_buffer_size * 20 - 1;
} }
bsize = fread(obj->data.tail.buffer, 1, bsize, fp); bsize = fread(obj->data.tail.buffer, 1, bsize, fp);
fclose(fp); fclose(fp);
@ -5874,8 +5872,8 @@ head:
obj->data.tail.readlines = iter; obj->data.tail.readlines = iter;
/* Make sure nl is at least 1 byte smaller than the /* Make sure nl is at least 1 byte smaller than the
* buffer max size. */ * buffer max size. */
if (nl > (long) ((small_text_buffer_size * 20) - 1)) { if (nl > (long) ((text_buffer_size * 20) - 1)) {
nl = small_text_buffer_size * 20 - 1; nl = text_buffer_size * 20 - 1;
} }
nl = fread(obj->data.tail.buffer, 1, nl, fp); nl = fread(obj->data.tail.buffer, 1, nl, fp);
fclose(fp); fclose(fp);
@ -6048,7 +6046,7 @@ static void generate_text()
p = text_buffer; p = text_buffer;
generate_text_internal(p, p_p_max_size, text_objects, text_object_count, cur); generate_text_internal(p, max_user_text, text_objects, text_object_count, cur);
if (stuff_in_upper_case) { if (stuff_in_upper_case) {
char *p; char *p;
@ -6329,9 +6327,9 @@ static void draw_string(const char *s)
printf("%s\n", s); printf("%s\n", s);
fflush(stdout); /* output immediately, don't buffer */ fflush(stdout); /* output immediately, don't buffer */
} }
memset(tmpstring1, 0, small_text_buffer_size); memset(tmpstring1, 0, text_buffer_size);
memset(tmpstring2, 0, small_text_buffer_size); memset(tmpstring2, 0, text_buffer_size);
strncpy(tmpstring1, s, small_text_buffer_size - 1); strncpy(tmpstring1, s, text_buffer_size - 1);
pos = 0; pos = 0;
added = 0; added = 0;
char space[2]; char space[2];
@ -6343,19 +6341,19 @@ static void draw_string(const char *s)
/* This code looks for tabs in the text and coverts them to spaces. /* This code looks for tabs in the text and coverts them to spaces.
* The trick is getting the correct number of spaces, and not going * The trick is getting the correct number of spaces, and not going
* over the window's size without forcing the window larger. */ * over the window's size without forcing the window larger. */
for (i = 0; i < (int)small_text_buffer_size; i++) { for (i = 0; i < (int)text_buffer_size; i++) {
if (tmpstring1[i] == '\t') { // 9 is ascii tab if (tmpstring1[i] == '\t') { // 9 is ascii tab
i2 = 0; i2 = 0;
for (i2 = 0; i2 < (8 - (1 + pos) % 8) && added <= max; i2++) { for (i2 = 0; i2 < (8 - (1 + pos) % 8) && added <= max; i2++) {
/* guard against overrun */ /* guard against overrun */
tmpstring2[MIN(pos + i2, (int)small_text_buffer_size - 1)] = ' '; tmpstring2[MIN(pos + i2, (int)text_buffer_size - 1)] = ' ';
added++; added++;
} }
pos += i2; pos += i2;
} else { } else {
if (tmpstring1[i] != 9) { if (tmpstring1[i] != 9) {
/* guard against overrun */ /* guard against overrun */
tmpstring2[MIN(pos, (int)small_text_buffer_size - 1)] = tmpstring1[i]; tmpstring2[MIN(pos, (int)text_buffer_size - 1)] = tmpstring1[i];
pos++; pos++;
} }
} }
@ -6400,7 +6398,7 @@ static void draw_string(const char *s)
} }
cur_x += width_of_s; cur_x += width_of_s;
#endif /* X11 */ #endif /* X11 */
memcpy(tmpstring1, s, small_text_buffer_size); memcpy(tmpstring1, s, text_buffer_size);
} }
long redmask, greenmask, bluemask; long redmask, greenmask, bluemask;
@ -7352,18 +7350,18 @@ void reload_config(void)
if (tmpstring1) { if (tmpstring1) {
free(tmpstring1); free(tmpstring1);
} }
tmpstring1 = malloc(small_text_buffer_size); tmpstring1 = malloc(text_buffer_size);
memset(tmpstring1, 0, small_text_buffer_size); memset(tmpstring1, 0, text_buffer_size);
if (tmpstring2) { if (tmpstring2) {
free(tmpstring2); free(tmpstring2);
} }
tmpstring2 = malloc(small_text_buffer_size); tmpstring2 = malloc(text_buffer_size);
memset(tmpstring2, 0, small_text_buffer_size); memset(tmpstring2, 0, text_buffer_size);
if (text_buffer) { if (text_buffer) {
free(text_buffer); free(text_buffer);
} }
text_buffer = malloc(large_text_buffer_size); text_buffer = malloc(max_user_text);
memset(text_buffer, 0, large_text_buffer_size); memset(text_buffer, 0, max_user_text);
update_text(); update_text();
} }
} }
@ -8180,26 +8178,16 @@ static void load_config_file(const char *f)
} }
} }
CONF("text_buffer_size") { CONF("text_buffer_size") {
ERR("text_buffer_size is deprecated in favour of small_text_buffer size and large_text_buffer_size");
}
CONF("small_text_buffer_size") {
if (value) { if (value) {
small_text_buffer_size = atoi(value); text_buffer_size = atoi(value);
if (small_text_buffer_size < DEFAULT_TEXT_BUFFER_SIZE) { if (text_buffer_size < DEFAULT_TEXT_BUFFER_SIZE) {
small_text_buffer_size = DEFAULT_TEXT_BUFFER_SIZE; ERR("text_buffer_size must be >=%i bytes", DEFAULT_TEXT_BUFFER_SIZE);
text_buffer_size = DEFAULT_TEXT_BUFFER_SIZE;
} }
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
CONF("large_text_buffer_size") {
if (value) {
large_text_buffer_size = atoi(value);
p_p_max_size = large_text_buffer_size;
} else {
CONF_ERR;
}
}
CONF("text") { CONF("text") {
if (text) { if (text) {
free(text); free(text);
@ -8561,12 +8549,12 @@ int main(int argc, char **argv)
} }
} }
text_buffer = malloc(large_text_buffer_size); text_buffer = malloc(max_user_text);
memset(text_buffer, 0, large_text_buffer_size); memset(text_buffer, 0, max_user_text);
tmpstring1 = malloc(small_text_buffer_size); tmpstring1 = malloc(text_buffer_size);
memset(tmpstring1, 0, small_text_buffer_size); memset(tmpstring1, 0, text_buffer_size);
tmpstring2 = malloc(small_text_buffer_size); tmpstring2 = malloc(text_buffer_size);
memset(tmpstring2, 0, small_text_buffer_size); memset(tmpstring2, 0, text_buffer_size);
#ifdef X11 #ifdef X11
selected_font = 0; selected_font = 0;

View File

@ -86,8 +86,7 @@
#define TOP_TIME 5 #define TOP_TIME 5
#define DEFAULT_TEXT_BUFFER_SIZE 128 #define DEFAULT_TEXT_BUFFER_SIZE 128
extern unsigned int large_text_buffer_size; extern unsigned int text_buffer_size;
extern unsigned int small_text_buffer_size;
extern unsigned int p_max_size; extern unsigned int p_max_size;
/* maximum number of special things, e.g. fonts, offsets, aligns, etc. */ /* maximum number of special things, e.g. fonts, offsets, aligns, etc. */

View File

@ -790,9 +790,13 @@ int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
divn = read(divfd, divbuf, 63); divn = read(divfd, divbuf, 63);
/* should read until n == 0 but I doubt that kernel will give these /* should read until n == 0 but I doubt that kernel will give these
* in multiple pieces. :) */ * in multiple pieces. :) */
if (divn < 0) {
ERR("open_sysfs_sensor(): can't read from sysfs");
} else {
divbuf[divn] = '\0'; divbuf[divn] = '\0';
*div = atoi(divbuf); *div = atoi(divbuf);
} }
}
close(divfd); close(divfd);
@ -817,7 +821,7 @@ double get_sysfs_info(int *fd, int div, char *devtype, char *type)
/* should read until n == 0 but I doubt that kernel will give these /* should read until n == 0 but I doubt that kernel will give these
* in multiple pieces. :) */ * in multiple pieces. :) */
if (n < 0) { if (n < 0) {
printf("get_sysfs_info(): read from %s failed\n", devtype); ERR("get_sysfs_info(): read from %s failed\n", devtype);
} else { } else {
buf[n] = '\0'; buf[n] = '\0';
val = atoi(buf); val = atoi(buf);

View File

@ -62,7 +62,7 @@ void mbox_scan(char *args, char *output, size_t max_len)
{ {
int i, u, flag; int i, u, flag;
int force_rescan = 0; int force_rescan = 0;
char buf[small_text_buffer_size]; char buf[text_buffer_size];
struct stat statbuf; struct stat statbuf;
/* output was set to 1 after malloc'ing in conky.c */ /* output was set to 1 after malloc'ing in conky.c */
@ -210,7 +210,7 @@ void mbox_scan(char *args, char *output, size_t max_len)
/* first find a "From " to set it to 0 for header-sarchings */ /* first find a "From " to set it to 0 for header-sarchings */
flag = 1; flag = 1;
while (!feof(fp)) { while (!feof(fp)) {
if (fgets(buf, small_text_buffer_size, fp) == NULL) { if (fgets(buf, text_buffer_size, fp) == NULL) {
break; break;
} }
@ -219,7 +219,7 @@ void mbox_scan(char *args, char *output, size_t max_len)
/* skip until \n */ /* skip until \n */
while (strchr(buf, '\n') == NULL && !feof(fp)) { while (strchr(buf, '\n') == NULL && !feof(fp)) {
fgets(buf, small_text_buffer_size, fp); fgets(buf, text_buffer_size, fp);
} }
flag = 0; /* in the headers now */ flag = 0; /* in the headers now */
@ -235,7 +235,7 @@ void mbox_scan(char *args, char *output, size_t max_len)
/* then search for new mail ("From ") */ /* then search for new mail ("From ") */
while (strchr(buf, '\n') == NULL && !feof(fp)) { while (strchr(buf, '\n') == NULL && !feof(fp)) {
fgets(buf, small_text_buffer_size, fp); fgets(buf, text_buffer_size, fp);
} }
flag = 1; /* in the body now */ flag = 1; /* in the body now */
continue; continue;
@ -252,7 +252,7 @@ void mbox_scan(char *args, char *output, size_t max_len)
curr = curr->previous; curr = curr->previous;
/* Skip until \n */ /* Skip until \n */
while (strchr(buf, '\n') == NULL && !feof(fp)) { while (strchr(buf, '\n') == NULL && !feof(fp)) {
fgets(buf, small_text_buffer_size, fp); fgets(buf, text_buffer_size, fp);
} }
continue; continue;
} }
@ -275,7 +275,7 @@ void mbox_scan(char *args, char *output, size_t max_len)
curr->from[i] = '\0'; curr->from[i] = '\0';
/* skip until \n */ /* skip until \n */
while (strchr(buf, '\n') == NULL && !feof(fp)) { while (strchr(buf, '\n') == NULL && !feof(fp)) {
fgets(buf, small_text_buffer_size, fp); fgets(buf, text_buffer_size, fp);
} }
break; break;
} }
@ -294,7 +294,7 @@ void mbox_scan(char *args, char *output, size_t max_len)
curr->from[i] = '\0'; curr->from[i] = '\0';
/* skip until \n */ /* skip until \n */
while (strchr(buf, '\n') == NULL && !feof(fp)) { while (strchr(buf, '\n') == NULL && !feof(fp)) {
fgets(buf, small_text_buffer_size, fp); fgets(buf, text_buffer_size, fp);
} }
break; break;
} }
@ -324,7 +324,7 @@ void mbox_scan(char *args, char *output, size_t max_len)
/* skip until \n */ /* skip until \n */
while (strchr(buf, '\n') == NULL && !feof(fp)) { while (strchr(buf, '\n') == NULL && !feof(fp)) {
fgets(buf, small_text_buffer_size, fp); fgets(buf, text_buffer_size, fp);
} }
break; break;
} }
@ -344,14 +344,14 @@ void mbox_scan(char *args, char *output, size_t max_len)
while (i) { while (i) {
if (curr->from[0] != '\0') { if (curr->from[0] != '\0') {
if (i != print_mails) { if (i != print_mails) {
snprintf(buf, small_text_buffer_size, "\nF: %-*s S: %-*s", from_width, snprintf(buf, text_buffer_size, "\nF: %-*s S: %-*s", from_width,
curr->from, subject_width, curr->subject); curr->from, subject_width, curr->subject);
} else { /* first time - no \n in front */ } else { /* first time - no \n in front */
snprintf(buf, small_text_buffer_size, "F: %-*s S: %-*s", from_width, snprintf(buf, text_buffer_size, "F: %-*s S: %-*s", from_width,
curr->from, subject_width, curr->subject); curr->from, subject_width, curr->subject);
} }
} else { } else {
snprintf(buf, small_text_buffer_size, "\n"); snprintf(buf, text_buffer_size, "\n");
} }
strncat(output, buf, max_len - strlen(output)); strncat(output, buf, max_len - strlen(output));

View File

@ -37,31 +37,31 @@ void clear_mpd_stats(struct information *current_info);
void init_mpd_stats(struct information *current_info) void init_mpd_stats(struct information *current_info)
{ {
if (current_info->mpd.artist == NULL) { if (current_info->mpd.artist == NULL) {
current_info->mpd.artist = malloc(small_text_buffer_size); current_info->mpd.artist = malloc(text_buffer_size);
} }
if (current_info->mpd.album == NULL) { if (current_info->mpd.album == NULL) {
current_info->mpd.album = malloc(small_text_buffer_size); current_info->mpd.album = malloc(text_buffer_size);
} }
if (current_info->mpd.title == NULL) { if (current_info->mpd.title == NULL) {
current_info->mpd.title = malloc(small_text_buffer_size); current_info->mpd.title = malloc(text_buffer_size);
} }
if (current_info->mpd.random == NULL) { if (current_info->mpd.random == NULL) {
current_info->mpd.random = malloc(small_text_buffer_size); current_info->mpd.random = malloc(text_buffer_size);
} }
if (current_info->mpd.repeat == NULL) { if (current_info->mpd.repeat == NULL) {
current_info->mpd.repeat = malloc(small_text_buffer_size); current_info->mpd.repeat = malloc(text_buffer_size);
} }
if (current_info->mpd.track == NULL) { if (current_info->mpd.track == NULL) {
current_info->mpd.track = malloc(small_text_buffer_size); current_info->mpd.track = malloc(text_buffer_size);
} }
if (current_info->mpd.status == NULL) { if (current_info->mpd.status == NULL) {
current_info->mpd.status = malloc(small_text_buffer_size); current_info->mpd.status = malloc(text_buffer_size);
} }
if (current_info->mpd.name == NULL) { if (current_info->mpd.name == NULL) {
current_info->mpd.name = malloc(small_text_buffer_size); current_info->mpd.name = malloc(text_buffer_size);
} }
if (current_info->mpd.file == NULL) { if (current_info->mpd.file == NULL) {
current_info->mpd.file = malloc(small_text_buffer_size); current_info->mpd.file = malloc(text_buffer_size);
} }
clear_mpd_stats(current_info); clear_mpd_stats(current_info);
} }
@ -151,7 +151,7 @@ void *update_mpd(void)
clear_mpd_stats(current_info); clear_mpd_stats(current_info);
strncpy(current_info->mpd.status, "MPD not responding", strncpy(current_info->mpd.status, "MPD not responding",
small_text_buffer_size - 1); text_buffer_size - 1);
timed_thread_unlock(mpd_timed_thread); timed_thread_unlock(mpd_timed_thread);
if (timed_thread_test(mpd_timed_thread)) { if (timed_thread_test(mpd_timed_thread)) {
timed_thread_exit(mpd_timed_thread); timed_thread_exit(mpd_timed_thread);
@ -170,7 +170,7 @@ void *update_mpd(void)
clear_mpd_stats(current_info); clear_mpd_stats(current_info);
strncpy(current_info->mpd.status, "MPD not responding", strncpy(current_info->mpd.status, "MPD not responding",
small_text_buffer_size - 1); text_buffer_size - 1);
timed_thread_unlock(mpd_timed_thread); timed_thread_unlock(mpd_timed_thread);
if (timed_thread_test(mpd_timed_thread)) { if (timed_thread_test(mpd_timed_thread)) {
timed_thread_exit(mpd_timed_thread); timed_thread_exit(mpd_timed_thread);
@ -195,14 +195,14 @@ void *update_mpd(void)
} */ } */
if (status->state == MPD_STATUS_STATE_PLAY) { if (status->state == MPD_STATUS_STATE_PLAY) {
strncpy(current_info->mpd.status, "Playing", small_text_buffer_size - 1); strncpy(current_info->mpd.status, "Playing", text_buffer_size - 1);
} }
if (status->state == MPD_STATUS_STATE_STOP) { if (status->state == MPD_STATUS_STATE_STOP) {
clear_mpd_stats(current_info); clear_mpd_stats(current_info);
strncpy(current_info->mpd.status, "Stopped", small_text_buffer_size - 1); strncpy(current_info->mpd.status, "Stopped", text_buffer_size - 1);
} }
if (status->state == MPD_STATUS_STATE_PAUSE) { if (status->state == MPD_STATUS_STATE_PAUSE) {
strncpy(current_info->mpd.status, "Paused", small_text_buffer_size - 1); strncpy(current_info->mpd.status, "Paused", text_buffer_size - 1);
} }
if (status->state == MPD_STATUS_STATE_UNKNOWN) { if (status->state == MPD_STATUS_STATE_UNKNOWN) {
clear_mpd_stats(current_info); clear_mpd_stats(current_info);
@ -253,37 +253,37 @@ void *update_mpd(void)
if (song->artist) { if (song->artist) {
strncpy(current_info->mpd.artist, song->artist, strncpy(current_info->mpd.artist, song->artist,
small_text_buffer_size - 1); text_buffer_size - 1);
} else { } else {
*current_info->mpd.artist = 0; *current_info->mpd.artist = 0;
} }
if (song->album) { if (song->album) {
strncpy(current_info->mpd.album, song->album, strncpy(current_info->mpd.album, song->album,
small_text_buffer_size - 1); text_buffer_size - 1);
} else { } else {
*current_info->mpd.album = 0; *current_info->mpd.album = 0;
} }
if (song->title) { if (song->title) {
strncpy(current_info->mpd.title, song->title, strncpy(current_info->mpd.title, song->title,
small_text_buffer_size - 1); text_buffer_size - 1);
} else { } else {
*current_info->mpd.title = 0; *current_info->mpd.title = 0;
} }
if (song->track) { if (song->track) {
strncpy(current_info->mpd.track, song->track, strncpy(current_info->mpd.track, song->track,
small_text_buffer_size - 1); text_buffer_size - 1);
} else { } else {
*current_info->mpd.track = 0; *current_info->mpd.track = 0;
} }
if (song->name) { if (song->name) {
strncpy(current_info->mpd.name, song->name, strncpy(current_info->mpd.name, song->name,
small_text_buffer_size - 1); text_buffer_size - 1);
} else { } else {
*current_info->mpd.name = 0; *current_info->mpd.name = 0;
} }
if (song->file) { if (song->file) {
strncpy(current_info->mpd.file, song->file, strncpy(current_info->mpd.file, song->file,
small_text_buffer_size - 1); text_buffer_size - 1);
} else { } else {
*current_info->mpd.file = 0; *current_info->mpd.file = 0;
} }

View File

@ -105,14 +105,14 @@ static void user_time(char *ptr)
static void users_alloc(struct information *ptr) static void users_alloc(struct information *ptr)
{ {
if (ptr->users.names == NULL) { if (ptr->users.names == NULL) {
ptr->users.names = malloc(small_text_buffer_size); ptr->users.names = malloc(text_buffer_size);
} }
if (ptr->users.terms == NULL) { if (ptr->users.terms == NULL) {
ptr->users.terms = malloc(small_text_buffer_size); ptr->users.terms = malloc(text_buffer_size);
} }
if (ptr->users.times == NULL) { if (ptr->users.times == NULL) {
ptr->users.times = malloc(small_text_buffer_size); ptr->users.times = malloc(text_buffer_size);
} }
} }
@ -128,15 +128,15 @@ void update_users()
free(current_info->users.names); free(current_info->users.names);
current_info->users.names = 0; current_info->users.names = 0;
} }
current_info->users.names = malloc(small_text_buffer_size); current_info->users.names = malloc(text_buffer_size);
strncpy(current_info->users.names, temp, small_text_buffer_size); strncpy(current_info->users.names, temp, text_buffer_size);
} else { } else {
if (current_info->users.names) { if (current_info->users.names) {
free(current_info->users.names); free(current_info->users.names);
current_info->users.names = 0; current_info->users.names = 0;
} }
current_info->users.names = malloc(small_text_buffer_size); current_info->users.names = malloc(text_buffer_size);
strncpy(current_info->users.names, "broken", small_text_buffer_size); strncpy(current_info->users.names, "broken", text_buffer_size);
} }
user_num(&t); user_num(&t);
if (t != 0) { if (t != 0) {
@ -154,15 +154,15 @@ void update_users()
free(current_info->users.terms); free(current_info->users.terms);
current_info->users.terms = 0; current_info->users.terms = 0;
} }
current_info->users.terms = malloc(small_text_buffer_size); current_info->users.terms = malloc(text_buffer_size);
strncpy(current_info->users.terms, temp, small_text_buffer_size); strncpy(current_info->users.terms, temp, text_buffer_size);
} else { } else {
if (current_info->users.terms) { if (current_info->users.terms) {
free(current_info->users.terms); free(current_info->users.terms);
current_info->users.terms = 0; current_info->users.terms = 0;
} }
current_info->users.terms = malloc(small_text_buffer_size); current_info->users.terms = malloc(text_buffer_size);
strncpy(current_info->users.terms, "broken", small_text_buffer_size); strncpy(current_info->users.terms, "broken", text_buffer_size);
} }
user_time(temp); user_time(temp);
if (temp != NULL) { if (temp != NULL) {
@ -170,14 +170,14 @@ void update_users()
free(current_info->users.times); free(current_info->users.times);
current_info->users.times = 0; current_info->users.times = 0;
} }
current_info->users.times = malloc(small_text_buffer_size); current_info->users.times = malloc(text_buffer_size);
strncpy(current_info->users.times, temp, small_text_buffer_size); strncpy(current_info->users.times, temp, text_buffer_size);
} else { } else {
if (current_info->users.times) { if (current_info->users.times) {
free(current_info->users.times); free(current_info->users.times);
current_info->users.times = 0; current_info->users.times = 0;
} }
current_info->users.times = malloc(small_text_buffer_size); current_info->users.times = malloc(text_buffer_size);
strncpy(current_info->users.times, "broken", small_text_buffer_size); strncpy(current_info->users.times, "broken", text_buffer_size);
} }
} }