X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fdownloads.c;h=60783c5685cad880b94c1f877dc821c473891218;hb=fb6f6fa4ec4e3277e30d84326d48e6850822d318;hp=a208e51b7dc317fb4248c7dbe94bcab4ca32344e;hpb=9f145319b92b196662aa51cb2e3d7c392629965e;p=citadel.git
diff --git a/webcit/downloads.c b/webcit/downloads.c
index a208e51b7..60783c568 100644
--- a/webcit/downloads.c
+++ b/webcit/downloads.c
@@ -1,231 +1,339 @@
/*
- * $Id$
+ * Copyright (c) 1996-2012 by the citadel.org team
+ *
+ * This program is open source software. You can redistribute it and/or
+ * modify it under the terms of the GNU General Public License, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*/
+
#include "webcit.h"
#include "webserver.h"
-void display_room_directory(void)
+extern void output_static(const char* What);
+
+extern char* static_dirs[];
+
+typedef struct _FileListStruct {
+ StrBuf *Filename;
+ long FileSize;
+ StrBuf *MimeType;
+ StrBuf *Comment;
+ int IsPic;
+ int Sequence;
+} FileListStruct;
+
+void FreeFiles(void *vFile)
{
- char buf[1024];
- char filename[256];
- char filesize[256];
- char mimetype[64];
- char comment[512];
- int bg = 0;
- char title[256];
- int havepics = 0;
-
- output_headers(1, 1, 2, 0, 0, 0);
- wprintf("
\n");
-
- wprintf("
\n");
- if (havepics)
- wprintf("
", _("Slideshow"));
- wDumpContent(1);
+ if (File1->IsPic != File2->IsPic)
+ return File1->IsPic > File2->IsPic;
+ return strcasecmp(ChrPtr(File1->MimeType), ChrPtr(File2->MimeType)) != 0;
}
-void display_pictureview(void)
+int CompareFilelistByName(const void *vFile1, const void *vFile2)
{
+ FileListStruct *File1 = (FileListStruct*) GetSearchPayload(vFile1);
+ FileListStruct *File2 = (FileListStruct*) GetSearchPayload(vFile2);
+
+ if (File1->IsPic != File2->IsPic)
+ return File1->IsPic > File2->IsPic;
+ return strcasecmp(ChrPtr(File1->Filename), ChrPtr(File2->Filename));
+}
+int CompareFilelistByNameRev(const void *vFile1, const void *vFile2)
+{
+ FileListStruct *File1 = (FileListStruct*) GetSearchPayload(vFile1);
+ FileListStruct *File2 = (FileListStruct*) GetSearchPayload(vFile2);
+ if (File1->IsPic != File2->IsPic)
+ return File1->IsPic < File2->IsPic;
+ return strcasecmp(ChrPtr(File2->Filename), ChrPtr(File1->Filename));
+}
+int GroupchangeFilelistByName(const void *vFile1, const void *vFile2)
+{
+ FileListStruct *File1 = (FileListStruct*) vFile1;
+ FileListStruct *File2 = (FileListStruct*) vFile2;
+
+ return ChrPtr(File1->Filename)[0] != ChrPtr(File2->Filename)[0];
+}
+
+
+int CompareFilelistBySize(const void *vFile1, const void *vFile2)
+{
+ FileListStruct *File1 = (FileListStruct*) GetSearchPayload(vFile1);
+ FileListStruct *File2 = (FileListStruct*) GetSearchPayload(vFile2);
+ if (File1->FileSize == File2->FileSize)
+ return 0;
+ return (File1->FileSize > File2->FileSize);
+}
+int CompareFilelistBySizeRev(const void *vFile1, const void *vFile2)
+{
+ FileListStruct *File1 = (FileListStruct*) GetSearchPayload(vFile1);
+ FileListStruct *File2 = (FileListStruct*) GetSearchPayload(vFile2);
+ if (File1->FileSize == File2->FileSize)
+ return 0;
+ return (File1->FileSize < File2->FileSize);
+}
+int GroupchangeFilelistBySize(const void *vFile1, const void *vFile2)
+{
+ return 0;
+}
+
+
+int CompareFilelistByComment(const void *vFile1, const void *vFile2)
+{
+ FileListStruct *File1 = (FileListStruct*) GetSearchPayload(vFile1);
+ FileListStruct *File2 = (FileListStruct*) GetSearchPayload(vFile2);
+ return strcasecmp(ChrPtr(File1->Comment), ChrPtr(File2->Comment));
+}
+int CompareFilelistByCommentRev(const void *vFile1, const void *vFile2)
+{
+ FileListStruct *File1 = (FileListStruct*) GetSearchPayload(vFile1);
+ FileListStruct *File2 = (FileListStruct*) GetSearchPayload(vFile2);
+ return strcasecmp(ChrPtr(File2->Comment), ChrPtr(File1->Comment));
+}
+int GroupchangeFilelistByComment(const void *vFile1, const void *vFile2)
+{
+ FileListStruct *File1 = (FileListStruct*) vFile1;
+ FileListStruct *File2 = (FileListStruct*) vFile2;
+ return ChrPtr(File1->Comment)[9] != ChrPtr(File2->Comment)[0];
+}
+
+
+int CompareFilelistBySequence(const void *vFile1, const void *vFile2)
+{
+ FileListStruct *File1 = (FileListStruct*) GetSearchPayload(vFile1);
+ FileListStruct *File2 = (FileListStruct*) GetSearchPayload(vFile2);
+ return (File2->Sequence > File1->Sequence);
+}
+int GroupchangeFilelistBySequence(const void *vFile1, const void *vFile2)
+{
+ return 0;
+}
+
+/* -------------------------------------------------------------------------------- */
+HashList* LoadFileList(StrBuf *Target, WCTemplputParams *TP)
+{
+ FileListStruct *Entry;
+ StrBuf *Buf;
+ HashList *Files;
+ int Done = 0;
+ int sequence = 0;
char buf[1024];
- char filename[256];
- char filesize[256];
- char mimetype[64];
- char comment[512];
- char title[256];
- int n = 0;
-
+ CompareFunc SortIt;
+ int HavePic = 0;
+ WCTemplputParams SubTP;
- if (lbstr("frame") == 1) {
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ serv_puts("RDIR");
+ serv_getln(buf, sizeof buf);
+ if (buf[0] != '1') return NULL;
- output_headers(1, 1, 2, 0, 0, 0);
- wprintf("
\n");
- wprintf("
");
- snprintf(title, sizeof title, _("Pictures in %s"), WC->wc_roomname);
- escputs(title);
- wprintf("
");
- wprintf("\n");
-
- wprintf("