pristine/ext_todo-20030105.patch
author "Tomas Zeman <tzeman@volny.cz>"
Thu, 01 Nov 2007 16:41:45 +0100
changeset 1 b375914441b2
permissions -rw-r--r--
mq init; added pristine patches + fix for qregex
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     1
diff -uN qmail-1.03/EXTTODO qmail-exttodo/EXTTODO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     2
--- qmail-1.03/EXTTODO	Thu Jan  1 01:00:00 1970
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     3
+++ qmail-exttodo/EXTTODO	Sun Jan  5 22:12:01 2003
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     4
@@ -0,0 +1,114 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     5
+EXTTODO by Claudio Jeker <jeker@n-r-g.com> and 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     6
+Andre Oppermann <opi@nrg4u.com>
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     7
+(c) 1998,1999,2000,2001,2002 Internet Business Solutions Ltd.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     8
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     9
+The EXTTODO patch is a part of the qmail-ldap patch.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    10
+This patches for qmail come with NO WARRANTY.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    11
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    12
+These patches are under the BSD license.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    13
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    14
+RELEASE: 5. Jan. 2003
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    15
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    16
+EXTTODO:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    17
+======================
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    18
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    19
+TOC:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    20
+ WHAT DOES IT DO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    21
+ INSTALL
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    22
+ CONFIG FILES
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    23
+ SETUP
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    24
+ BIG PICTURE
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    25
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    26
+NEWS:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    27
+ 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    28
+ This is the first release of the EXTTODO patch.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    29
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    30
+================================================================================
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    31
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    32
+WHAT DOES IT DO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    33
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    34
+ The exttodo patch addresses a problem known as the silly qmail (queue)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    35
+ problem. This problem is found only on system with high injection rates.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    36
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    37
+ qmail with a big local and remote concurrency could deliver a tremendous 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    38
+ amount of messages but normally this can not be achieved because qmail-send
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    39
+ becomes a bottleneck on those high volumes servers.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    40
+ qmail-send preprocesses all new messages before distributing them for local
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    41
+ or remote delivering. In one run qmail-send does one todo run but has the 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    42
+ ability to close multiple jobs. Because of this layout qmail-send can not 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    43
+ feed all the new available (local/remote) delivery slots and therefor it is 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    44
+ not possible to achieve the maximum throughput.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    45
+ This would be a minor problem if one qmail-send run could be done in extreme
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    46
+ short time but because of many file system calls (fsync and (un)link) a todo
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    47
+ run is expensive and throttles the throughput.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    48
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    49
+ The exttodo patch tries to solve the problem by moving the todo routine into 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    50
+ an external program. This reduces the run time in qmail-send.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    51
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    52
+ exttodo adds a new program to qmail called qmail-todo. qmail-todo prepares
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    53
+ incoming messages for local and remote delivering (by creating info/<messid>
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    54
+ local/<messid> and remote/<messid> and removing todo/<messid>). See also
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    55
+ INTERNALS. As next qmail-todo transmits the <messid> to qmail-send which will
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    56
+ add this message into the priority queue which schedules the message for 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    57
+ delivery. 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    58
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    59
+INSTALL
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    60
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    61
+ To enable the exttodo patch you need to define EXTERNAL_TODO while compiling
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    62
+ qmail(-ldap) this can be done with the -D flag of cc (e.g. cc -DEXTERNAL_TODO).
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    63
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    64
+ NOTE: the exttodo patch can also be used on qmail systems without the 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    65
+ qmail-ldap patch.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    66
+ 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    67
+================================================================================
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    68
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    69
+CONFIG FILES
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    70
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    71
+ No additional control files are used or needed.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    72
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    73
+================================================================================
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    74
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    75
+SETUP
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    76
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    77
+ qmail-todo will be started by qmail-start and therefor no additional setup
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    78
+ is needed.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    79
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    80
+ To verify that exttodo is running just check if qmail-todo is running.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    81
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    82
+================================================================================
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    83
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    84
+BIG PICTURE
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    85
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    86
+               +-------+   +-------+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    87
+               | clean |   | clean |
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    88
+               +--0-1--+   +--0-1--+       +-----------+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    89
+         trigger  ^ |         ^ |        +->0,1 lspawn |
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    90
+            |     | v         | v       /  +-----------+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    91
+ +-------+  v  +--2-3--+   +--5-6--+   /
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    92
+ |       |  |  |       0<--7     1,2<-+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    93
+ | queue |--+--| todo  |   | send  |
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    94
+ |       |  |  |       1-->8     3,4<-+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    95
+ +-------+     +-------+   +---0---+   \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    96
+                               |        \  +-----------+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    97
+                               v         +->0,1 rspwan |
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    98
+                           +---0---+       +-----------+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    99
+                           | logger|
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   100
+                           +-------+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   101
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   102
+Communication between qmail-send and qmail-todo
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   103
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   104
+todo -> send:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   105
+   D[LRB]<mesgid>\0
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   106
+          Start delivery for new message with id <messid>.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   107
+          the character L, R or B defines the type
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   108
+          of delivery, local, remote or both respectively.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   109
+   L<string>\0
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   110
+          Dump string to the logger without adding additional \n or similar.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   111
+send -> todo:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   112
+   H      Got a SIGHUP reread ~/control/locals and ~/control/virtualdomains
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   113
+   X      Quit ASAP.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   114
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   115
+qmail-todo sends "\0" terminated messages whereas qmail-send just send one
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   116
+character to qmail-todo.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   117
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   118
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   119
diff -uN qmail-1.03/EXTTODO-INFO qmail-exttodo/EXTTODO-INFO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   120
--- qmail-1.03/EXTTODO-INFO	Thu Jan  1 01:00:00 1970
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   121
+++ qmail-exttodo/EXTTODO-INFO	Tue Apr 30 16:49:02 2002
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   122
@@ -0,0 +1,11 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   123
+Files modified:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   124
+Makefile
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   125
+EXTTODO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   126
+FILES
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   127
+TARGETS
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   128
+qmail-send.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   129
+qmail-todo.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   130
+qmail-start.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   131
+hier.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   132
+install-big.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   133
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   134
diff -uN qmail-1.03/FILES qmail-exttodo/FILES
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   135
--- qmail-1.03/FILES	Mon Jun 15 12:53:16 1998
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   136
+++ qmail-exttodo/FILES	Mon Apr 22 13:59:28 2002
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   137
@@ -431,3 +431,4 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   138
 tcp-environ.5
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   139
 constmap.h
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   140
 constmap.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   141
+qmail-todo.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   142
diff -uN qmail-1.03/Makefile qmail-exttodo/Makefile
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   143
--- qmail-1.03/Makefile	Mon Jun 15 12:53:16 1998
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   144
+++ qmail-exttodo/Makefile	Mon Apr 22 14:55:59 2002
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   145
@@ -1,5 +1,7 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   146
 # Don't edit Makefile! Use conf-* for configuration.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   147
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   148
+DEFINES=-DEXTERNAL_TODO # use to enable external todo
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   149
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   150
 SHELL=/bin/sh
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   151
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   152
 default: it
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   153
@@ -703,7 +705,7 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   154
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   155
 hier.o: \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   156
 compile hier.c auto_qmail.h auto_split.h auto_uids.h fmt.h fifo.h
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   157
-	./compile hier.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   158
+	./compile $(DEFINES) hier.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   159
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   160
 home: \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   161
 home.sh conf-qmail
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   162
@@ -755,7 +757,7 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   163
 install-big.o: \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   164
 compile install-big.c auto_qmail.h auto_split.h auto_uids.h fmt.h \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   165
 fifo.h
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   166
-	./compile install-big.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   167
+	./compile $(DEFINES) install-big.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   168
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   169
 install.o: \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   170
 compile install.c substdio.h strerr.h error.h open.h readwrite.h \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   171
@@ -808,7 +810,7 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   172
 forward preline condredirect bouncesaying except maildirmake \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   173
 maildir2mbox maildirwatch qail elq pinq idedit install-big install \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   174
 instcheck home home+df proc proc+df binm1 binm1+df binm2 binm2+df \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   175
-binm3 binm3+df
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   176
+binm3 binm3+df qmail-todo
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   177
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   178
 load: \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   179
 make-load warn-auto.sh systype
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   180
@@ -1509,7 +1511,7 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   181
 scan.h case.h auto_qmail.h trigger.h newfield.h stralloc.h quote.h \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   182
 qmail.h substdio.h qsutil.h prioq.h datetime.h gen_alloc.h constmap.h \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   183
 fmtqfn.h readsubdir.h direntry.h
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   184
-	./compile qmail-send.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   185
+	./compile $(DEFINES) qmail-send.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   186
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   187
 qmail-showctl: \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   188
 load qmail-showctl.o auto_uids.o control.o open.a getln.a stralloc.a \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   189
@@ -1574,7 +1576,7 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   190
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   191
 qmail-start.o: \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   192
 compile qmail-start.c fd.h prot.h exit.h fork.h auto_uids.h
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   193
-	./compile qmail-start.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   194
+	./compile $(DEFINES) qmail-start.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   195
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   196
 qmail-tcpok: \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   197
 load qmail-tcpok.o open.a lock.a strerr.a substdio.a error.a str.a \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   198
@@ -1605,6 +1607,20 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   199
 compile qmail-tcpto.c substdio.h subfd.h substdio.h auto_qmail.h \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   200
 fmt.h ip.h lock.h error.h exit.h datetime.h now.h datetime.h
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   201
 	./compile qmail-tcpto.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   202
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   203
+qmail-todo: \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   204
+load qmail-todo.o control.o constmap.o trigger.o fmtqfn.o now.o \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   205
+readsubdir.o case.a ndelay.a getln.a sig.a open.a stralloc.a alloc.a \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   206
+substdio.a error.a str.a fs.a auto_qmail.o auto_split.o
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   207
+	./load qmail-todo control.o constmap.o trigger.o fmtqfn.o now.o \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   208
+	readsubdir.o case.a ndelay.a getln.a sig.a open.a stralloc.a \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   209
+	alloc.a substdio.a error.a str.a fs.a auto_qmail.o auto_split.o
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   210
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   211
+qmail-todo.o: \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   212
+compile alloc.h auto_qmail.h byte.h constmap.h control.h direntry.h error.h \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   213
+exit.h fmt.h fmtqfn.h getln.h open.h ndelay.h now.h readsubdir.h readwrite.h \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   214
+scan.h select.h str.h stralloc.h substdio.h trigger.h
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   215
+	./compile $(DEFINES) qmail-todo.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   216
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   217
 qmail-upq: \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   218
 warn-auto.sh qmail-upq.sh conf-qmail conf-break conf-split
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   219
diff -uN qmail-1.03/TARGETS qmail-exttodo/TARGETS
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   220
--- qmail-1.03/TARGETS	Mon Jun 15 12:53:16 1998
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   221
+++ qmail-exttodo/TARGETS	Mon Apr 22 13:59:32 2002
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   222
@@ -385,3 +385,5 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   223
 man
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   224
 setup
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   225
 check
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   226
+qmail-todo.o
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   227
+qmail-todo
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   228
diff -uN qmail-1.03/hier.c qmail-exttodo/hier.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   229
--- qmail-1.03/hier.c	Mon Jun 15 12:53:16 1998
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   230
+++ qmail-exttodo/hier.c	Mon Apr 22 14:01:58 2002
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   231
@@ -108,6 +108,9 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   232
   c(auto_qmail,"bin","qmail-rspawn",auto_uido,auto_gidq,0711);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   233
   c(auto_qmail,"bin","qmail-clean",auto_uido,auto_gidq,0711);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   234
   c(auto_qmail,"bin","qmail-send",auto_uido,auto_gidq,0711);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   235
+#ifdef EXTERNAL_TODO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   236
+  c(auto_qmail,"bin","qmail-todo",auto_uido,auto_gidq,0711);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   237
+#endif
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   238
   c(auto_qmail,"bin","splogger",auto_uido,auto_gidq,0711);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   239
   c(auto_qmail,"bin","qmail-newu",auto_uido,auto_gidq,0700);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   240
   c(auto_qmail,"bin","qmail-newmrh",auto_uido,auto_gidq,0700);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   241
diff -uN qmail-1.03/install-big.c qmail-exttodo/install-big.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   242
--- qmail-1.03/install-big.c	Mon Jun 15 12:53:16 1998
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   243
+++ qmail-exttodo/install-big.c	Mon Apr 22 14:02:11 2002
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   244
@@ -108,6 +108,9 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   245
   c(auto_qmail,"bin","qmail-rspawn",auto_uido,auto_gidq,0711);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   246
   c(auto_qmail,"bin","qmail-clean",auto_uido,auto_gidq,0711);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   247
   c(auto_qmail,"bin","qmail-send",auto_uido,auto_gidq,0711);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   248
+#ifdef EXTERNAL_TODO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   249
+  c(auto_qmail,"bin","qmail-todo",auto_uido,auto_gidq,0711);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   250
+#endif
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   251
   c(auto_qmail,"bin","splogger",auto_uido,auto_gidq,0711);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   252
   c(auto_qmail,"bin","qmail-newu",auto_uido,auto_gidq,0700);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   253
   c(auto_qmail,"bin","qmail-newmrh",auto_uido,auto_gidq,0700);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   254
diff -uN qmail-1.03/qmail-send.c qmail-exttodo/qmail-send.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   255
--- qmail-1.03/qmail-send.c	Mon Jun 15 12:53:16 1998
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   256
+++ qmail-exttodo/qmail-send.c	Sun Jan  5 22:09:42 2003
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   257
@@ -1215,6 +1215,7 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   258
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   259
 /* this file is too long ---------------------------------------------- TODO */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   260
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   261
+#ifndef EXTERNAL_TODO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   262
 datetime_sec nexttodorun;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   263
 DIR *tododir; /* if 0, have to opendir again */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   264
 stralloc todoline = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   265
@@ -1438,6 +1439,143 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   266
    if (fdchan[c] != -1) close(fdchan[c]);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   267
 }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   268
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   269
+#endif
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   270
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   271
+/* this file is too long ------------------------------------- EXTERNAL TODO */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   272
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   273
+#ifdef EXTERNAL_TODO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   274
+stralloc todoline = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   275
+char todobuf[2048];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   276
+int todofdin;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   277
+int todofdout;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   278
+int flagtodoalive;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   279
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   280
+void tododied() { log1("alert: oh no! lost qmail-todo connection! dying...\n");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   281
+ flagexitasap = 1; flagtodoalive = 0; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   282
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   283
+void todo_init()
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   284
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   285
+  todofdout = 7;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   286
+  todofdin = 8;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   287
+  flagtodoalive = 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   288
+  /* sync with external todo */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   289
+  if (write(todofdout, "S", 1) != 1) tododied();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   290
+  
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   291
+  return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   292
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   293
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   294
+void todo_selprep(nfds,rfds,wakeup)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   295
+int *nfds;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   296
+fd_set *rfds;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   297
+datetime_sec *wakeup;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   298
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   299
+  if (flagexitasap) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   300
+    if (flagtodoalive) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   301
+      write(todofdout, "X", 1);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   302
+    }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   303
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   304
+  if (flagtodoalive) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   305
+    FD_SET(todofdin,rfds);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   306
+    if (*nfds <= todofdin)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   307
+      *nfds = todofdin + 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   308
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   309
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   310
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   311
+void todo_del(char* s)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   312
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   313
+ int flagchan[CHANNELS];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   314
+ struct prioq_elt pe;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   315
+ unsigned long id;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   316
+ unsigned int len;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   317
+ int c;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   318
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   319
+ for (c = 0;c < CHANNELS;++c) flagchan[c] = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   320
+ switch(*s++) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   321
+  case 'L':
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   322
+    flagchan[0] = 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   323
+    break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   324
+  case 'R':
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   325
+    flagchan[1] = 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   326
+    break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   327
+  case 'B':
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   328
+    flagchan[0] = 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   329
+    flagchan[1] = 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   330
+    break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   331
+  case 'X':
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   332
+    break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   333
+  default:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   334
+    log1("warning: qmail-send unable to understand qmail-todo\n");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   335
+    return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   336
+ }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   337
+ 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   338
+ len = scan_ulong(s,&id);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   339
+ if (!len || s[len]) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   340
+  log1("warning: qmail-send unable to understand qmail-todo\n");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   341
+  return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   342
+ }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   343
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   344
+ pe.id = id; pe.dt = now();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   345
+ for (c = 0;c < CHANNELS;++c)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   346
+   if (flagchan[c])
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   347
+     while (!prioq_insert(&pqchan[c],&pe)) nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   348
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   349
+ for (c = 0;c < CHANNELS;++c) if (flagchan[c]) break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   350
+ if (c == CHANNELS)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   351
+   while (!prioq_insert(&pqdone,&pe)) nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   352
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   353
+ return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   354
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   355
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   356
+void todo_do(rfds)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   357
+fd_set *rfds;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   358
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   359
+  int r;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   360
+  char ch;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   361
+  int i;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   362
+  
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   363
+  if (!flagtodoalive) return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   364
+  if (!FD_ISSET(todofdin,rfds)) return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   365
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   366
+  r = read(todofdin,todobuf,sizeof(todobuf));
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   367
+  if (r == -1) return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   368
+  if (r == 0) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   369
+    if (flagexitasap)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   370
+      flagtodoalive = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   371
+    else
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   372
+      tododied();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   373
+    return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   374
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   375
+  for (i = 0;i < r;++i) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   376
+    ch = todobuf[i];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   377
+    while (!stralloc_append(&todoline,&ch)) nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   378
+    if (todoline.len > REPORTMAX)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   379
+      todoline.len = REPORTMAX;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   380
+      /* qmail-todo is responsible for keeping it short */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   381
+    if (!ch && (todoline.len > 1)) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   382
+      switch (todoline.s[0]) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   383
+	case 'D':
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   384
+	  if (flagexitasap) break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   385
+	  todo_del(todoline.s + 1);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   386
+	  break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   387
+	case 'L':
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   388
+	  log1(todoline.s + 1);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   389
+	  break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   390
+	case 'X':
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   391
+	  if (flagexitasap)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   392
+	    flagtodoalive = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   393
+	  else
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   394
+	    tododied();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   395
+	  break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   396
+	default:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   397
+	  log1("warning: qmail-send unable to understand qmail-todo: report mangled\n");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   398
+	  break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   399
+      }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   400
+      todoline.len = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   401
+    }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   402
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   403
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   404
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   405
+#endif
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   406
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   407
 /* this file is too long ---------------------------------------------- MAIN */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   408
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   409
@@ -1504,6 +1642,9 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   410
    log1("alert: unable to reread controls: unable to switch to home directory\n");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   411
    return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   412
   }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   413
+#ifdef EXTERNAL_TODO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   414
+ write(todofdout, "H", 1);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   415
+#endif
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   416
  regetcontrols();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   417
  while (chdir("queue") == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   418
   {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   419
@@ -1568,8 +1709,12 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   420
  todo_init();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   421
  cleanup_init();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   422
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   423
+#ifdef EXTERNAL_TODO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   424
+ while (!flagexitasap || !del_canexit() || flagtodoalive)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   425
+#else
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   426
  while (!flagexitasap || !del_canexit())
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   427
-  {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   428
+#endif
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   429
+ {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   430
    recent = now();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   431
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   432
    if (flagrunasap) { flagrunasap = 0; pqrun(); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   433
diff -uN qmail-1.03/qmail-start.c qmail-exttodo/qmail-start.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   434
--- qmail-1.03/qmail-start.c	Mon Jun 15 12:53:16 1998
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   435
+++ qmail-exttodo/qmail-start.c	Mon Apr 22 13:55:48 2002
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   436
@@ -8,6 +8,9 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   437
 char *(qcargs[]) = { "qmail-clean", 0 };
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   438
 char *(qlargs[]) = { "qmail-lspawn", "./Mailbox", 0 };
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   439
 char *(qrargs[]) = { "qmail-rspawn", 0 };
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   440
+#ifdef EXTERNAL_TODO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   441
+char *(qtargs[]) = { "qmail-todo", 0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   442
+#endif
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   443
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   444
 void die() { _exit(111); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   445
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   446
@@ -18,13 +21,28 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   447
 int pi4[2];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   448
 int pi5[2];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   449
 int pi6[2];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   450
-
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   451
-void close23456() { close(2); close(3); close(4); close(5); close(6); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   452
+#ifdef EXTERNAL_TODO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   453
+int pi7[2];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   454
+int pi8[2];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   455
+int pi9[2];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   456
+int pi10[2];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   457
+#endif
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   458
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   459
+void close23456() { 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   460
+  close(2); close(3); close(4); close(5); close(6); 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   461
+#ifdef EXTERNAL_TODO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   462
+  close(7); close(8);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   463
+#endif
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   464
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   465
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   466
 void closepipes() {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   467
   close(pi1[0]); close(pi1[1]); close(pi2[0]); close(pi2[1]);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   468
   close(pi3[0]); close(pi3[1]); close(pi4[0]); close(pi4[1]);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   469
   close(pi5[0]); close(pi5[1]); close(pi6[0]); close(pi6[1]);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   470
+#ifdef EXTERNAL_TODO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   471
+  close(pi7[0]); close(pi7[1]); close(pi8[0]); close(pi8[1]);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   472
+	close(pi9[0]); close(pi9[1]); close(pi10[0]); close(pi10[1]);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   473
+#endif
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   474
 }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   475
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   476
 void main(argc,argv)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   477
@@ -40,6 +58,10 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   478
   if (fd_copy(4,0) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   479
   if (fd_copy(5,0) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   480
   if (fd_copy(6,0) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   481
+#ifdef EXTERNAL_TODO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   482
+  if (fd_copy(7,0) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   483
+  if (fd_copy(8,0) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   484
+#endif
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   485
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   486
   if (argv[1]) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   487
     qlargs[1] = argv[1];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   488
@@ -70,6 +92,12 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   489
   if (pipe(pi4) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   490
   if (pipe(pi5) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   491
   if (pipe(pi6) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   492
+#ifdef EXTERNAL_TODO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   493
+  if (pipe(pi7) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   494
+  if (pipe(pi8) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   495
+  if (pipe(pi9) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   496
+  if (pipe(pi10) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   497
+#endif
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   498
  
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   499
   switch(fork()) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   500
     case -1: die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   501
@@ -105,6 +133,34 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   502
       execvp(*qcargs,qcargs);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   503
       die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   504
   }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   505
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   506
+#ifdef EXTERNAL_TODO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   507
+  switch(fork()) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   508
+    case -1: die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   509
+    case 0:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   510
+      if (prot_uid(auto_uids) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   511
+      if (fd_copy(0,pi7[0]) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   512
+      if (fd_copy(1,pi8[1]) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   513
+      close23456();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   514
+      if (fd_copy(2,pi9[1]) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   515
+      if (fd_copy(3,pi10[0]) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   516
+      closepipes();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   517
+      execvp(*qtargs,qtargs);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   518
+      die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   519
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   520
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   521
+  switch(fork()) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   522
+    case -1: die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   523
+    case 0:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   524
+      if (prot_uid(auto_uidq) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   525
+      if (fd_copy(0,pi9[0]) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   526
+      if (fd_copy(1,pi10[1]) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   527
+      close23456();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   528
+      closepipes();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   529
+      execvp(*qcargs,qcargs);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   530
+      die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   531
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   532
+#endif
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   533
  
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   534
   if (prot_uid(auto_uids) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   535
   if (fd_copy(0,1) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   536
@@ -114,6 +170,10 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   537
   if (fd_copy(4,pi4[0]) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   538
   if (fd_copy(5,pi5[1]) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   539
   if (fd_copy(6,pi6[0]) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   540
+#ifdef EXTERNAL_TODO
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   541
+  if (fd_copy(7,pi7[1]) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   542
+  if (fd_copy(8,pi8[0]) == -1) die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   543
+#endif
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   544
   closepipes();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   545
   execvp(*qsargs,qsargs);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   546
   die();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   547
diff -uN qmail-1.03/qmail-todo.c qmail-exttodo/qmail-todo.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   548
--- qmail-1.03/qmail-todo.c	Thu Jan  1 01:00:00 1970
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   549
+++ qmail-exttodo/qmail-todo.c	Sun Jan  5 22:16:34 2003
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   550
@@ -0,0 +1,688 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   551
+#include <sys/types.h>
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   552
+#include <sys/stat.h>
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   553
+#include "alloc.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   554
+#include "auto_qmail.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   555
+#include "byte.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   556
+#include "constmap.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   557
+#include "control.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   558
+#include "direntry.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   559
+#include "error.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   560
+#include "exit.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   561
+#include "fmt.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   562
+#include "fmtqfn.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   563
+#include "getln.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   564
+#include "open.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   565
+#include "ndelay.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   566
+#include "now.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   567
+#include "readsubdir.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   568
+#include "readwrite.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   569
+#include "scan.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   570
+#include "select.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   571
+#include "str.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   572
+#include "stralloc.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   573
+#include "substdio.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   574
+#include "trigger.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   575
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   576
+/* critical timing feature #1: if not triggered, do not busy-loop */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   577
+/* critical timing feature #2: if triggered, respond within fixed time */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   578
+/* important timing feature: when triggered, respond instantly */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   579
+#define SLEEP_TODO 1500 /* check todo/ every 25 minutes in any case */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   580
+#define SLEEP_FUZZ 1 /* slop a bit on sleeps to avoid zeno effect */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   581
+#define SLEEP_FOREVER 86400 /* absolute maximum time spent in select() */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   582
+#define SLEEP_SYSFAIL 123
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   583
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   584
+stralloc percenthack = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   585
+struct constmap mappercenthack;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   586
+stralloc locals = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   587
+struct constmap maplocals;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   588
+stralloc vdoms = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   589
+struct constmap mapvdoms;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   590
+stralloc envnoathost = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   591
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   592
+char strnum[FMT_ULONG];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   593
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   594
+/* XXX not good, if qmail-send.c changes this has to be updated */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   595
+#define CHANNELS 2
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   596
+char *chanaddr[CHANNELS] = { "local/", "remote/" };
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   597
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   598
+datetime_sec recent;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   599
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   600
+void log1(char *x);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   601
+void log3(char* x, char* y, char* z);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   602
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   603
+int flagstopasap = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   604
+void sigterm(void)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   605
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   606
+  if (flagstopasap == 0)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   607
+    log1("status: qmail-todo stop processing asap\n");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   608
+  flagstopasap = 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   609
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   610
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   611
+int flagreadasap = 0; void sighup(void) { flagreadasap = 1; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   612
+int flagsendalive = 1; void senddied(void) { flagsendalive = 0; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   613
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   614
+void nomem() { log1("alert: out of memory, sleeping...\n"); sleep(10); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   615
+void pausedir(dir) char *dir;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   616
+{ log3("alert: unable to opendir ",dir,", sleeping...\n"); sleep(10); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   617
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   618
+void cleandied()
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   619
+{ 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   620
+  log1("alert: qmail-todo: oh no! lost qmail-clean connection! dying...\n");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   621
+  flagstopasap = 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   622
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   623
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   624
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   625
+/* this file is not so long ------------------------------------- FILENAMES */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   626
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   627
+stralloc fn = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   628
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   629
+void fnmake_init(void)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   630
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   631
+ while (!stralloc_ready(&fn,FMTQFN)) nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   632
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   633
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   634
+void fnmake_info(unsigned long id) { fn.len = fmtqfn(fn.s,"info/",id,1); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   635
+void fnmake_todo(unsigned long id) { fn.len = fmtqfn(fn.s,"todo/",id,0); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   636
+void fnmake_mess(unsigned long id) { fn.len = fmtqfn(fn.s,"mess/",id,1); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   637
+void fnmake_chanaddr(unsigned long id, int c)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   638
+{ fn.len = fmtqfn(fn.s,chanaddr[c],id,1); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   639
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   640
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   641
+/* this file is not so long ------------------------------------- REWRITING */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   642
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   643
+stralloc rwline = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   644
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   645
+/* 1 if by land, 2 if by sea, 0 if out of memory. not allowed to barf. */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   646
+/* may trash recip. must set up rwline, between a T and a \0. */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   647
+int rewrite(char *recip)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   648
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   649
+  int i;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   650
+  int j;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   651
+  char *x;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   652
+  static stralloc addr = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   653
+  int at;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   654
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   655
+  if (!stralloc_copys(&rwline,"T")) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   656
+  if (!stralloc_copys(&addr,recip)) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   657
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   658
+  i = byte_rchr(addr.s,addr.len,'@');
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   659
+  if (i == addr.len) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   660
+    if (!stralloc_cats(&addr,"@")) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   661
+    if (!stralloc_cat(&addr,&envnoathost)) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   662
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   663
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   664
+  while (constmap(&mappercenthack,addr.s + i + 1,addr.len - i - 1)) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   665
+    j = byte_rchr(addr.s,i,'%');
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   666
+    if (j == i) break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   667
+    addr.len = i;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   668
+    i = j;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   669
+    addr.s[i] = '@';
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   670
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   671
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   672
+  at = byte_rchr(addr.s,addr.len,'@');
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   673
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   674
+  if (constmap(&maplocals,addr.s + at + 1,addr.len - at - 1)) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   675
+    if (!stralloc_cat(&rwline,&addr)) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   676
+    if (!stralloc_0(&rwline)) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   677
+    return 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   678
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   679
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   680
+  for (i = 0;i <= addr.len;++i)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   681
+    if (!i || (i == at + 1) || (i == addr.len) || ((i > at) && (addr.s[i] == '.')))
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   682
+      if (x = constmap(&mapvdoms,addr.s + i,addr.len - i)) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   683
+        if (!*x) break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   684
+        if (!stralloc_cats(&rwline,x)) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   685
+        if (!stralloc_cats(&rwline,"-")) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   686
+        if (!stralloc_cat(&rwline,&addr)) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   687
+        if (!stralloc_0(&rwline)) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   688
+        return 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   689
+      }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   690
+ 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   691
+  if (!stralloc_cat(&rwline,&addr)) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   692
+  if (!stralloc_0(&rwline)) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   693
+  return 2;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   694
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   695
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   696
+/* this file is not so long --------------------------------- COMMUNICATION */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   697
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   698
+substdio sstoqc; char sstoqcbuf[1024];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   699
+substdio ssfromqc; char ssfromqcbuf[1024];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   700
+stralloc comm_buf = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   701
+int comm_pos;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   702
+int fdout = -1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   703
+int fdin = -1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   704
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   705
+void comm_init(void)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   706
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   707
+ substdio_fdbuf(&sstoqc,write,2,sstoqcbuf,sizeof(sstoqcbuf));
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   708
+ substdio_fdbuf(&ssfromqc,read,3,ssfromqcbuf,sizeof(ssfromqcbuf));
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   709
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   710
+ fdout = 1; /* stdout */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   711
+ fdin = 0;  /* stdin */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   712
+ if (ndelay_on(fdout) == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   713
+ /* this is so stupid: NDELAY semantics should be default on write */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   714
+   senddied(); /* drastic, but better than risking deadlock */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   715
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   716
+ while (!stralloc_ready(&comm_buf,1024)) nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   717
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   718
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   719
+int comm_canwrite(void)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   720
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   721
+ /* XXX: could allow a bigger buffer; say 10 recipients */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   722
+ /* XXX: returns true if there is something in the buffer */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   723
+ if (!flagsendalive) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   724
+ if (comm_buf.s && comm_buf.len) return 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   725
+ return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   726
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   727
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   728
+void log1(char* x)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   729
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   730
+  int pos;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   731
+  
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   732
+  pos = comm_buf.len;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   733
+  if (!stralloc_cats(&comm_buf,"L")) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   734
+  if (!stralloc_cats(&comm_buf,x)) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   735
+  if (!stralloc_0(&comm_buf)) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   736
+  return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   737
+  
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   738
+fail:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   739
+  /* either all or nothing */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   740
+  comm_buf.len = pos;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   741
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   742
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   743
+void log3(char* x, char *y, char *z)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   744
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   745
+  int pos;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   746
+  
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   747
+  pos = comm_buf.len;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   748
+  if (!stralloc_cats(&comm_buf,"L")) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   749
+  if (!stralloc_cats(&comm_buf,x)) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   750
+  if (!stralloc_cats(&comm_buf,y)) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   751
+  if (!stralloc_cats(&comm_buf,z)) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   752
+  if (!stralloc_0(&comm_buf)) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   753
+  return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   754
+  
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   755
+fail:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   756
+  /* either all or nothing */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   757
+  comm_buf.len = pos;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   758
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   759
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   760
+void comm_write(unsigned long id, int local, int remote)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   761
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   762
+  int pos;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   763
+  char *s;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   764
+  
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   765
+  if(local && remote) s="B";
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   766
+  else if(local) s="L";
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   767
+  else if(remote) s="R";
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   768
+  else s="X";
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   769
+  
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   770
+  pos = comm_buf.len;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   771
+  strnum[fmt_ulong(strnum,id)] = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   772
+  if (!stralloc_cats(&comm_buf,"D")) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   773
+  if (!stralloc_cats(&comm_buf,s)) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   774
+  if (!stralloc_cats(&comm_buf,strnum)) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   775
+  if (!stralloc_0(&comm_buf)) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   776
+  return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   777
+  
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   778
+fail:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   779
+  /* either all or nothing */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   780
+  comm_buf.len = pos;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   781
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   782
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   783
+static int issafe(char ch)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   784
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   785
+ if (ch == '%') return 0; /* general principle: allman's code is crap */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   786
+ if (ch < 33) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   787
+ if (ch > 126) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   788
+ return 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   789
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   790
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   791
+void comm_info(unsigned long id, unsigned long size, char* from, unsigned long pid, unsigned long uid)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   792
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   793
+  int pos;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   794
+  int i;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   795
+  
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   796
+  pos = comm_buf.len;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   797
+  if (!stralloc_cats(&comm_buf,"Linfo msg ")) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   798
+  strnum[fmt_ulong(strnum,id)] = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   799
+  if (!stralloc_cats(&comm_buf,strnum)) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   800
+  if (!stralloc_cats(&comm_buf,": bytes ")) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   801
+  strnum[fmt_ulong(strnum,size)] = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   802
+  if (!stralloc_cats(&comm_buf,strnum)) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   803
+  if (!stralloc_cats(&comm_buf," from <")) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   804
+  i = comm_buf.len;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   805
+  if (!stralloc_cats(&comm_buf,from)) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   806
+  for (;i < comm_buf.len;++i)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   807
+    if (comm_buf.s[i] == '\n')
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   808
+      comm_buf.s[i] = '/';
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   809
+    else
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   810
+      if (!issafe(comm_buf.s[i]))
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   811
+	comm_buf.s[i] = '_';
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   812
+  if (!stralloc_cats(&comm_buf,"> qp ")) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   813
+  strnum[fmt_ulong(strnum,pid)] = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   814
+  if (!stralloc_cats(&comm_buf,strnum)) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   815
+  if (!stralloc_cats(&comm_buf," uid ")) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   816
+  strnum[fmt_ulong(strnum,uid)] = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   817
+  if (!stralloc_cats(&comm_buf,strnum)) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   818
+  if (!stralloc_cats(&comm_buf,"\n")) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   819
+  if (!stralloc_0(&comm_buf)) goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   820
+  return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   821
+  
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   822
+fail:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   823
+  /* either all or nothing */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   824
+  comm_buf.len = pos;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   825
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   826
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   827
+void comm_exit(void)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   828
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   829
+  int w;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   830
+  
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   831
+  /* if it fails exit, we have already stoped */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   832
+  if (!stralloc_cats(&comm_buf,"X")) _exit(1);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   833
+  if (!stralloc_0(&comm_buf)) _exit(1);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   834
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   835
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   836
+void comm_selprep(int *nfds, fd_set *wfds, fd_set *rfds)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   837
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   838
+  if (flagsendalive) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   839
+    if (flagstopasap && comm_canwrite() == 0)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   840
+      comm_exit();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   841
+    if (comm_canwrite()) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   842
+      FD_SET(fdout,wfds);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   843
+      if (*nfds <= fdout)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   844
+	*nfds = fdout + 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   845
+    }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   846
+    FD_SET(fdin,rfds);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   847
+    if (*nfds <= fdin)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   848
+      *nfds = fdin + 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   849
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   850
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   851
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   852
+void comm_do(fd_set *wfds, fd_set *rfds)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   853
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   854
+  /* first write then read */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   855
+  if (flagsendalive)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   856
+    if (comm_canwrite())
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   857
+      if (FD_ISSET(fdout,wfds)) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   858
+	int w;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   859
+	int len;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   860
+	len = comm_buf.len;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   861
+	w = write(fdout,comm_buf.s + comm_pos,len - comm_pos);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   862
+	if (w <= 0) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   863
+	  if ((w == -1) && (errno == error_pipe))
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   864
+	    senddied();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   865
+	} else {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   866
+	  comm_pos += w;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   867
+	  if (comm_pos == len) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   868
+	    comm_buf.len = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   869
+	    comm_pos = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   870
+	  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   871
+	}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   872
+      }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   873
+  if (flagsendalive)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   874
+    if (FD_ISSET(fdin,rfds)) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   875
+      /* there are only two messages 'H' and 'X' */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   876
+      char c;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   877
+      int r;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   878
+      r = read(fdin, &c, 1);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   879
+      if (r <= 0) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   880
+	if ((r == -1) && (errno != error_intr))
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   881
+	  senddied();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   882
+      } else {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   883
+	switch(c) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   884
+	  case 'H':
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   885
+	    sighup();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   886
+	    break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   887
+	  case 'X':
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   888
+	    sigterm();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   889
+	    break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   890
+	  default:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   891
+	    log1("warning: qmail-todo: qmail-send speaks an obscure dialect\n");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   892
+	    break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   893
+	}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   894
+      }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   895
+    }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   896
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   897
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   898
+/* this file is not so long ------------------------------------------ TODO */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   899
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   900
+datetime_sec nexttodorun;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   901
+DIR *tododir; /* if 0, have to opendir again */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   902
+stralloc todoline = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   903
+char todobuf[SUBSTDIO_INSIZE];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   904
+char todobufinfo[512];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   905
+char todobufchan[CHANNELS][1024];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   906
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   907
+void todo_init(void)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   908
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   909
+ tododir = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   910
+ nexttodorun = now();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   911
+ trigger_set();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   912
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   913
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   914
+void todo_selprep(int *nfds, fd_set *rfds, datetime_sec *wakeup)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   915
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   916
+ if (flagstopasap) return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   917
+ trigger_selprep(nfds,rfds);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   918
+ if (tododir) *wakeup = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   919
+ if (*wakeup > nexttodorun) *wakeup = nexttodorun;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   920
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   921
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   922
+void todo_do(fd_set *rfds)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   923
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   924
+ struct stat st;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   925
+ substdio ss; int fd;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   926
+ substdio ssinfo; int fdinfo;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   927
+ substdio sschan[CHANNELS];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   928
+ int fdchan[CHANNELS];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   929
+ int flagchan[CHANNELS];
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   930
+ char ch;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   931
+ int match;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   932
+ unsigned long id;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   933
+ unsigned int len;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   934
+ direntry *d;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   935
+ int c;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   936
+ unsigned long uid;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   937
+ unsigned long pid;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   938
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   939
+ fd = -1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   940
+ fdinfo = -1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   941
+ for (c = 0;c < CHANNELS;++c) fdchan[c] = -1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   942
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   943
+ if (flagstopasap) return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   944
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   945
+ if (!tododir)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   946
+  {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   947
+   if (!trigger_pulled(rfds))
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   948
+     if (recent < nexttodorun)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   949
+       return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   950
+   trigger_set();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   951
+   tododir = opendir("todo");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   952
+   if (!tododir)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   953
+    {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   954
+     pausedir("todo");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   955
+     return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   956
+    }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   957
+   nexttodorun = recent + SLEEP_TODO;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   958
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   959
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   960
+ d = readdir(tododir);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   961
+ if (!d)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   962
+  {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   963
+   closedir(tododir);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   964
+   tododir = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   965
+   return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   966
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   967
+ if (str_equal(d->d_name,".")) return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   968
+ if (str_equal(d->d_name,"..")) return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   969
+ len = scan_ulong(d->d_name,&id);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   970
+ if (!len || d->d_name[len]) return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   971
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   972
+ fnmake_todo(id);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   973
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   974
+ fd = open_read(fn.s);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   975
+ if (fd == -1) { log3("warning: qmail-todo: unable to open ",fn.s,"\n"); return; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   976
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   977
+ fnmake_mess(id);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   978
+ /* just for the statistics */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   979
+ if (stat(fn.s,&st) == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   980
+  { log3("warning: qmail-todo: unable to stat ",fn.s,"\n"); goto fail; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   981
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   982
+ for (c = 0;c < CHANNELS;++c)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   983
+  {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   984
+   fnmake_chanaddr(id,c);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   985
+   if (unlink(fn.s) == -1) if (errno != error_noent)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   986
+    { log3("warning: qmail-todo: unable to unlink ",fn.s,"\n"); goto fail; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   987
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   988
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   989
+ fnmake_info(id);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   990
+ if (unlink(fn.s) == -1) if (errno != error_noent)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   991
+  { log3("warning: qmail-todo: unable to unlink ",fn.s,"\n"); goto fail; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   992
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   993
+ fdinfo = open_excl(fn.s);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   994
+ if (fdinfo == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   995
+  { log3("warning: qmail-todo: unable to create ",fn.s,"\n"); goto fail; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   996
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   997
+ strnum[fmt_ulong(strnum,id)] = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   998
+ log3("new msg ",strnum,"\n");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   999
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1000
+ for (c = 0;c < CHANNELS;++c) flagchan[c] = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1001
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1002
+ substdio_fdbuf(&ss,read,fd,todobuf,sizeof(todobuf));
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1003
+ substdio_fdbuf(&ssinfo,write,fdinfo,todobufinfo,sizeof(todobufinfo));
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1004
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1005
+ uid = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1006
+ pid = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1007
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1008
+ for (;;)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1009
+  {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1010
+   if (getln(&ss,&todoline,&match,'\0') == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1011
+    {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1012
+     /* perhaps we're out of memory, perhaps an I/O error */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1013
+     fnmake_todo(id);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1014
+     log3("warning: qmail-todo: trouble reading ",fn.s,"\n"); goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1015
+    }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1016
+   if (!match) break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1017
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1018
+   switch(todoline.s[0])
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1019
+    {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1020
+     case 'u':
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1021
+       scan_ulong(todoline.s + 1,&uid);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1022
+       break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1023
+     case 'p':
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1024
+       scan_ulong(todoline.s + 1,&pid);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1025
+       break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1026
+     case 'F':
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1027
+       if (substdio_putflush(&ssinfo,todoline.s,todoline.len) == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1028
+	{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1029
+	 fnmake_info(id);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1030
+         log3("warning: qmail-todo: trouble writing to ",fn.s,"\n"); goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1031
+	}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1032
+	comm_info(id, (unsigned long) st.st_size, todoline.s + 1, pid, uid);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1033
+       break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1034
+     case 'T':
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1035
+       switch(rewrite(todoline.s + 1))
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1036
+	{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1037
+	 case 0: nomem(); goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1038
+	 case 2: c = 1; break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1039
+	 default: c = 0; break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1040
+        }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1041
+       if (fdchan[c] == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1042
+	{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1043
+	 fnmake_chanaddr(id,c);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1044
+	 fdchan[c] = open_excl(fn.s);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1045
+	 if (fdchan[c] == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1046
+          { log3("warning: qmail-todo: unable to create ",fn.s,"\n"); goto fail; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1047
+	 substdio_fdbuf(&sschan[c]
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1048
+	   ,write,fdchan[c],todobufchan[c],sizeof(todobufchan[c]));
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1049
+	 flagchan[c] = 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1050
+	}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1051
+       if (substdio_bput(&sschan[c],rwline.s,rwline.len) == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1052
+        {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1053
+	 fnmake_chanaddr(id,c);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1054
+         log3("warning: qmail-todo: trouble writing to ",fn.s,"\n"); goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1055
+        }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1056
+       break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1057
+     default:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1058
+       fnmake_todo(id);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1059
+       log3("warning: qmail-todo: unknown record type in ",fn.s,"\n"); goto fail;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1060
+    }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1061
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1062
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1063
+ close(fd); fd = -1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1064
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1065
+ fnmake_info(id);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1066
+ if (substdio_flush(&ssinfo) == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1067
+  { log3("warning: qmail-todo: trouble writing to ",fn.s,"\n"); goto fail; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1068
+ if (fsync(fdinfo) == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1069
+  { log3("warning: qmail-todo: trouble fsyncing ",fn.s,"\n"); goto fail; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1070
+ close(fdinfo); fdinfo = -1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1071
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1072
+ for (c = 0;c < CHANNELS;++c)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1073
+   if (fdchan[c] != -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1074
+    {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1075
+     fnmake_chanaddr(id,c);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1076
+     if (substdio_flush(&sschan[c]) == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1077
+      { log3("warning: qmail-todo: trouble writing to ",fn.s,"\n"); goto fail; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1078
+     if (fsync(fdchan[c]) == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1079
+      { log3("warning: qmail-todo: trouble fsyncing ",fn.s,"\n"); goto fail; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1080
+     close(fdchan[c]); fdchan[c] = -1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1081
+    }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1082
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1083
+ fnmake_todo(id);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1084
+ if (substdio_putflush(&sstoqc,fn.s,fn.len) == -1) { cleandied(); return; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1085
+ if (substdio_get(&ssfromqc,&ch,1) != 1) { cleandied(); return; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1086
+ if (ch != '+')
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1087
+  {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1088
+   log3("warning: qmail-clean unable to clean up ",fn.s,"\n");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1089
+   return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1090
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1091
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1092
+ comm_write(id, flagchan[0], flagchan[1]);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1093
+ 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1094
+ return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1095
+ 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1096
+ fail:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1097
+ if (fd != -1) close(fd);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1098
+ if (fdinfo != -1) close(fdinfo);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1099
+ for (c = 0;c < CHANNELS;++c)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1100
+   if (fdchan[c] != -1) close(fdchan[c]);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1101
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1102
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1103
+/* this file is too long ---------------------------------------------- MAIN */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1104
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1105
+int getcontrols(void)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1106
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1107
+ if (control_init() == -1) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1108
+ if (control_rldef(&envnoathost,"control/envnoathost",1,"envnoathost") != 1) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1109
+ if (control_readfile(&locals,"control/locals",1) != 1) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1110
+ if (!constmap_init(&maplocals,locals.s,locals.len,0)) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1111
+ switch(control_readfile(&percenthack,"control/percenthack",0))
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1112
+  {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1113
+   case -1: return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1114
+   case 0: if (!constmap_init(&mappercenthack,"",0,0)) return 0; break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1115
+   case 1: if (!constmap_init(&mappercenthack,percenthack.s,percenthack.len,0)) return 0; break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1116
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1117
+ switch(control_readfile(&vdoms,"control/virtualdomains",0))
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1118
+  {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1119
+   case -1: return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1120
+   case 0: if (!constmap_init(&mapvdoms,"",0,1)) return 0; break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1121
+   case 1: if (!constmap_init(&mapvdoms,vdoms.s,vdoms.len,1)) return 0; break;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1122
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1123
+ return 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1124
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1125
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1126
+stralloc newlocals = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1127
+stralloc newvdoms = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1128
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1129
+void regetcontrols(void)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1130
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1131
+ int r;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1132
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1133
+ if (control_readfile(&newlocals,"control/locals",1) != 1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1134
+  { log1("alert: qmail-todo: unable to reread control/locals\n"); return; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1135
+ r = control_readfile(&newvdoms,"control/virtualdomains",0);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1136
+ if (r == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1137
+  { log1("alert: qmail-todo: unable to reread control/virtualdomains\n"); return; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1138
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1139
+ constmap_free(&maplocals);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1140
+ constmap_free(&mapvdoms);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1141
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1142
+ while (!stralloc_copy(&locals,&newlocals)) nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1143
+ while (!constmap_init(&maplocals,locals.s,locals.len,0)) nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1144
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1145
+ if (r)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1146
+  {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1147
+   while (!stralloc_copy(&vdoms,&newvdoms)) nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1148
+   while (!constmap_init(&mapvdoms,vdoms.s,vdoms.len,1)) nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1149
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1150
+ else
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1151
+   while (!constmap_init(&mapvdoms,"",0,1)) nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1152
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1153
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1154
+void reread(void)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1155
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1156
+ if (chdir(auto_qmail) == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1157
+  {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1158
+   log1("alert: qmail-todo: unable to reread controls: unable to switch to home directory\n");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1159
+   return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1160
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1161
+ regetcontrols();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1162
+ while (chdir("queue") == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1163
+  {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1164
+   log1("alert: qmail-todo: unable to switch back to queue directory; HELP! sleeping...\n");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1165
+   sleep(10);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1166
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1167
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1168
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1169
+void main()
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1170
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1171
+ datetime_sec wakeup;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1172
+ fd_set rfds;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1173
+ fd_set wfds;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1174
+ int nfds;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1175
+ struct timeval tv;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1176
+ int r;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1177
+ char c;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1178
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1179
+ if (chdir(auto_qmail) == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1180
+  { log1("alert: qmail-todo: cannot start: unable to switch to home directory\n"); _exit(111); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1181
+ if (!getcontrols())
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1182
+  { log1("alert: qmail-todo: cannot start: unable to read controls\n"); _exit(111); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1183
+ if (chdir("queue") == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1184
+  { log1("alert: qmail-todo: cannot start: unable to switch to queue directory\n"); _exit(111); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1185
+ sig_pipeignore();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1186
+ umask(077);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1187
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1188
+ fnmake_init();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1189
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1190
+ todo_init();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1191
+ comm_init();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1192
+ 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1193
+ do {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1194
+   r = read(fdin, &c, 1);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1195
+   if ((r == -1) && (errno != error_intr))
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1196
+     _exit(100); /* read failed probably qmail-send died */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1197
+ } while (r =! 1); /* we assume it is a 'S' */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1198
+ 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1199
+ for (;;)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1200
+  {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1201
+   recent = now();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1202
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1203
+   if (flagreadasap) { flagreadasap = 0; reread(); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1204
+   if (!flagsendalive) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1205
+     /* qmail-send finaly exited, so do the same. */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1206
+     if (flagstopasap) _exit(0);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1207
+     /* qmail-send died. We can not log and we can not work therefor _exit(1). */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1208
+     _exit(1);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1209
+   }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1210
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1211
+   wakeup = recent + SLEEP_FOREVER;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1212
+   FD_ZERO(&rfds);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1213
+   FD_ZERO(&wfds);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1214
+   nfds = 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1215
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1216
+   todo_selprep(&nfds,&rfds,&wakeup);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1217
+   comm_selprep(&nfds,&wfds,&rfds);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1218
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1219
+   if (wakeup <= recent) tv.tv_sec = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1220
+   else tv.tv_sec = wakeup - recent + SLEEP_FUZZ;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1221
+   tv.tv_usec = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1222
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1223
+   if (select(nfds,&rfds,&wfds,(fd_set *) 0,&tv) == -1)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1224
+     if (errno == error_intr)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1225
+       ;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1226
+     else
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1227
+       log1("warning: qmail-todo: trouble in select\n");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1228
+   else
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1229
+    {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1230
+     recent = now();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1231
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1232
+     todo_do(&rfds);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1233
+     comm_do(&wfds, &rfds);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1234
+    }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1235
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1236
+  /* NOTREACHED */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1237
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
  1238
+