Mercurial > noffle
view src/control.c @ 422:18b3c63bf7dc noffle
[svn] fixed update-inetd
author | godisch |
---|---|
date | Fri, 20 Jun 2003 07:35:55 +0100 |
parents | 21300895412f |
children |
line wrap: on
line source
/* control.c $Id: control.c 517 2003-04-03 17:21:24Z bears $ */ #if HAVE_CONFIG_H #include <config.h> #endif #include <stdio.h> #include "common.h" #include "content.h" #include "control.h" #include "database.h" #include "group.h" #include "itemlist.h" #include "log.h" #include "outgoing.h" #include "portable.h" int Ctrl_cancel( const char *msgId ) { ItemList *refs; const char *ref; Str server; Bool inOutgoing = FALSE; int res = CANCEL_OK; Bool removeFromDb = TRUE; /* See if in outgoing and zap if so. */ if ( Out_find( msgId, server ) ) { Out_remove( server, msgId ); Log_dbg( LOG_DBG_CONTROL, "'%s' cancelled from outgoing queue for '%s'.\n", msgId, server ); inOutgoing = TRUE; } if ( ! Db_contains( msgId ) ) { Log_dbg( LOG_DBG_CONTROL, "Cancel: '%s' not in database.", msgId ); return inOutgoing ? CANCEL_OK : CANCEL_NO_SUCH_MSG; } /* Retrieve the Xrefs, remove from each group and then remove from the database. */ refs = new_Itl( Db_xref( msgId ), " " ); for( ref = Itl_first( refs ); ref != NULL; ref = Itl_next( refs ) ) { Str grp; int no; if ( sscanf( ref, "%"MAXCHAR_STR"[^:]:%d", grp, &no ) != 2 ) break; if ( Grp_exists( grp ) ) { Cont_read( grp ); Cont_delete( no ); /* * If we don't manage to remove the overview, leave the message * in the main database to avoid confusion. Yes, the message * will not be cancelled properly for this group but we don't * signal this to the calling routine. */ if ( Cont_write() ) Log_dbg( LOG_DBG_CONTROL, "Removed '%s' from group '%s'.", msgId, grp ); else removeFromDb = FALSE; if ( ! Grp_local( grp ) && ! inOutgoing ) res = CANCEL_NEEDS_MSG; } else { Log_dbg( LOG_DBG_CONTROL, "Group '%s' in Xref for '%s' not found.", grp, msgId ); } } del_Itl( refs ); if ( removeFromDb ) Db_delete( msgId ); Log_dbg( LOG_DBG_CONTROL, "Message '%s' cancelled%s.", msgId, (res == CANCEL_NEEDS_MSG) ? ", needs cancelling upstream" : "" ); return res; }