Implemented 'line as link'

SVN revision: 300
This commit is contained in:
Stefan Ritt 2002-12-02 07:48:08 +00:00
parent f3da58bf15
commit d583eff9a0
2 changed files with 199 additions and 157 deletions

View File

@ -977,6 +977,13 @@ If this flag is <b>1</b>, only top level messages are displayed in the search
result page for threaded display. No replies are shown. The default is <b>0</b>. result page for threaded display. No replies are shown. The default is <b>0</b>.
<p> <p>
<li><b><code>Line as link = 0|1</code></b>
</br>
If this flag is <b>1</b>, the full line is used as a link to each message in the
search result page. Otherwise, only the icon at the beginning of each line is used
as the link, which can be hard to hit for small icons. The default is <b>0</b>.
<p>
<li><b><code>Table align = left|center|right</code></b> <li><b><code>Table align = left|center|right</code></b>
</br> </br>
Determines the text alignment inside the table of a search result for <i>summary</i> or Determines the text alignment inside the table of a search result for <i>summary</i> or

349
elogd.c
View File

@ -6,6 +6,9 @@
Contents: Web server program for Electronic Logbook ELOG Contents: Web server program for Electronic Logbook ELOG
$Log$ $Log$
Revision 2.109 2002/12/02 07:48:08 midas
Implemented 'line as link'
Revision 2.108 2002/11/29 14:49:12 midas Revision 2.108 2002/11/29 14:49:12 midas
Renamed _text to _mtext (problems under AIX) Renamed _text to _mtext (problems under AIX)
@ -770,14 +773,14 @@ char tmp[1000], str[256], uattr[256], *ps, *pt, *p;
p++; p++;
/* extract name */ /* extract name */
strcpy(str, p); strlcpy(str, p, sizeof(str));
for (j=0 ; j<(int)strlen(str) ; j++) for (j=0 ; j<(int)strlen(str) ; j++)
str[j] = toupper(str[j]); str[j] = toupper(str[j]);
/* search name */ /* search name */
for (i=0 ; i<n ; i++) for (i=0 ; i<n ; i++)
{ {
strcpy(uattr, name[i]); strlcpy(uattr, name[i], sizeof(uattr));
for (j=0 ; j<(int)strlen(uattr) ; j++) for (j=0 ; j<(int)strlen(uattr) ; j++)
uattr[j] = toupper(uattr[j]); uattr[j] = toupper(uattr[j]);
@ -1394,9 +1397,9 @@ static char old_language[256];
} }
else else
{ {
strcpy(file_name, cfg_dir); strlcpy(file_name, cfg_dir, sizeof(file_name));
strcat(file_name, "eloglang."); strlcat(file_name, "eloglang.", sizeof(file_name));
strcat(file_name, language); strlcat(file_name, language, sizeof(file_name));
fh = open(file_name, O_RDONLY | O_BINARY); fh = open(file_name, O_RDONLY | O_BINARY);
if (fh < 0) if (fh < 0)
@ -1591,12 +1594,12 @@ int i;
memset(file_name, 0, sizeof(file_name)); memset(file_name, 0, sizeof(file_name));
strcpy(file_name, cfg_dir); strlcpy(file_name, cfg_dir, sizeof(file_name));
strcat(file_name, "themes"); strlcat(file_name, "themes", sizeof(file_name));
strcat(file_name, DIR_SEPARATOR_STR); strlcat(file_name, DIR_SEPARATOR_STR, sizeof(file_name));
strcat(file_name, tn); strlcat(file_name, tn, sizeof(file_name));
strcat(file_name, DIR_SEPARATOR_STR); strlcat(file_name, DIR_SEPARATOR_STR, sizeof(file_name));
strcat(file_name, "theme.cfg"); strlcat(file_name, "theme.cfg", sizeof(file_name));
f = fopen(file_name, "r"); f = fopen(file_name, "r");
if (f == NULL) if (f == NULL)
@ -1787,9 +1790,9 @@ INT ss_file_find(char *path, char *pattern, char **plist)
char str[255]; char str[255];
int i, first; int i, first;
strcpy(str,path); strlcpy(str, path, sizeof(str));
strcat(str,"\\"); strlcat(str, "\\", sizeof(str));
strcat(str,pattern); strlcat(str, pattern, sizeof(str));
first = 1; first = 1;
i = 0; i = 0;
lpfdata = malloc(sizeof(WIN32_FIND_DATA)); lpfdata = malloc(sizeof(WIN32_FIND_DATA));
@ -1884,8 +1887,8 @@ struct tm tms;
/* go through all files */ /* go through all files */
for (index=0 ; index<n ; index++) for (index=0 ; index<n ; index++)
{ {
strcpy(file_name, dir); strlcpy(file_name, dir, sizeof(file_name));
strcat(file_name, file_list+index*MAX_PATH_LENGTH); strlcat(file_name, file_list+index*MAX_PATH_LENGTH, sizeof(file_name));
fh = open(file_name, O_RDWR | O_BINARY, 0644); fh = open(file_name, O_RDWR | O_BINARY, 0644);
@ -2050,15 +2053,15 @@ int i, j, n, status;
/* get data dir from configuration file */ /* get data dir from configuration file */
getcfg(logbook, "Data dir", str); getcfg(logbook, "Data dir", str);
if (str[0] == DIR_SEPARATOR || str[1] == ':') if (str[0] == DIR_SEPARATOR || str[1] == ':')
strcpy(data_dir, str); strlcpy(data_dir, str, sizeof(data_dir));
else else
{ {
strcpy(data_dir, cfg_dir); strlcpy(data_dir, cfg_dir, sizeof(data_dir));
strcat(data_dir, str); strlcat(data_dir, str, sizeof(data_dir));
} }
if (data_dir[strlen(data_dir)-1] != DIR_SEPARATOR) if (data_dir[strlen(data_dir)-1] != DIR_SEPARATOR)
strcat(data_dir, DIR_SEPARATOR_STR); strlcat(data_dir, DIR_SEPARATOR_STR, sizeof(data_dir));
/* create data directory if not existing */ /* create data directory if not existing */
getcwd(str, sizeof(str)); getcwd(str, sizeof(str));
@ -2366,14 +2369,13 @@ char message[TEXT_SIZE+1000], attachment_all[64*MAX_ATTACHMENTS];
p += 41; p += 41;
if ((int) strlen(p) >= *textsize) if ((int) strlen(p) >= *textsize)
{ {
strncpy(text, p, *textsize-1); strlcpy(text, p, *textsize);
text[*textsize-1] = 0;
show_error("Message too long to display. Please increase TEXT_SIZE and recompile elogd."); show_error("Message too long to display. Please increase TEXT_SIZE and recompile elogd.");
return EL_FILE_ERROR; return EL_FILE_ERROR;
} }
else else
{ {
strcpy(text, p); strlcpy(text, p, *textsize);
/* strip CR at end */ /* strip CR at end */
if (text[strlen(text)-1] == '\n') if (text[strlen(text)-1] == '\n')
@ -2686,8 +2688,8 @@ BOOL bedit;
if (p && (afile_name[i][0] || equal_ustring(afile_name[i], loc("<delete>")))) if (p && (afile_name[i][0] || equal_ustring(afile_name[i], loc("<delete>"))))
{ {
/* delete old attachment */ /* delete old attachment */
strcpy(str, lbs->data_dir); strlcpy(str, lbs->data_dir, sizeof(str));
strcat(str, p); strlcat(str, p, sizeof(str));
remove(str); remove(str);
} }
@ -2726,8 +2728,8 @@ BOOL bedit;
sprintf(message+strlen(message), "Encoding: %s\n", encoding); sprintf(message+strlen(message), "Encoding: %s\n", encoding);
sprintf(message+strlen(message), "========================================\n"); sprintf(message+strlen(message), "========================================\n");
strcat(message, text); strlcat(message, text, sizeof(message));
strcat(message, "\n"); strlcat(message, "\n", sizeof(message));
write(fh, message, strlen(message)); write(fh, message, strlen(message));
@ -2931,8 +2933,8 @@ char message[TEXT_SIZE+1000], attachment_all[64*MAX_ATTACHMENTS];
if (attachment[i][0] && p) if (attachment[i][0] && p)
{ {
/* delete old attachment if new one exists */ /* delete old attachment if new one exists */
strcpy(str, lbs->data_dir); strlcpy(str, lbs->data_dir, sizeof(str));
strcat(str, p); strlcat(str, p, sizeof(str));
remove(str); remove(str);
} }
@ -2943,8 +2945,8 @@ char message[TEXT_SIZE+1000], attachment_all[64*MAX_ATTACHMENTS];
if (delete_attachments && p) if (delete_attachments && p)
{ {
strcpy(str, lbs->data_dir); strlcpy(str, lbs->data_dir, sizeof(str));
strcat(str, p); strlcat(str, p, sizeof(str));
remove(str); remove(str);
} }
} }
@ -3342,8 +3344,7 @@ char str[10000];
return 0; return 0;
} }
strncpy(_mtext, value, TEXT_SIZE); strlcpy(_mtext, value, TEXT_SIZE);
_mtext[TEXT_SIZE-1] = 0;
return 1; return 1;
} }
@ -3357,8 +3358,7 @@ char str[10000];
return 0; return 0;
} }
strncpy(_cmdline, value, CMD_SIZE); strlcpy(_cmdline, value, CMD_SIZE);
_cmdline[CMD_SIZE-1] = 0;
return 1; return 1;
} }
@ -3369,7 +3369,7 @@ char str[10000];
if (i<MAX_PARAM) if (i<MAX_PARAM)
{ {
strcpy(_param[i], param); strlcpy(_param[i], param, PARAM_LENGTH);
if (strlen(value) >= VALUE_SIZE) if (strlen(value) >= VALUE_SIZE)
{ {
@ -3378,8 +3378,7 @@ char str[10000];
return 0; return 0;
} }
strncpy(_value[i], value, VALUE_SIZE); strlcpy(_value[i], value, VALUE_SIZE);
_value[i][VALUE_SIZE-1] = 0;
} }
else else
{ {
@ -3435,8 +3434,8 @@ int i;
{ {
for ( ; i<MAX_PARAM-1 ; i++) for ( ; i<MAX_PARAM-1 ; i++)
{ {
strcpy(_param[i], _param[i+1]); strlcpy(_param[i], _param[i+1], PARAM_LENGTH);
strcpy(_value[i], _value[i+1]); strlcpy(_value[i], _value[i+1], PARAM_LENGTH);
} }
_param[MAX_PARAM-1][0] = 0; _param[MAX_PARAM-1][0] = 0;
_value[MAX_PARAM-1][0] = 0; _value[MAX_PARAM-1][0] = 0;
@ -3490,8 +3489,7 @@ char *p;
{ {
p++; p++;
strncpy(list[i], p, NAME_LENGTH-1); strlcpy(list[i], p, NAME_LENGTH);
list[i][NAME_LENGTH-1] = 0;
if (strchr(list[i], '"')) if (strchr(list[i], '"'))
*strchr(list[i], '"') = 0; *strchr(list[i], '"') = 0;
@ -3502,8 +3500,7 @@ char *p;
} }
else else
{ {
strncpy(list[i], p, NAME_LENGTH-1); strlcpy(list[i], p, NAME_LENGTH);
list[i][NAME_LENGTH-1] = 0;
if (strchr(list[i], ',')) if (strchr(list[i], ','))
*strchr(list[i], ',') = 0; *strchr(list[i], ',') = 0;
@ -3942,7 +3939,7 @@ struct tm *gmt;
} }
} }
sprintf(str, "%s", getparam("redir")); strlcpy(str, getparam("redir"), sizeof(str));
if (!str[0]) if (!str[0])
{ {
if (lbs) if (lbs)
@ -4104,26 +4101,26 @@ struct tm *ts;
/* add remote host */ /* add remote host */
strcpy(list[i], "remote_host"); strcpy(list[i], "remote_host");
strcpy(value[i++], rem_host); strlcpy(value[i++], rem_host, NAME_LENGTH);
/* add local host */ /* add local host */
strcpy(list[i], "host"); strcpy(list[i], "host");
strcpy(value[i++], host_name); strlcpy(value[i++], host_name, NAME_LENGTH);
/* add user names */ /* add user names */
strcpy(list[i], "short_name"); strcpy(list[i], "short_name");
strcpy(value[i++], getparam("unm")); strlcpy(value[i++], getparam("unm"), NAME_LENGTH);
strcpy(list[i], "long_name"); strcpy(list[i], "long_name");
strcpy(value[i++], getparam("full_name")); strlcpy(value[i++], getparam("full_name"), NAME_LENGTH);
/* add email */ /* add email */
strcpy(list[i], "user_email"); strcpy(list[i], "user_email");
strcpy(value[i], "mailto:"); strcpy(value[i], "mailto:");
strcat(value[i++], getparam("user_email")); strlcat(value[i++], getparam("user_email"), NAME_LENGTH);
/* add logbook */ /* add logbook */
strcpy(list[i], "logbook"); strcpy(list[i], "logbook");
strcpy(value[i++], lbs->name); strlcpy(value[i++], lbs->name, NAME_LENGTH);
/* add date */ /* add date */
strcpy(list[i], "date"); strcpy(list[i], "date");
@ -4161,8 +4158,8 @@ int i, fh, wrong_pwd, size;
strcpy(file_name, str); strcpy(file_name, str);
else else
{ {
strcpy(file_name, cfg_dir); strlcpy(file_name, cfg_dir, sizeof(file_name));
strcat(file_name, str); strlcat(file_name, str, sizeof(file_name));
} }
wrong_pwd = FALSE; wrong_pwd = FALSE;
@ -4827,8 +4824,8 @@ time_t now;
strcpy(file_name, str); strcpy(file_name, str);
else else
{ {
strcpy(file_name, cfg_dir); strlcpy(file_name, cfg_dir, sizeof(file_name));
strcat(file_name, str); strlcat(file_name, str, sizeof(file_name));
} }
/* check if file exists */ /* check if file exists */
@ -5350,8 +5347,8 @@ int i, fh, size, self_register;
strcpy(file_name, str); strcpy(file_name, str);
else else
{ {
strcpy(file_name, cfg_dir); strlcpy(file_name, cfg_dir, sizeof(file_name));
strcat(file_name, str); strlcat(file_name, str, sizeof(file_name));
} }
fh = open(file_name, O_RDWR | O_BINARY | O_CREAT, 644); fh = open(file_name, O_RDWR | O_BINARY | O_CREAT, 644);
@ -5472,8 +5469,8 @@ int i, fh, size, self_register;
} }
else else
{ {
strcat(url, lbs->name); strlcat(url, lbs->name, sizeof(url));
strcat(url, "/"); strlcat(url, "/", sizeof(url));
} }
if (!getcfg(lbs->name, "Use Email from", mail_from)) if (!getcfg(lbs->name, "Use Email from", mail_from))
@ -5588,8 +5585,8 @@ int i, fh, size;
strcpy(file_name, str); strcpy(file_name, str);
else else
{ {
strcpy(file_name, cfg_dir); strlcpy(file_name, cfg_dir, sizeof(file_name));
strcat(file_name, str); strlcat(file_name, str, sizeof(file_name));
} }
fh = open(file_name, O_RDWR | O_BINARY, 0644); fh = open(file_name, O_RDWR | O_BINARY, 0644);
@ -5849,7 +5846,7 @@ char str[256], in_reply_to[80], reply_to[256];
} }
else else
{ {
strcpy(str, getparam("lastcmd")); strlcpy(str, getparam("lastcmd"), sizeof(str));
url_decode(str); url_decode(str);
redirect(str); redirect(str);
} }
@ -6072,7 +6069,7 @@ struct tm *gmt;
} }
return_length = strlen(return_buffer)+size; return_length = strlen(return_buffer)+size;
strcat(return_buffer, message); strlcat(return_buffer, message, sizeof(return_buffer));
return EL_SUCCESS; return EL_SUCCESS;
} }
@ -6091,7 +6088,7 @@ void display_line(LOGBOOK *lbs, int message_id, int number, char *mode,
char str[256], ref[256], *nowrap, col[80], format[256], file_name[256]; char str[256], ref[256], *nowrap, col[80], format[256], file_name[256];
char slist[MAX_N_ATTR+10][NAME_LENGTH], svalue[MAX_N_ATTR+10][NAME_LENGTH]; char slist[MAX_N_ATTR+10][NAME_LENGTH], svalue[MAX_N_ATTR+10][NAME_LENGTH];
char display[256], attr_icon[80], align[32]; char display[256], attr_icon[80], align[32];
int i, j, size, i_line, index, colspan; int i, j, size, i_line, index, colspan, line_as_link;
BOOL link_displayed, skip_comma; BOOL link_displayed, skip_comma;
FILE *f; FILE *f;
@ -6137,6 +6134,9 @@ FILE *f;
if (getcfg(lbs->name, "Table align", str)) if (getcfg(lbs->name, "Table align", str))
strcpy(align, str); strcpy(align, str);
line_as_link = (getcfg(lbs->name, "Line as link", str) && atoi(str) == 1 &&
(equal_ustring(mode, "Threaded")));
if (equal_ustring(mode, "Threaded") && getcfg(lbs->name, "Thread display", display)) if (equal_ustring(mode, "Threaded") && getcfg(lbs->name, "Thread display", display))
{ {
/* check if to use icon from attributes */ /* check if to use icon from attributes */
@ -6220,7 +6220,15 @@ FILE *f;
strcpy(svalue[j++], date); strcpy(svalue[j++], date);
strsubst(display, slist, svalue, j); strsubst(display, slist, svalue, j);
rsputs2(display);
if (getcfg(lbs->name, "Line as link", str) && atoi(str) == 1)
{
rsprintf("<a href=\"%s\">", ref);
rsputs(display);
rsprintf("</a>\n");
}
else
rsputs2(display);
} }
else else
{ {
@ -6228,6 +6236,9 @@ FILE *f;
if (select && !equal_ustring(mode, "Threaded")) if (select && !equal_ustring(mode, "Threaded"))
rsprintf("<td bgcolor=%s><input type=checkbox name=\"s%d\" value=%d>\n", col, (*n_display)++, message_id); rsprintf("<td bgcolor=%s><input type=checkbox name=\"s%d\" value=%d>\n", col, (*n_display)++, message_id);
if (line_as_link)
rsprintf("<a href=\"%s\">", ref);
for (index=0 ; index<n_attr_disp ; index++) for (index=0 ; index<n_attr_disp ; index++)
{ {
if (equal_ustring(disp_attr[index], "#")) if (equal_ustring(disp_attr[index], "#"))
@ -6237,18 +6248,40 @@ FILE *f;
if (level == 0) if (level == 0)
{ {
if (*gt("Thread image")) if (*gt("Thread image"))
rsprintf("<a href=\"%s\"><img border=0 src=\"%s\"></a>&nbsp;", ref, gt("Thread image")); {
if (line_as_link)
rsprintf("<img border=0 src=\"%s\">&nbsp;", gt("Thread image"));
else
rsprintf("<a href=\"%s\"><img border=0 src=\"%s\"></a>&nbsp;", ref, gt("Thread image"));
}
else else
rsprintf("<font size=%d><a href=\"%s\">&nbsp;%d&nbsp;</a></font>", {
size, ref, message_id); if (line_as_link)
rsprintf("<font size=%d>&nbsp;%d&nbsp;</font>",
size, message_id);
else
rsprintf("<font size=%d><a href=\"%s\">&nbsp;%d&nbsp;</a></font>",
size, ref, message_id);
}
} }
else else
{ {
if (*gt("Thread reply image")) if (*gt("Thread reply image"))
rsprintf("<a href=\"%s\"><img border=0 src=\"%s\"></a>&nbsp;", ref, gt("Thread reply image")); {
if (line_as_link)
rsprintf("<img border=0 src=\"%s\">&nbsp;", gt("Thread reply image"));
else
rsprintf("<a href=\"%s\"><img border=0 src=\"%s\"></a>&nbsp;", ref, gt("Thread reply image"));
}
else else
rsprintf("<font size=%d><a href=\"%s\">&nbsp;%d&nbsp;</a></font>", {
size, ref, message_id); if (line_as_link)
rsprintf("<font size=%d>&nbsp;%d&nbsp;</font>",
size, message_id);
else
rsprintf("<font size=%d><a href=\"%s\">&nbsp;%d&nbsp;</a></font>",
size, ref, message_id);
}
} }
skip_comma = TRUE; skip_comma = TRUE;
@ -6264,7 +6297,7 @@ FILE *f;
{ {
if (equal_ustring(mode, "Threaded")) if (equal_ustring(mode, "Threaded"))
{ {
if (!link_displayed) if (!link_displayed && !line_as_link)
{ {
rsprintf("<font size=%d><a href=\"%s\">%s</a></font>", rsprintf("<font size=%d><a href=\"%s\">%s</a></font>",
size, ref, lbs->name); size, ref, lbs->name);
@ -6320,7 +6353,7 @@ FILE *f;
if (equal_ustring(mode, "Threaded")) if (equal_ustring(mode, "Threaded"))
{ {
if (!link_displayed) if (!link_displayed && !line_as_link)
{ {
rsprintf("<font size=%d><a href=\"%s\">%s</a></font>", rsprintf("<font size=%d><a href=\"%s\">%s</a></font>",
size, ref, str); size, ref, str);
@ -6358,7 +6391,7 @@ FILE *f;
if (atoi(attrib[i]) == 1) if (atoi(attrib[i]) == 1)
{ {
rsprintf("<font size=%d>", size); rsprintf("<font size=%d>", size);
if (!link_displayed) if (!link_displayed && !line_as_link)
{ {
rsprintf("<a href=\"%s\">", ref); rsprintf("<a href=\"%s\">", ref);
rsputs2(attr_list[i]); rsputs2(attr_list[i]);
@ -6390,7 +6423,7 @@ FILE *f;
else else
{ {
rsprintf("<font size=%d>", size); rsprintf("<font size=%d>", size);
if (!link_displayed) if (!link_displayed && !line_as_link)
{ {
rsprintf("<a href=\"%s\">", ref); rsprintf("<a href=\"%s\">", ref);
rsputs2(attrib[i]); rsputs2(attrib[i]);
@ -6447,6 +6480,9 @@ FILE *f;
} }
} }
} }
if (line_as_link)
rsprintf("</a>\n");
} }
if (equal_ustring(mode, "Threaded")) if (equal_ustring(mode, "Threaded"))
@ -6549,9 +6585,9 @@ FILE *f;
/* display attachment */ /* display attachment */
rsprintf("<br><font size=%d><pre>", size); rsprintf("<br><font size=%d><pre>", size);
strcpy(file_name, lbs->data_dir); strlcpy(file_name, lbs->data_dir, sizeof(file_name));
strcat(file_name, attachment[index]); strlcat(file_name, attachment[index], sizeof(file_name));
f = fopen(file_name, "rt"); f = fopen(file_name, "rt");
if (f != NULL) if (f != NULL)
@ -6637,12 +6673,12 @@ int msg_compare_reverse(const void *m1, const void *m2)
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
void build_ref(char *ref) void build_ref(char *ref, int size)
{ {
char *p1, *p2; char *p1, *p2;
if (strchr(getparam("cmdline"), '?')) if (strchr(getparam("cmdline"), '?'))
strcat(ref, strchr(getparam("cmdline"), '?')); strlcat(ref, strchr(getparam("cmdline"), '?'), size);
/* eliminate old search */ /* eliminate old search */
if (strstr(ref, "cmd=Search&")) if (strstr(ref, "cmd=Search&"))
@ -6688,7 +6724,7 @@ char ref[256];
if (page_n > 1) if (page_n > 1)
{ {
sprintf(ref, "page%d", page_n - 1); sprintf(ref, "page%d", page_n - 1);
build_ref(ref); build_ref(ref, sizeof(ref));
rsprintf("<a href=\"%s\">%s</a>&nbsp;&nbsp;", ref, loc("Previous")); rsprintf("<a href=\"%s\">%s</a>&nbsp;&nbsp;", ref, loc("Previous"));
} }
@ -6698,7 +6734,7 @@ char ref[256];
for (i=0 ; i<(n_msg-1)/n_page+1 ; i++) for (i=0 ; i<(n_msg-1)/n_page+1 ; i++)
{ {
sprintf(ref, "page%d", i+1); sprintf(ref, "page%d", i+1);
build_ref(ref); build_ref(ref, sizeof(ref));
if (i == (n_msg-1)/n_page) if (i == (n_msg-1)/n_page)
{ {
@ -6720,7 +6756,7 @@ char ref[256];
if (page_n != -1 && page_n * n_page < n_msg) if (page_n != -1 && page_n * n_page < n_msg)
{ {
sprintf(ref, "page%d", page_n + 1); sprintf(ref, "page%d", page_n + 1);
build_ref(ref); build_ref(ref, sizeof(ref));
rsprintf("<a href=\"%s\">%s</a>&nbsp;&nbsp;", ref, loc("Next")); rsprintf("<a href=\"%s\">%s</a>&nbsp;&nbsp;", ref, loc("Next"));
} }
@ -6728,7 +6764,7 @@ char ref[256];
if (page_n != -1 && n_page < n_msg) if (page_n != -1 && n_page < n_msg)
{ {
sprintf(ref, "page"); sprintf(ref, "page");
build_ref(ref); build_ref(ref, sizeof(ref));
rsprintf("<a href=\"%s\">%s</a>\n", ref, loc("All")); rsprintf("<a href=\"%s\">%s</a>\n", ref, loc("All"));
} }
@ -6926,9 +6962,9 @@ LOGBOOK *lbs_cur;
atoi(str) == 1) atoi(str) == 1)
{ {
if (strchr(_cmdline, '?')) if (strchr(_cmdline, '?'))
strcat(_cmdline, "&reverse=0"); strlcat(_cmdline, "&reverse=0", sizeof(_cmdline));
else else
strcat(_cmdline, "?reverse=0"); strlcat(_cmdline, "?reverse=0", sizeof(_cmdline));
} }
redirect(_cmdline); redirect(_cmdline);
return; return;
@ -6937,7 +6973,7 @@ LOGBOOK *lbs_cur;
/* redirect go command */ /* redirect go command */
if (isparam("lastcmd")) //## and not copy to / move to / delete ... if (isparam("lastcmd")) //## and not copy to / move to / delete ...
{ {
strcpy(str, getparam("lastcmd")); strlcpy(str, getparam("lastcmd"), sizeof(str));
url_decode(str); url_decode(str);
/* strip previous "last" */ /* strip previous "last" */
@ -6946,9 +6982,11 @@ LOGBOOK *lbs_cur;
/* add new "last" */ /* add new "last" */
if (strchr(str, '?')) if (strchr(str, '?'))
sprintf(str+strlen(str), "&last=%s", getparam("last")); sprintf(str+strlen(str), "&last=");
else else
sprintf(str+strlen(str), "?last=%s", getparam("last")); sprintf(str+strlen(str), "?last=");
strlcat(str, getparam("last"), sizeof(str));
redirect(str); redirect(str);
return; return;
} }
@ -7325,8 +7363,7 @@ LOGBOOK *lbs_cur;
if (equal_ustring(getparam("sort"), attr_list[i]) || if (equal_ustring(getparam("sort"), attr_list[i]) ||
equal_ustring(getparam("rsort"), attr_list[i])) equal_ustring(getparam("rsort"), attr_list[i]))
{ {
strncpy(msg_list[index].string, attrib[i], 255); strlcpy(msg_list[index].string, attrib[i], 256);
msg_list[index].string[255] = 0;
} }
if (equal_ustring(getparam("sort"), "#") || if (equal_ustring(getparam("sort"), "#") ||
@ -7566,8 +7603,8 @@ LOGBOOK *lbs_cur;
strcpy(file_name, str); strcpy(file_name, str);
else else
{ {
strcpy(file_name, cfg_dir); strlcpy(file_name, cfg_dir, sizeof(file_name));
strcat(file_name, str); strlcat(file_name, str, sizeof(file_name));
} }
f = fopen(file_name, "rb"); f = fopen(file_name, "rb");
@ -7889,8 +7926,8 @@ LOGBOOK *lbs_cur;
strcpy(file_name, str); strcpy(file_name, str);
else else
{ {
strcpy(file_name, cfg_dir); strlcpy(file_name, cfg_dir, sizeof(file_name));
strcat(file_name, str); strlcat(file_name, str, sizeof(file_name));
} }
f = fopen(file_name, "rb"); f = fopen(file_name, "rb");
@ -7990,8 +8027,8 @@ char slist[MAX_N_ATTR+10][NAME_LENGTH], svalue[MAX_N_ATTR+10][NAME_LENGTH];
} }
else else
{ {
strcat(str, lbs->name); strlcat(str, lbs->name, sizeof(str));
strcat(str, "/"); strlcat(str, "/", sizeof(str));
} }
sprintf(mail_text+strlen(mail_text), "\r\n%s URL : %s%d\r\n", sprintf(mail_text+strlen(mail_text), "\r\n%s URL : %s%d\r\n",
@ -8105,9 +8142,9 @@ int i, j, n, missing, first, index, n_mail, suppress, message_id, resubmit_or
if (first) if (first)
first = 0; first = 0;
else else
strcat(attrib[i], " | "); strlcat(attrib[i], " | ", NAME_LENGTH);
if (strlen(attrib[i]) + strlen(getparam(str)) < NAME_LENGTH-2) if (strlen(attrib[i]) + strlen(getparam(str)) < NAME_LENGTH-2)
strcat(attrib[i], getparam(str)); strlcat(attrib[i], getparam(str), NAME_LENGTH);
else else
break; break;
} }
@ -8118,8 +8155,7 @@ int i, j, n, missing, first, index, n_mail, suppress, message_id, resubmit_or
} }
else else
{ {
strncpy(attrib[i], getparam(attr_list[i]), NAME_LENGTH); strlcpy(attrib[i], getparam(attr_list[i]), NAME_LENGTH);
attrib[i][NAME_LENGTH-1] = 0;
} }
if (!*getparam("edit")) if (!*getparam("edit"))
@ -8222,13 +8258,13 @@ int i, j, n, missing, first, index, n_mail, suppress, message_id, resubmit_or
if (strchr(attr_list[index], ' ')) if (strchr(attr_list[index], ' '))
sprintf(str+strlen(str), "\"%s\"", attr_list[index]); sprintf(str+strlen(str), "\"%s\"", attr_list[index]);
else else
strcat(str, attr_list[index]); strlcat(str, attr_list[index], sizeof(str));
strcat(str, " "); strcat(str, " ");
if (strchr(getparam(attr_list[index]), ' ')) if (strchr(getparam(attr_list[index]), ' '))
sprintf(str+strlen(str), "\"%s\"", getparam(attr_list[index])); sprintf(str+strlen(str), "\"%s\"", getparam(attr_list[index]));
else else
strcat(str, getparam(attr_list[index])); strlcat(str, getparam(attr_list[index]), sizeof(str));
} }
else else
sprintf(str, "Email ALL"); sprintf(str, "Email ALL");
@ -8272,8 +8308,8 @@ int i, j, n, missing, first, index, n_mail, suppress, message_id, resubmit_or
strcpy(file_name, str); strcpy(file_name, str);
else else
{ {
strcpy(file_name, cfg_dir); strlcpy(file_name, cfg_dir, sizeof(file_name));
strcat(file_name, str); strlcat(file_name, str, sizeof(file_name));
} }
send_file_direct(file_name); send_file_direct(file_name);
return; return;
@ -8350,8 +8386,8 @@ LOGBOOK *lbs_dest;
for (i=0 ; i<MAX_ATTACHMENTS ; i++) for (i=0 ; i<MAX_ATTACHMENTS ; i++)
if (attachment[i][0]) if (attachment[i][0])
{ {
strcpy(file_name, lbs->data_dir); strlcpy(file_name, lbs->data_dir, sizeof(file_name));
strcat(file_name, attachment[i]); strlcat(file_name, attachment[i], sizeof(file_name));
fh = open(file_name, O_RDONLY | O_BINARY); fh = open(file_name, O_RDONLY | O_BINARY);
if (fh > 0) if (fh > 0)
@ -8370,8 +8406,8 @@ LOGBOOK *lbs_dest;
} }
/* stip date/time from file name */ /* stip date/time from file name */
strcpy(str, attachment[i]); strlcpy(str, attachment[i], sizeof(str));
strcpy(attachment[i], str+14); strlcpy(attachment[i], str+14, NAME_LENGTH);
} }
/* submit in destination logbook without links, submit all attributes from /* submit in destination logbook without links, submit all attributes from
@ -8921,8 +8957,8 @@ BOOL first;
strcpy(file_name, str); strcpy(file_name, str);
else else
{ {
strcpy(file_name, cfg_dir); strlcpy(file_name, cfg_dir, sizeof(file_name));
strcat(file_name, str); strlcat(file_name, str, sizeof(file_name));
} }
f = fopen(file_name, "rb"); f = fopen(file_name, "rb");
@ -9163,8 +9199,8 @@ BOOL first;
att[i] = 0; att[i] = 0;
/* determine size of attachment */ /* determine size of attachment */
strcpy(file_name, lbs->data_dir); strlcpy(file_name, lbs->data_dir, sizeof(file_name));
strcat(file_name, attachment[index]); strlcat(file_name, attachment[index], sizeof(file_name));
length = 0; length = 0;
fh = open(file_name, O_RDONLY | O_BINARY); fh = open(file_name, O_RDONLY | O_BINARY);
@ -9220,8 +9256,8 @@ BOOL first;
if (!strstr(att, ".HTML")) if (!strstr(att, ".HTML"))
rsprintf("<br><pre>"); rsprintf("<br><pre>");
strcpy(file_name, lbs->data_dir); strlcpy(file_name, lbs->data_dir, sizeof(file_name));
strcat(file_name, attachment[index]); strlcat(file_name, attachment[index], sizeof(file_name));
f = fopen(file_name, "rt"); f = fopen(file_name, "rt");
if (f != NULL) if (f != NULL)
@ -9266,8 +9302,8 @@ BOOL first;
strcpy(file_name, str); strcpy(file_name, str);
else else
{ {
strcpy(file_name, cfg_dir); strlcpy(file_name, cfg_dir, sizeof(file_name));
strcat(file_name, str); strlcat(file_name, str, sizeof(file_name));
} }
f = fopen(file_name, "rb"); f = fopen(file_name, "rb");
@ -9364,11 +9400,11 @@ int i;
return 1; return 1;
if (str[0] == DIR_SEPARATOR || str[1] == ':') if (str[0] == DIR_SEPARATOR || str[1] == ':')
strcpy(file_name, str); strlcpy(file_name, str, sizeof(file_name));
else else
{ {
strcpy(file_name, cfg_dir); strlcpy(file_name, cfg_dir, sizeof(file_name));
strcat(file_name, str); strlcat(file_name, str, sizeof(file_name));
} }
f = fopen(file_name, "r"); f = fopen(file_name, "r");
@ -9410,7 +9446,7 @@ int i;
while (*p && *p == ' ') while (*p && *p == ' ')
p++; p++;
strncpy(str, p, sizeof(str)-1); strlcpy(str, p, sizeof(str));
if (strchr(str, ':')) if (strchr(str, ':'))
*strchr(str, ':') = 0; *strchr(str, ':') = 0;
@ -9457,8 +9493,8 @@ int i;
strcpy(file_name, str); strcpy(file_name, str);
else else
{ {
strcpy(file_name, cfg_dir); strlcpy(file_name, cfg_dir, sizeof(file_name));
strcat(file_name, str); strlcat(file_name, str, sizeof(file_name));
} }
f = fopen(file_name, "r"); f = fopen(file_name, "r");
@ -9759,11 +9795,11 @@ FILE *f;
{ {
/* check if file starts with an absolute directory */ /* check if file starts with an absolute directory */
if (str[0] == DIR_SEPARATOR || str[1] == ':') if (str[0] == DIR_SEPARATOR || str[1] == ':')
strcpy(file_name, str); strlcpy(file_name, str, sizeof(file_name));
else else
{ {
strcpy(file_name, cfg_dir); strlcpy(file_name, cfg_dir, sizeof(file_name));
strcat(file_name, str); strlcat(file_name, str, sizeof(file_name));
} }
send_file_direct(file_name); send_file_direct(file_name);
return; return;
@ -10100,23 +10136,23 @@ FILE *f;
dec_path[13] = '_'; dec_path[13] = '_';
/* file from data directory requested */ /* file from data directory requested */
strcpy(file_name, lbs->data_dir); strlcpy(file_name, lbs->data_dir, sizeof(file_name));
strcat(file_name, dec_path); strlcat(file_name, dec_path, sizeof(file_name));
} }
else else
{ {
/* file from theme directory requested */ /* file from theme directory requested */
strcpy(file_name, cfg_dir); strlcpy(file_name, cfg_dir, sizeof(file_name));
if (file_name[0]) if (file_name[0])
strcat(file_name, DIR_SEPARATOR_STR); strlcat(file_name, DIR_SEPARATOR_STR, sizeof(file_name));
strcat(file_name, "themes"); strlcat(file_name, "themes", sizeof(file_name));
strcat(file_name, DIR_SEPARATOR_STR); strlcat(file_name, DIR_SEPARATOR_STR, sizeof(file_name));
if (theme_name[0]) if (theme_name[0])
{ {
strcat(file_name, theme_name); strlcat(file_name, theme_name, sizeof(file_name));
strcat(file_name, DIR_SEPARATOR_STR); strlcat(file_name, DIR_SEPARATOR_STR, sizeof(file_name));
} }
strcat(file_name, dec_path); strlcat(file_name, dec_path, sizeof(file_name));
} }
send_file_direct(file_name); send_file_direct(file_name);
@ -10166,17 +10202,17 @@ FILE *f;
} }
/* send local help file */ /* send local help file */
strcpy(file_name, cfg_dir); strlcpy(file_name, cfg_dir, sizeof(file_name));
strcat(file_name, "eloghelp_"); strlcat(file_name, "eloghelp_", sizeof(file_name));
if (getcfg("global", "Language", str)) if (getcfg("global", "Language", str))
{ {
str[2] = 0; str[2] = 0;
strcat(file_name, str); strlcat(file_name, str, sizeof(file_name));
} }
else else
strcat(file_name, "en"); strlcat(file_name, "en", sizeof(file_name));
strcat(file_name, ".html"); strlcat(file_name, ".html", sizeof(file_name));
f = fopen(file_name, "r"); f = fopen(file_name, "r");
if (f == NULL) if (f == NULL)
@ -10382,8 +10418,8 @@ FILE *f;
strcpy(file_name, str); strcpy(file_name, str);
else else
{ {
strcpy(file_name, cfg_dir); strlcpy(file_name, cfg_dir, sizeof(file_name));
strcat(file_name, str); strlcat(file_name, str, sizeof(file_name));
} }
send_file_direct(file_name); send_file_direct(file_name);
return; return;
@ -10414,7 +10450,7 @@ char *p, *pitem;
setparam("cmdline", string); setparam("cmdline", string);
strncpy(path, string, sizeof(path)); strlcpy(path, string, sizeof(path));
path[255] = 0; path[255] = 0;
if (strchr(path, '?')) if (strchr(path, '?'))
*strchr(path, '?') = 0; *strchr(path, '?') = 0;
@ -10472,8 +10508,7 @@ int i, n;
{ {
if (strstr(string, "name=")) if (strstr(string, "name="))
{ {
strncpy(line, strstr(string, "name=") + 5, sizeof(line)-1); strlcpy(line, strstr(string, "name=") + 5, sizeof(line));
line[sizeof(line)-1] = 0;
if (strchr(line, '\r')) if (strchr(line, '\r'))
*strchr(line, '\r') = 0; *strchr(line, '\r') = 0;
@ -10949,11 +10984,11 @@ struct timeval timeout;
if (header_length == 0) if (header_length == 0)
{ {
/* extract logbook */ /* extract logbook */
strncpy(str, net_buffer+6, sizeof(str)); strlcpy(str, net_buffer+6, sizeof(str));
if (strstr(str, "HTTP")) if (strstr(str, "HTTP"))
*(strstr(str, "HTTP")-1) = 0; *(strstr(str, "HTTP")-1) = 0;
strcpy(logbook, str); strlcpy(logbook, str, sizeof(logbook));
strcpy(logbook_enc, str); strlcpy(logbook_enc, str, sizeof(logbook));
url_decode(logbook); url_decode(logbook);
/* extract header and content length */ /* extract header and content length */
@ -10965,7 +11000,7 @@ struct timeval timeout;
boundary[0] = 0; boundary[0] = 0;
if (strstr(net_buffer, "boundary=")) if (strstr(net_buffer, "boundary="))
{ {
strncpy(boundary, strstr(net_buffer, "boundary=")+9, sizeof(boundary)); strlcpy(boundary, strstr(net_buffer, "boundary=")+9, sizeof(boundary));
if (strchr(boundary, '\r')) if (strchr(boundary, '\r'))
*strchr(boundary, '\r') = 0; *strchr(boundary, '\r') = 0;
} }
@ -11022,7 +11057,7 @@ struct timeval timeout;
p++; p++;
while (*p && *p == ' ') while (*p && *p == ' ')
p++; p++;
strncpy(str, p, sizeof(str)); strlcpy(str, p, sizeof(str));
for (i=0 ; i<(int)strlen(str) ; i++) for (i=0 ; i<(int)strlen(str) ; i++)
if (str[i] == '=' || str[i] == ';') if (str[i] == '=' || str[i] == ';')
@ -11056,7 +11091,7 @@ struct timeval timeout;
p += 9; p += 9;
while (*p && *p == ' ') while (*p && *p == ' ')
p++; p++;
strncpy(referer, p, sizeof(referer)); strlcpy(referer, p, sizeof(referer));
if (strchr(referer, '\r')) if (strchr(referer, '\r'))
*strchr(referer, '\r') = 0; *strchr(referer, '\r') = 0;
if (strchr(referer, '?')) if (strchr(referer, '?'))
@ -11072,7 +11107,7 @@ struct timeval timeout;
p += 11; p += 11;
while (*p && *p == ' ') while (*p && *p == ' ')
p++; p++;
strncpy(browser, p, sizeof(browser)); strlcpy(browser, p, sizeof(browser));
if (strchr(browser, '\r')) if (strchr(browser, '\r'))
*strchr(browser, '\r') = 0; *strchr(browser, '\r') = 0;
} }
@ -11153,8 +11188,8 @@ struct timeval timeout;
strstr(logbook, ".htm")) strstr(logbook, ".htm"))
{ {
/* serve file directly */ /* serve file directly */
strcpy(str, cfg_dir); strlcpy(str, cfg_dir, sizeof(str));
strcat(str, logbook); strlcat(str, logbook, sizeof(str));
send_file_direct(str); send_file_direct(str);
send(_sock, return_buffer, return_length, 0); send(_sock, return_buffer, return_length, 0);
@ -11197,10 +11232,10 @@ struct timeval timeout;
if (verbose) if (verbose)
printf("\n\n\n%s\n", net_buffer); printf("\n\n\n%s\n", net_buffer);
strcpy(logbook, str); strlcpy(logbook, str, sizeof(logbook));
strcpy(logbook_enc, logbook); strlcpy(logbook_enc, logbook, sizeof(logbook_enc));
url_encode(logbook_enc); url_encode(logbook_enc);
strcat(logbook_enc, "/"); strlcat(logbook_enc, "/", sizeof(logbook_enc));
/* redirect to logbook, necessary to get optional cookies for that logbook */ /* redirect to logbook, necessary to get optional cookies for that logbook */
redirect(logbook_enc); redirect(logbook_enc);
@ -11663,7 +11698,7 @@ struct tm *tms;
else if (argv[i][1] == 'l') else if (argv[i][1] == 'l')
strcpy(logbook, argv[++i]); strcpy(logbook, argv[++i]);
else if (argv[i][1] == 'h') else if (argv[i][1] == 'h')
strncpy(tcp_hostname, argv[++i], sizeof(tcp_hostname)); strlcpy(tcp_hostname, argv[++i], sizeof(tcp_hostname));
else else
{ {
usage: usage: