Changed indentation

SVN revision: 764
This commit is contained in:
Stefan Ritt 2004-02-16 15:05:56 +00:00
parent 0d39b39c4c
commit 3b72352ce2

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 1.248 2004/02/16 15:05:56 midas
Changed indentation
Revision 1.247 2004/02/16 15:04:32 midas Revision 1.247 2004/02/16 15:04:32 midas
Fixed compiler warnings Fixed compiler warnings
@ -559,23 +562,40 @@ struct {
char type[32]; char type[32];
} filetype[] = { } filetype[] = {
{".CSS", "text/css"}, {
{".JPG", "image/jpeg"}, ".CSS", "text/css"},
{".JPEG", "image/jpeg"}, {
{".GIF", "image/gif"}, ".JPG", "image/jpeg"},
{".PNG", "image/png"}, {
{".PS", "application/postscript"}, ".JPEG", "image/jpeg"},
{".EPS", "application/postscript"}, {
{".HTML", "text/html"}, ".GIF", "image/gif"},
{".HTM", "text/html"}, {
{".XLS", "application/x-msexcel"}, ".PNG", "image/png"},
{".DOC", "application/msword"}, {
{".PDF", "application/pdf"}, ".PS", "application/postscript"},
{".JS", "application/x-javascript"}, {
{".TXT", "text/plain"}, ".EPS", "application/postscript"},
{".ASC", "text/plain"}, {
{".ZIP", "application/x-zip-compressed"}, ".HTML", "text/html"},
{"",""},}; {
".HTM", "text/html"},
{
".XLS", "application/x-msexcel"},
{
".DOC", "application/msword"},
{
".PDF", "application/pdf"},
{
".JS", "application/x-javascript"},
{
".TXT", "text/plain"},
{
".ASC", "text/plain"},
{
".ZIP", "application/x-zip-compressed"},
{
"", ""},};
typedef struct { typedef struct {
int message_id; int message_id;
@ -3459,6 +3479,7 @@ int el_submit(LOGBOOK * lbs, int message_id, BOOL bedit,
char attachment_all[64 * MAX_ATTACHMENTS]; char attachment_all[64 * MAX_ATTACHMENTS];
tail_size = orig_size = 0; tail_size = orig_size = 0;
buffer = NULL; buffer = NULL;
message = malloc(TEXT_SIZE + 100); message = malloc(TEXT_SIZE + 100);
assert(message); assert(message);
@ -3665,8 +3686,7 @@ int el_submit(LOGBOOK * lbs, int message_id, BOOL bedit,
for (j = i + 1; for (j = i + 1;
j < *lbs->n_el_index j < *lbs->n_el_index
&& strieq(lbs->el_index[i].file_name, lbs->el_index[j].file_name); && strieq(lbs->el_index[i].file_name, lbs->el_index[j].file_name); j++)
j++)
lbs->el_index[j].offset += delta; lbs->el_index[j].offset += delta;
} }
@ -3922,8 +3942,7 @@ INT el_delete_message(LOGBOOK * lbs, int message_id,
/* correct all offsets after deleted message */ /* correct all offsets after deleted message */
for (i = 0; i < *lbs->n_el_index; i++) for (i = 0; i < *lbs->n_el_index; i++)
if (strieq(lbs->el_index[i].file_name, str) && if (strieq(lbs->el_index[i].file_name, str) && lbs->el_index[i].offset > old_offset)
lbs->el_index[i].offset > old_offset)
lbs->el_index[i].offset -= size; lbs->el_index[i].offset -= size;
/* if other logbook has same index, update pointers */ /* if other logbook has same index, update pointers */
@ -4757,7 +4776,8 @@ int scan_attributes(char *logbook, char *condition)
/* scan configuration file for attributes and fill attr_list, attr_options /* scan configuration file for attributes and fill attr_list, attr_options
and attr_flags arrays */ and attr_flags arrays */
{ {
char list[10000], str[NAME_LENGTH], type[NAME_LENGTH], tmp_list[MAX_N_ATTR][NAME_LENGTH]; char list[10000], str[NAME_LENGTH], type[NAME_LENGTH],
tmp_list[MAX_N_ATTR][NAME_LENGTH];
int i, j, n, m; int i, j, n, m;
if (getcfg_cond(logbook, condition, "Attributes", list)) { if (getcfg_cond(logbook, condition, "Attributes", list)) {
@ -5964,7 +5984,8 @@ void show_date_selector(int day, int month, int year, char *index)
rsprintf("</select>\n"); rsprintf("</select>\n");
if (year) if (year)
rsprintf("&nbsp;%s: <input type=\"text\" size=5 maxlength=5 name=\"y%s\" value=\"%d\">", rsprintf
("&nbsp;%s: <input type=\"text\" size=5 maxlength=5 name=\"y%s\" value=\"%d\">",
loc("Year"), index, year); loc("Year"), index, year);
else else
rsprintf("&nbsp;%s: <input type=\"text\" size=5 maxlength=5 name=\"y%s\">", rsprintf("&nbsp;%s: <input type=\"text\" size=5 maxlength=5 name=\"y%s\">",
@ -6504,7 +6525,8 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
rsprintf("<td class=\"attribvalue\">"); rsprintf("<td class=\"attribvalue\">");
strencode2(str, attrib[index]); strencode2(str, attrib[index]);
rsprintf("<input type=\"text\" size=%d maxlength=%d name=\"%s\" value=\"%s\">\n", rsprintf
("<input type=\"text\" size=%d maxlength=%d name=\"%s\" value=\"%s\">\n",
input_size, input_maxlen, ua, str); input_size, input_maxlen, ua, str);
rsprintf("</td></tr>\n"); rsprintf("</td></tr>\n");
@ -7121,7 +7143,8 @@ void show_find_form(LOGBOOK * lbs)
/* table for two-column items */ /* table for two-column items */
rsprintf("<table width=\"100%%\" cellspacing=0>\n"); rsprintf("<table width=\"100%%\" cellspacing=0>\n");
rsprintf("<tr><td class=\"attribname\" nowrap width=\"10%%\">%s:</td>", loc("Entry date")); rsprintf("<tr><td class=\"attribname\" nowrap width=\"10%%\">%s:</td>",
loc("Entry date"));
rsprintf("<td class=\"attribvalue\"><table width=\"100%%\" cellspacing=0 border=0>\n"); rsprintf("<td class=\"attribvalue\"><table width=\"100%%\" cellspacing=0 border=0>\n");
rsprintf("<tr><td width=\"1%%\">%s:<td>", loc("Start")); rsprintf("<tr><td width=\"1%%\">%s:<td>", loc("Start"));
@ -7214,10 +7237,12 @@ void show_find_form(LOGBOOK * lbs)
} }
rsprintf("<tr><td class=\"attribname\">%s:</td>", loc("Text")); rsprintf("<tr><td class=\"attribname\">%s:</td>", loc("Text"));
rsprintf("<td class=\"attribvalue\"><input type=\"text\" size=\"30\" maxlength=\"80\" name=\"subtext\">\n"); rsprintf
("<td class=\"attribvalue\"><input type=\"text\" size=\"30\" maxlength=\"80\" name=\"subtext\">\n");
rsprintf("<i>%s</i></td></tr>\n", loc("(case insensitive substring)")); rsprintf("<i>%s</i></td></tr>\n", loc("(case insensitive substring)"));
rsprintf("<tr><td><td class=\"attribvalue\"><input type=checkbox name=sall value=1>%s</td></tr>\n", rsprintf
("<tr><td><td class=\"attribvalue\"><input type=checkbox name=sall value=1>%s</td></tr>\n",
loc("Search text also in attributes")); loc("Search text also in attributes"));
rsprintf("</table></td></tr></table>\n"); rsprintf("</table></td></tr></table>\n");
@ -7492,6 +7517,7 @@ int save_admin_config(char *section, char *buffer, char *error)
/* save tail */ /* save tail */
buf2 = NULL; buf2 = NULL;
if (p2) { if (p2) {
buf2 = malloc(strlen(p2) + 1); buf2 = malloc(strlen(p2) + 1);
assert(buf2); assert(buf2);
@ -10190,7 +10216,8 @@ void display_line(LOGBOOK * lbs, int message_id, int number, char *mode,
else else
strftime(str, sizeof(str), format, pts); strftime(str, sizeof(str), format, pts);
rsprintf("<td class=\"%s\"><a href=\"%s\">%s</a></td>\n", sclass, ref, str); rsprintf("<td class=\"%s\"><a href=\"%s\">%s</a></td>\n", sclass,
ref, str);
} }
@ -10710,8 +10737,7 @@ BOOL is_command_allowed(LOGBOOK * lbs, char *command)
else if (command[0]) { else if (command[0]) {
n = strbreak(menu_str, menu_item, MAX_N_LIST); n = strbreak(menu_str, menu_item, MAX_N_LIST);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
if (strieq(command, menu_item[i]) || if (strieq(command, menu_item[i]) || strieq(command, loc(menu_item[i])))
strieq(command, loc(menu_item[i])))
break; break;
if (i == n) { if (i == n) {
@ -10753,7 +10779,8 @@ void build_ref(char *ref, int size, char *mode, char *expand)
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
void show_page_filters(LOGBOOK * lbs, int n_msg, int page_n, BOOL mode_commands, BOOL threaded) void show_page_filters(LOGBOOK * lbs, int n_msg, int page_n, BOOL mode_commands,
BOOL threaded)
{ {
int cur_exp, n, i, j, index; int cur_exp, n, i, j, index;
char ref[256], str[NAME_LENGTH], comment[NAME_LENGTH], char ref[256], str[NAME_LENGTH], comment[NAME_LENGTH],
@ -10841,9 +10868,12 @@ void show_page_filters(LOGBOOK * lbs, int n_msg, int page_n, BOOL mode_commands,
rsprintf("<option %s value=1>%s\n", i == 1 ? "selected" : "", loc("Day")); rsprintf("<option %s value=1>%s\n", i == 1 ? "selected" : "", loc("Day"));
rsprintf("<option %s value=7>%s\n", i == 7 ? "selected" : "", loc("Week")); rsprintf("<option %s value=7>%s\n", i == 7 ? "selected" : "", loc("Week"));
rsprintf("<option %s value=31>%s\n", i == 31 ? "selected" : "", loc("Month")); rsprintf("<option %s value=31>%s\n", i == 31 ? "selected" : "", loc("Month"));
rsprintf("<option %s value=92>3 %s\n", i == 92 ? "selected" : "", loc("Months")); rsprintf("<option %s value=92>3 %s\n", i == 92 ? "selected" : "",
rsprintf("<option %s value=182>6 %s\n", i == 182 ? "selected" : "", loc("Months")); loc("Months"));
rsprintf("<option %s value=364>%s\n", i == 364 ? "selected" : "", loc("Year")); rsprintf("<option %s value=182>6 %s\n", i == 182 ? "selected" : "",
loc("Months"));
rsprintf("<option %s value=364>%s\n", i == 364 ? "selected" : "",
loc("Year"));
rsprintf("</select>\n"); rsprintf("</select>\n");
} else { } else {
@ -10863,19 +10893,31 @@ void show_page_filters(LOGBOOK * lbs, int n_msg, int page_n, BOOL mode_commands,
rsprintf("<option value=\"_all_\">%s\n", loc("All entries")); rsprintf("<option value=\"_all_\">%s\n", loc("All entries"));
i = atoi(getparam(list[index])); i = atoi(getparam(list[index]));
rsprintf("<option %s value=364>%s %s\n", i == 364 ? "selected" : "", loc("Next"), loc("Year")); rsprintf("<option %s value=364>%s %s\n", i == 364 ? "selected" : "",
rsprintf("<option %s value=182>%s 6 %s\n", i == 182 ? "selected" : "", loc("Next"), loc("Months")); loc("Next"), loc("Year"));
rsprintf("<option %s value=92>%s 3 %s\n", i == 92 ? "selected" : "", loc("Next"), loc("Months")); rsprintf("<option %s value=182>%s 6 %s\n", i == 182 ? "selected" : "",
rsprintf("<option %s value=31>%s %s\n", i == 31 ? "selected" : "", loc("Next"), loc("Month")); loc("Next"), loc("Months"));
rsprintf("<option %s value=7>%s %s\n", i == 7 ? "selected" : "", loc("Next"), loc("Week")); rsprintf("<option %s value=92>%s 3 %s\n", i == 92 ? "selected" : "",
rsprintf("<option %s value=1>%s %s\n", i == 1 ? "selected" : "", loc("Next"), loc("Day")); loc("Next"), loc("Months"));
rsprintf("<option %s value=31>%s %s\n", i == 31 ? "selected" : "",
loc("Next"), loc("Month"));
rsprintf("<option %s value=7>%s %s\n", i == 7 ? "selected" : "",
loc("Next"), loc("Week"));
rsprintf("<option %s value=1>%s %s\n", i == 1 ? "selected" : "",
loc("Next"), loc("Day"));
rsprintf("<option %s value=-1>%s %s\n", i == -1 ? "selected" : "", loc("Last"), loc("Day")); rsprintf("<option %s value=-1>%s %s\n", i == -1 ? "selected" : "",
rsprintf("<option %s value=-7>%s %s\n", i == -7 ? "selected" : "", loc("Last"), loc("Week")); loc("Last"), loc("Day"));
rsprintf("<option %s value=-31>%s %s\n", i == -31 ? "selected" : "", loc("Last"), loc("Month")); rsprintf("<option %s value=-7>%s %s\n", i == -7 ? "selected" : "",
rsprintf("<option %s value=-92>%s 3 %s\n", i == -92 ? "selected" : "", loc("Last"), loc("Months")); loc("Last"), loc("Week"));
rsprintf("<option %s value=-182>%s 6 %s\n", i == -182 ? "selected" : "", loc("Last"), loc("Months")); rsprintf("<option %s value=-31>%s %s\n", i == -31 ? "selected" : "",
rsprintf("<option %s value=-364>%s %s\n", i == -364 ? "selected" : "", loc("Last"), loc("Year")); loc("Last"), loc("Month"));
rsprintf("<option %s value=-92>%s 3 %s\n", i == -92 ? "selected" : "",
loc("Last"), loc("Months"));
rsprintf("<option %s value=-182>%s 6 %s\n", i == -182 ? "selected" : "",
loc("Last"), loc("Months"));
rsprintf("<option %s value=-364>%s %s\n", i == -364 ? "selected" : "",
loc("Last"), loc("Year"));
rsprintf("</select>\n"); rsprintf("</select>\n");
} }
@ -13379,8 +13421,7 @@ void show_elog_message(LOGBOOK * lbs, char *dec_path, char *command)
/* check for locked attributes */ /* check for locked attributes */
for (i = 0; i < lbs->n_attr; i++) { for (i = 0; i < lbs->n_attr; i++) {
sprintf(lattr, "l%s", attr_list[i]); sprintf(lattr, "l%s", attr_list[i]);
if (*getparam(lattr) == '1' if (*getparam(lattr) == '1' && !strieq(getparam(attr_list[i]), attrib[i]))
&& !strieq(getparam(attr_list[i]), attrib[i]))
break; break;
} }
if (i < lbs->n_attr) if (i < lbs->n_attr)
@ -13828,7 +13869,8 @@ void show_elog_message(LOGBOOK * lbs, char *dec_path, char *command)
else else
strftime(str, sizeof(str), format, pts); strftime(str, sizeof(str), format, pts);
rsprintf("%s:</td><td class=\"%s\">%s&nbsp</td>\n", attr_list[i], class_value, str); rsprintf("%s:</td><td class=\"%s\">%s&nbsp</td>\n", attr_list[i], class_value,
str);
} else { } else {
rsprintf("%s:</td><td class=\"%s\">\n", attr_list[i], class_value); rsprintf("%s:</td><td class=\"%s\">\n", attr_list[i], class_value);
@ -14372,8 +14414,7 @@ void show_logbook_node(LBLIST plb, LBLIST pparent, int level, int btop)
expand = 0; expand = 0;
if (isparam("gexp")) { if (isparam("gexp")) {
if (strieq(plb->name, getparam("gexp")) || if (strieq(plb->name, getparam("gexp")) ||
node_contains(plb, getparam("gexp")) || node_contains(plb, getparam("gexp")) || strieq(getparam("gexp"), "all"))
strieq(getparam("gexp"), "all"))
expand = 1; expand = 1;
} }
@ -15869,6 +15910,7 @@ void ctrlc_handler(int sig)
void hup_handler(int sig) void hup_handler(int sig)
{ {
_hup = TRUE; _hup = TRUE;
} }
@ -16465,15 +16507,13 @@ void server_loop(int tcp_port, int daemon)
n = strbreak(list, host_list, MAX_N_LIST); n = strbreak(list, host_list, MAX_N_LIST);
/* check if current connection matches anyone on the list */ /* check if current connection matches anyone on the list */
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (strieq(rem_host, host_list[i]) || if (strieq(rem_host, host_list[i]) || strieq(rem_host_ip, host_list[i])
strieq(rem_host_ip, host_list[i])
|| strieq(host_list[i], "all")) { || strieq(host_list[i], "all")) {
if (verbose) if (verbose)
printf printf
("Remote host \"%s\" matches \"%s\" in \"Hosts deny\". Access denied.\n", ("Remote host \"%s\" matches \"%s\" in \"Hosts deny\". Access denied.\n",
strieq(rem_host_ip, strieq(rem_host_ip,
host_list[i]) ? rem_host_ip : rem_host, host_list[i]) ? rem_host_ip : rem_host, host_list[i]);
host_list[i]);
authorized = 0; authorized = 0;
break; break;
} }
@ -16512,15 +16552,13 @@ void server_loop(int tcp_port, int daemon)
n = strbreak(list, host_list, MAX_N_LIST); n = strbreak(list, host_list, MAX_N_LIST);
/* check if current connection matches anyone on the list */ /* check if current connection matches anyone on the list */
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (strieq(rem_host, host_list[i]) || if (strieq(rem_host, host_list[i]) || strieq(rem_host_ip, host_list[i])
strieq(rem_host_ip, host_list[i])
|| strieq(host_list[i], "all")) { || strieq(host_list[i], "all")) {
if (verbose) if (verbose)
printf printf
("Remote host \"%s\" matches \"%s\" in \"Hosts allow\". Access granted.\n", ("Remote host \"%s\" matches \"%s\" in \"Hosts allow\". Access granted.\n",
strieq(rem_host_ip, strieq(rem_host_ip,
host_list[i]) ? rem_host_ip : rem_host, host_list[i]) ? rem_host_ip : rem_host, host_list[i]);
host_list[i]);
authorized = 1; authorized = 1;
break; break;
} }
@ -16641,10 +16679,10 @@ void server_loop(int tcp_port, int daemon)
if (return_length != -1) { if (return_length != -1) {
if (return_length == 0) if (return_length == 0)
return_length = strlen_retbuf; return_length = strlen_retbuf;
if ((keep_alive if ((keep_alive && strstr(return_buffer, "Content-Length") == NULL)
&& strstr(return_buffer, "Content-Length") == NULL)
|| strstr(return_buffer, "Content-Length") > || strstr(return_buffer, "Content-Length") >
strstr(return_buffer, "\r\n\r\n")) { strstr(return_buffer,
"\r\n\r\n")) {
/*---- add content-length ----*/ /*---- add content-length ----*/
p = strstr(return_buffer, "\r\n\r\n"); p = strstr(return_buffer, "\r\n\r\n");