Mercurial > noffle
comparison control.c @ 26:526a4c34ee2e noffle
[svn] Applied patch from Jim Hague: support for local groups / new command
line options --create and --cancel.
author | enz |
---|---|
date | Sat, 29 Apr 2000 15:45:56 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
25:ab6cf19be6d3 | 26:526a4c34ee2e |
---|---|
1 /* | |
2 control.c | |
3 | |
4 $Id: control.c 32 2000-04-29 14:45:56Z enz $ | |
5 */ | |
6 | |
7 #include "control.h" | |
8 #include <stdio.h> | |
9 #include "common.h" | |
10 #include "content.h" | |
11 #include "database.h" | |
12 #include "group.h" | |
13 #include "itemlist.h" | |
14 #include "log.h" | |
15 #include "outgoing.h" | |
16 | |
17 int | |
18 Ctrl_cancel( const char *msgId ) | |
19 { | |
20 ItemList *refs; | |
21 const char *ref; | |
22 Str server; | |
23 Bool seen = FALSE; | |
24 int res = CANCEL_OK; | |
25 | |
26 /* See if in outgoing and zap if so. */ | |
27 if ( Out_find( msgId, server ) ) | |
28 { | |
29 Out_remove( server, msgId ); | |
30 Log_inf( "'%s' cancelled from outgoing queue for '%s'.\n", | |
31 msgId, server ); | |
32 seen = TRUE; | |
33 } | |
34 | |
35 if ( ! Db_contains( msgId ) ) | |
36 { | |
37 Log_inf( "Cancel: '%s' not in database.", msgId ); | |
38 return seen ? CANCEL_OK : CANCEL_NO_SUCH_MSG; | |
39 } | |
40 | |
41 /* | |
42 Retrieve the Xrefs, remove from each group and then | |
43 remove from the database. | |
44 */ | |
45 refs = new_Itl( Db_xref( msgId ), " " ); | |
46 for( ref = Itl_first( refs ); ref != NULL; ref = Itl_next( refs ) ) | |
47 { | |
48 Str grp; | |
49 int no; | |
50 | |
51 if ( sscanf( ref, "%s:%d", grp, &no ) != 2 ) | |
52 break; | |
53 | |
54 if ( Grp_exists( grp ) ) | |
55 { | |
56 Cont_read( grp ); | |
57 Cont_delete( no ); | |
58 Cont_write(); | |
59 | |
60 if ( ! Grp_local( grp ) && ! seen ) | |
61 res = CANCEL_NEEDS_MSG; | |
62 | |
63 Log_dbg( "Removed '%s' from group '%s'.", msgId, grp ); | |
64 } | |
65 else | |
66 { | |
67 Log_inf( "Group '%s' in Xref for '%s' not found.", grp, msgId ); | |
68 } | |
69 } | |
70 del_Itl( refs ); | |
71 Db_delete( msgId ); | |
72 Log_inf( "Message '%s' cancelled.", msgId ); | |
73 return res; | |
74 } |