--- index.c 2001/01/06 11:05:08 1.5
+++ index.c 2001/01/08 20:36:19 1.6
@@ -1,6 +1,6 @@
/*
$Source: /v/ossp/cvs/ossp-pkg/petidomo/index.c,v $
- $Revision: 1.5 $
+ $Revision: 1.6 $
Copyright (C) 2000 by CyberSolutions GmbH, Germany.
@@ -32,18 +32,11 @@
const char * defaultlist)
{
const struct PD_Config * MasterConfig = getMasterConfig();
- const struct List_Config * ListConfig;
FILE * fh;
const char * address = NULL;
char from[4096];
char envelope[4096];
- char * description;
- char * currLine;
- char * nextLine;
- char * buffer;
- DIR * dirp;
- struct dirent * entry;
- unsigned int entry_num;
+ char * p;
address = (MailStruct->Reply_To) ? MailStruct->Reply_To : MailStruct->From;
@@ -71,84 +64,17 @@
fprintf(fh, "Precedence: junk\n");
fprintf(fh, "Sender: %s\n", envelope);
fprintf(fh, "\n");
- fprintf(fh, "Index of available lists:\n");
- fprintf(fh, "=========================\n\n");
-
- /* Scan the directory. */
-
- entry_num = 0;
- dirp = opendir("lists");
- if (dirp == NULL) {
- fprintf(fh, \
-"An internal error has occured while processing your request. The\n" \
-"server administrator has been notified. You don't need to re-submit\n" \
-"your request, it will be processed as soon as the problem has been\n" \
-"remedied.\n");
- CloseMailer(fh);
- syslog(LOG_ERR, "Failed to read directory \"lists\": %m");
- return -1;
- }
- while((entry = readdir(dirp)) != NULL) {
- if (!strcasecmp(entry->d_name, ".") || !strcasecmp(entry->d_name, ".."))
- continue;
- if (isValidListName(entry->d_name) == FALSE)
- continue;
-
- ListConfig = getListConfig(entry->d_name);
- if (ListConfig->showonindex == FALSE)
- continue;
- entry_num++;
-
- /* Print stuff to the mail. */
-
- fprintf(fh, "%s", entry->d_name);
+ p = loadfile(MasterConfig->index_file);
+ if (p != NULL)
{
- int i;
- i = 40 - strlen(entry->d_name);
- if (i < 1)
- i = 1;
- while(i-- > 0)
- fputc(' ', fh);
- }
- if (ListConfig->allowpubsub == TRUE) {
- if (ListConfig->listtype == LIST_MODERATED)
- fprintf(fh, "(moderated mailing list)\n");
- else
- fprintf(fh, "(public mailing list)\n");
- }
- else
- fprintf(fh, "(closed mailing list)\n");
-
- buffer = text_easy_sprintf("lists/%s/description", entry->d_name);
- description = loadfile(buffer);
- if (description == NULL) {
- fprintf(fh, " no description available\n\n");
- continue;
+ fprintf(fh, "%s\n", p);
+ free(p);
}
-
- for (currLine = description; *currLine != '\0'; currLine = nextLine) {
- nextLine = text_find_next_line(currLine);
- if (nextLine[-1] == '\n')
- nextLine[-1] = '\0';
- fprintf(fh, " %s\n", currLine);
+ else
+ {
+ syslog(LOG_ERR, "There is no index file for Petidomo!");
+ fprintf(fh, "No index available.\n");
}
- fprintf(fh, "\n");
- free(description);
- }
- closedir(dirp);
-
- switch (entry_num) {
- case 0:
- fprintf(fh, "No mailing lists found.\n");
- break;
- case 1:
- fprintf(fh, "Found %d mailing list.\n", entry_num);
- break;
- default:
- fprintf(fh, "Found %d mailing lists.\n", entry_num);
- }
-
CloseMailer(fh);
-
return 0;
}
|