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