*/
void cmd_clos(char *cmdbuf)
{
- char buf[256];
-
if (CC->download_fp == NULL) {
cprintf("%d You don't have a download file open.\n", ERROR + RESOURCE_NOT_OPEN);
return;
*/
void cmd_ucls(char *cmd)
{
- struct CitContext *CCC = CC;
FILE *fp;
- char upload_notice[512];
- static int seq = 0;
+ char upload_notice[SIZ];
- if (CCC->upload_fp == NULL) {
+ if (CC->upload_fp == NULL) {
cprintf("%d You don't have an upload file open.\n", ERROR + RESOURCE_NOT_OPEN);
return;
}
fclose(CC->upload_fp);
- CCC->upload_fp = NULL;
+ CC->upload_fp = NULL;
if (!strcasecmp(cmd, "1")) {
- cprintf("%d File '%s' saved.\n", CIT_OK, CCC->upl_path);
- fp = fopen(CCC->upl_filedir, "a");
+ cprintf("%d File '%s' saved.\n", CIT_OK, CC->upl_path);
+ fp = fopen(CC->upl_filedir, "a");
if (fp == NULL) {
- fp = fopen(CCC->upl_filedir, "w");
+ fp = fopen(CC->upl_filedir, "w");
}
if (fp != NULL) {
- fprintf(fp, "%s %s %s\n", CCC->upl_file, CCC->upl_mimetype, CCC->upl_comment);
+ fprintf(fp, "%s %s %s\n", CC->upl_file, CC->upl_mimetype, CC->upl_comment);
fclose(fp);
}
- if ((CCC->room.QRflags2 & QR2_NOUPLMSG) == 0) {
+ if ((CC->room.QRflags2 & QR2_NOUPLMSG) == 0) {
/* put together an upload notice */
snprintf(upload_notice, sizeof upload_notice,
"NEW UPLOAD: '%s'\n %s\n%s\n",
- CCC->upl_file,
- CCC->upl_comment,
- CCC->upl_mimetype);
- quickie_message(CCC->curr_user, NULL, NULL, CCC->room.QRname,
- upload_notice, 0, NULL);
+ CC->upl_file,
+ CC->upl_comment,
+ CC->upl_mimetype
+ );
+ quickie_message(CC->curr_user, NULL, NULL, CC->room.QRname, upload_notice, 0, NULL);
}
} else {
- abort_upl(CCC);
- cprintf("%d File '%s' aborted.\n", CIT_OK, CCC->upl_path);
+ abort_upl(CC);
+ cprintf("%d File '%s' aborted.\n", CIT_OK, CC->upl_path);
}
}
/*
* This module handles fulltext indexing of the message base.
- * Copyright (c) 2005-2017 by the citadel.org team
+ * Copyright (c) 2005-2018 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 as published
return(0);
}
+
/*
* Flush our index cache out to disk.
*/
}
-
/*
* Add a message to the list of those to be indexed.
*/
++ft_num_msgs;
if (ft_num_msgs > ft_num_alloc) {
ft_num_alloc += 1024;
- ft_newmsgs = realloc(ft_newmsgs,
- (ft_num_alloc * sizeof(long)));
+ ft_newmsgs = realloc(ft_newmsgs, (ft_num_alloc * sizeof(long)));
}
ft_newmsgs[ft_num_msgs - 1] = msgnum;
}
}
+
/*
* Scan a room for messages to index.
*/
*/
void do_fulltext_indexing(void) {
int i;
- static time_t last_index = 0L;
static time_t last_progress = 0L;
static int is_running = 0;
if (is_running) return; /* Concurrency check - only one can run */
}
/*
- * Make sure we don't run the indexer too frequently.
- * FIXME move the setting into config
- time_t now = time(NULL);
- if ( (now - last_index) < 300L) {
- syslog(LOG_DEBUG,
- "fulltext: indexing interval not yet reached; last run was %ldm%lds ago",
- ((now - last_index) / 60),
- ((now - last_index) % 60)
- );
- return;
- }
- */
-
- /*
- * Silently return if our fulltext index is up to date with new messages.
- */
- if (
- (CtdlGetConfigLong("MMfulltext") >= CtdlGetConfigLong("MMhighest"))
- && (CtdlGetConfigInt("MM_fulltext_wordbreaker") == FT_WORDBREAKER_ID)
- ) {
- return; /* nothing to do! */
- }
-
- /*
- * If we've switched wordbreaker modules, burn the index and start
- * over.
+ * If we've switched wordbreaker modules, burn the index and start over.
*/
begin_critical_section(S_CONTROL);
if (CtdlGetConfigInt("MM_fulltext_wordbreaker") != FT_WORDBREAKER_ID) {
}
end_critical_section(S_CONTROL);
+ /*
+ * Silently return if our fulltext index is up to date with new messages.
+ */
+ if ((CtdlGetConfigLong("MMfulltext") >= CtdlGetConfigLong("MMhighest"))) {
+ return; /* nothing to do! */
+ }
+
/*
* Now go through each room and find messages to index.
*/
CtdlSetConfigLong("MMfulltext", ft_newhighest);
CtdlSetConfigInt("MM_fulltext_wordbreaker", FT_WORDBREAKER_ID);
end_critical_section(S_CONTROL);
- last_index = time(NULL);
syslog(LOG_DEBUG, "fulltext: indexing finished");
is_running = 0;
}
-
/*
* API call to perform searches.
* (This one does the "all of these words" search.)
cprintf("000\n");
}
+
/*
* Zero out our index cache.
*/
}
}
+
/*****************************************************************************/
CTDL_MODULE_INIT(fulltext)
}
-
/*
* Callback function to indicate that a message should be rejected
*/
}
-
/*
* Callback function to indicate that a vacation message should be generated
*/
}
+#if 0
/*
* Callback function to parse addresses per local system convention
* It is disabled because we don't support subaddresses.
*/
-#if 0
int ctdl_getsubaddress(sieve2_context_t *s, void *my)
{
struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
}
+#if 0
/*
* Callback function to fetch message body
* (Uncomment the code if we implement this extension)
*
+ */
int ctdl_getbody(sieve2_context_t *s, void *my)
{
return SIEVE2_ERROR_UNSUPPORTED;
}
- *
- */
+#endif
/*
return SIEVE2_ERROR_GETSCRIPT;
}
+
/*
* Callback function to retrieve message headers
*/
}
-
/*
* Add a room to the list of those rooms which potentially require sieve processing
*/
}
-
/*
* Perform sieve processing for one message (called by sieve_do_room() for each message)
*/
size_t headers_len = 0;
int len = 0;
- if (u == NULL)
- {
- syslog(LOG_EMERG, "Can't process message <%ld> without userdata!", msgnum);
+ if (u == NULL) {
+ syslog(LOG_ERR, "Can't process message <%ld> without userdata!", msgnum);
return;
}
syslog(LOG_DEBUG, "Calling sieve2_execute()");
res = sieve2_execute(sieve2_context, &my);
if (res != SIEVE2_OK) {
- syslog(LOG_CRIT, "sieve2_execute() returned %d: %s", res, sieve2_errstr(res));
+ syslog(LOG_ERR, "sieve2_execute() returned %d: %s", res, sieve2_errstr(res));
}
free(my.rfc822headers);
syslog(LOG_DEBUG, "Rules found. Performing Sieve processing for <%s>", roomname);
if (CtdlGetRoom(&CC->room, roomname) != 0) {
- syslog(LOG_CRIT, "ERROR: cannot load <%s>", roomname);
+ syslog(LOG_ERR, "ERROR: cannot load <%s>", roomname);
return;
}
res = sieve2_alloc(&sieve2_context);
if (res != SIEVE2_OK) {
- syslog(LOG_CRIT, "sieve2_alloc() returned %d: %s", res, sieve2_errstr(res));
+ syslog(LOG_ERR, "sieve2_alloc() returned %d: %s", res, sieve2_errstr(res));
return;
}
res = sieve2_callbacks(sieve2_context, ctdl_sieve_callbacks);
if (res != SIEVE2_OK) {
- syslog(LOG_CRIT, "sieve2_callbacks() returned %d: %s", res, sieve2_errstr(res));
+ syslog(LOG_ERR, "sieve2_callbacks() returned %d: %s", res, sieve2_errstr(res));
goto BAIL;
}
my.u = &u;
res = sieve2_validate(sieve2_context, &my);
if (res != SIEVE2_OK) {
- syslog(LOG_CRIT, "sieve2_validate() returned %d: %s", res, sieve2_errstr(res));
+ syslog(LOG_ERR, "sieve2_validate() returned %d: %s", res, sieve2_errstr(res));
goto BAIL;
}
BAIL:
res = sieve2_free(&sieve2_context);
if (res != SIEVE2_OK) {
- syslog(LOG_CRIT, "sieve2_free() returned %d: %s", res, sieve2_errstr(res));
+ syslog(LOG_ERR, "sieve2_free() returned %d: %s", res, sieve2_errstr(res));
}
/* Rewrite the config if we have to */
*/
res = sieve2_alloc(&sieve2_context);
if (res != SIEVE2_OK) {
- syslog(LOG_CRIT, "sieve2_alloc() returned %d: %s", res, sieve2_errstr(res));
+ syslog(LOG_ERR, "sieve2_alloc() returned %d: %s", res, sieve2_errstr(res));
return;
}
res = sieve2_callbacks(sieve2_context, ctdl_sieve_callbacks);
if (res != SIEVE2_OK) {
- syslog(LOG_CRIT, "sieve2_callbacks() returned %d: %s", res, sieve2_errstr(res));
+ syslog(LOG_ERR, "sieve2_callbacks() returned %d: %s", res, sieve2_errstr(res));
goto BAIL;
}
BAIL: res = sieve2_free(&sieve2_context);
if (res != SIEVE2_OK) {
- syslog(LOG_CRIT, "sieve2_free() returned %d: %s", res, sieve2_errstr(res));
+ syslog(LOG_ERR, "sieve2_free() returned %d: %s", res, sieve2_errstr(res));
}
}
+
void cleanup_sieve(void)
{
struct RoomProcList *ptr, *ptr2;
end_critical_section(S_SIEVELIST);
}
+
int serv_sieve_room(struct ctdlroom *room)
{
if (!strcasecmp(&room->QRname[11], MAILROOM)) {
return 0;
}
+
CTDL_MODULE_INIT(sieve)
{
if (!threading)
/* return our module name for the log */
return "sieve";
}
-