diff --git a/src/elogd.c b/src/elogd.c
index 655df5a2..3c18875e 100755
--- a/src/elogd.c
+++ b/src/elogd.c
@@ -6,6 +6,9 @@
Contents: Web server program for Electronic Logbook ELOG
$Log$
+ Revision 1.319 2004/04/30 22:17:29 midas
+ Implemented text body CSV import
+
Revision 1.318 2004/04/08 14:21:14 midas
Implemented 'protect selection page'
@@ -4439,6 +4442,39 @@ void strip_html(char *s)
/*------------------------------------------------------------------*/
+void insert_breaks(char *str, int n, int size)
+{
+ int i, j, i_last;
+
+ i_last = 0;
+ for (i = 0; i < (int) strlen(str); i++) {
+ if (str[i] == '\r')
+ i_last = i;
+
+ /* if more than n chars without return, insert one */
+ if (i - i_last >= n && (int) strlen(str) + 3 < size) {
+
+ /* find previous blank */
+ while (i > i_last && str[i] != ' ')
+ i--;
+ if (str[i] == ' ')
+ i++;
+
+ /* move trailing string one char further */
+ for (j = strlen(str) + 2; j > i; j--)
+ str[j] = str[j - 2];
+
+ /* set CR */
+ str[i++] = '\r';
+ str[i++] = '\n';
+
+ i_last = i;
+ }
+ }
+}
+
+/*------------------------------------------------------------------*/
+
void rsputs(const char *str)
{
if (strlen_retbuf + (int) strlen(str) > return_buffer_size) {
@@ -8915,7 +8951,7 @@ int show_download_page(LOGBOOK * lbs, char *path)
void show_import_page(LOGBOOK * lbs)
{
- char str[256];
+ char str[256], str2[256];
/*---- header ----*/
@@ -8979,23 +9015,38 @@ void show_import_page(LOGBOOK * lbs)
rsprintf("\n");
else
rsprintf("\n");
- rsprintf("\n", loc("Derive attributes from CSV file"));
+ rsprintf("
\n",
+ loc("Derive attributes from CSV file"));
if (isparam("ignore"))
rsprintf
("\n");
else
rsprintf("\n");
- rsprintf("\n", loc("Ignore first line"));
+ rsprintf("
\n", loc("Ignore first line"));
rsprintf("\n");
- rsprintf("\n", loc("Preview import"));
+ rsprintf("
\n", loc("Preview import"));
+
+ if (isparam("filltext"))
+ rsprintf
+ ("\n");
+ else
+ rsprintf("\n");
+ strcpy(str, loc("text"));
+ sprintf(str2, loc("Column header '%s' must be present in CSV file"), str);
+ rsprintf("
\n", loc("Fill text body"), str2);
+
rsprintf("\n");
rsprintf("
");
- rsputs2(text);
+ if (text[0])
+ rsputs2(text);
+ else
+ rsputs(" ");
rsputs("");
- } else
+ } else if (text[0])
rsputs(text);
+ else
+ rsputs(" ");
}
@@ -11088,7 +11210,10 @@ void display_line(LOGBOOK * lbs, int message_id, int number, char *mode,
/* only show text, not to rip apart HTML documents,
e.g. only the start of a table */
strip_html(str);
- strencode(str);
+ if (str[0])
+ strencode(str);
+ else
+ rsputs(" ");
rsputs("\n");
if (strieq(mode, "Threaded"))
@@ -12056,14 +12181,14 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
pt1--;
pt1++;
strcpy(param, pt1);
- param[(int)pt2-(int)pt1] = 0;
- strcpy(pt1, pt2+2);
+ param[(int) pt2 - (int) pt1] = 0;
+ strcpy(pt1, pt2 + 2);
/* remove param from lastcmd if present */
if ((pt1 = strstr(_cmdline, "lastcmd=")) != NULL) {
sprintf(str, "%s%%3D", param);
if (pt1 = strstr(_cmdline, str)) {
- pt2 = pt1+strlen(str);
+ pt2 = pt1 + strlen(str);
while (*pt2 && *pt2 != '%')
pt2++;
if (*pt2 == '%')
@@ -12078,15 +12203,15 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
pt1--;
pt1++;
strcpy(param, pt1);
- if (param[strlen(param)-1] == '=')
- param[strlen(param)-1] = 0;
+ if (param[strlen(param) - 1] == '=')
+ param[strlen(param) - 1] = 0;
*pt1 = 0;
/* remove param from lastcmd if present */
if ((pt1 = strstr(_cmdline, "lastcmd=")) != NULL) {
sprintf(str, "%s%%3D", param);
if (pt1 = strstr(_cmdline, str)) {
- pt2 = pt1+strlen(str);
+ pt2 = pt1 + strlen(str);
while (*pt2 && *pt2 != '%' && *pt2 != '&')
pt2++;
if (*pt2 == '%')
@@ -12743,7 +12868,7 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
/* default menu commands */
if (menu_str[0] == 0) {
- strcpy(menu_str, "New, Find, Select, ");
+ strcpy(menu_str, "New, Find, Select, CSV Import, ");
if (getcfg(lbs->name, "Password file", str))
strcat(menu_str, "Config, Logout, ");
@@ -15717,8 +15842,7 @@ void show_selection_page()
/* if selection page protected, check password */
if (getcfg("global", "password file", str) &&
- getcfg("global", "protect selection page", str) &&
- atoi(str) == 1)
+ getcfg("global", "protect selection page", str) && atoi(str) == 1)
if (!check_user_password(NULL, getparam("unm"), getparam("upwd"), ""))
return;