Mercurial > emacs
annotate lib-src/cvtmail.c @ 69860:000a5d4aa083
(rcirc-default-server): Rename from rcirc-server.
(rcirc-default-port): Rename from rcirc-port.
(rcirc-default-nick): Rename from rcirc-nick.
(rcirc-default-user-name): Rename from rcirc-user-name.
(rcirc-default-user-full-name): Rename from rcirc-user-full-name.
(rcirc-low-priority-flag): New variable.
(rcirc-decode-coding-system): New defcustom.
(rcirc-encode-coding-system): New defcustom.
(rcirc-coding-system-alist): New defcustom.
(rcirc-multiline-major-mode): New defcustom.
(rcirc-nick): New internal variable.
(rcirc-process): Remove variable.
(rcirc-server-buffer): New variable.
(rcirc): Update to use rcirc-default-* variables above.
(rcirc-connect): Do not add window-configuration-hook-here.
(rcirc-server): New internal variable.
(rcirc-connect): Do not send keepalive pings if rcirc-keepalive-seconds is nil.
(with-rcirc-server-buffer): New macro.
(rcirc-send-string): Encode with rcirc-encode-coding-system.
(rcirc-server-name): Rename from rcirc-server.
(rcirc-buffer-process): New function.
(rcirc-buffer-nick): New function.
(rcirc-buffer-target): Remove function.
(set-rcirc-decode-coding-system, set-rcirc-encode-coding-system): New commands.
(rcirc-mode-map): Change binding of C-c C-l to rcirc-toggle-low-priority.
(rcirc-mode): Initialize coding system based on rcirc-coding-system-alist.
New change-major-mode-hook to part the channel on a mode change.
Make kill-buffer-hook buffer-local.
(rcirc-change-major-mode-hook): New function.
(rcirc-clean-up-buffer): Rename from rcirc-kill-buffer-hook-1.
(rcirc-last-post-time): New variable.
(rcirc-process-message): Store the last time user posted a message to this
target.
(rcirc-multiline-minor-mode): New mode.
(rcirc-multiline-minor-mode-map): New mode map.
(rcirc-edit-multiline): Put multiline-edit buffer in
rcirc-multiline-major-mode along with rcirc-multiline-minor-mode.
(rcirc-print): Any line starting with an ignored nick will be ignored.
(rcirc-print): Decode using rcirc-decode-coding-system.
(rcirc-track-minor-mode): Update global-mode-string when disabling this mode.
(minor-mode-alist): add LowPri indicator.
(rcirc-toggle-low-priority): New function.
(rcirc-last-non-irc-buffer): Prefix arg now no means switch to next low priority
buffer with activity.
(rcirc-record-activity): Sort buffers in rcirc-activity by the last time the
user posted a message in to the target.
(rcirc-update-activity-string): New formatting for low priority buffers.
(rcirc-split-activity): New function.
(rcirc-handler-PART, rcirc-handler-KICK)
(rcirc-handler-PART-or-KICK): Kick responses are printed properly.
(rcirc-nick-away-alist): New variable.
(rcirc-handler-301): New handler. Away messages are printed once per change.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 08 Apr 2006 10:23:24 +0000 |
parents | 3661e9b3c48f |
children | 6d19c76d81c5 c5406394f567 |
rev | line source |
---|---|
64769
6358e3c6075c
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64083
diff
changeset
|
1 /* Copyright (C) 1985, 1994, 2002, 2003, 2004, |
68647
3661e9b3c48f
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64769
diff
changeset
|
2 2005, 2006 Free Software Foundation, Inc. |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
11425
diff
changeset
|
3 |
37 | 4 This file is part of GNU Emacs. |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
6107
8cc2a5d2e728
* cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents:
37
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
37 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
64083 | 18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 Boston, MA 02110-1301, USA. */ | |
37 | 20 |
21 /* cvtmail: | |
22 * Program to convert oldstyle goslings emacs mail directories into | |
23 * gnu-rmail format. Program expects a directory called Messages to | |
24 * exist in your home directory, containing individual mail messages in | |
25 * separate files in the standard gosling emacs mail reader format. | |
26 * | |
11425
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
27 * Program takes one argument: an output file. This file will contain |
37 | 28 * all the messages in Messages directory, in berkeley mail format. |
29 * If no output file is mentioned, messages are put in ~/OMAIL. | |
30 * | |
31 * In order to get rmail to read the messages, the resulting file must | |
32 * be mv'ed to ~/mbox, and then have rmail invoked on them. | |
42412 | 33 * |
37 | 34 * Author: Larry Kolodney, 1985 |
35 */ | |
36 | |
42412 | 37 #ifdef HAVE_CONFIG_H |
38 #include <config.h> | |
39 #endif | |
40 | |
37 | 41 #include <stdio.h> |
42 | |
42132 | 43 #ifndef HAVE_STDLIB_H |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
44 char *getenv (); |
42132 | 45 #endif |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
46 |
42132 | 47 char *xmalloc __P ((unsigned)); |
48 char *xrealloc __P ((char *, unsigned)); | |
49 void skip_to_lf __P ((FILE *)); | |
50 void sysfail __P ((char *)); | |
37 | 51 |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
52 int |
37 | 53 main (argc, argv) |
54 int argc; | |
55 char *argv[]; | |
56 { | |
57 char *hd; | |
58 char *md; | |
59 char *mdd; | |
60 char *mfile; | |
61 char *cf; | |
62 int cflen; | |
63 FILE *mddf; | |
64 FILE *mfilef; | |
65 FILE *cff; | |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
66 char pre[10]; |
37 | 67 char name[14]; |
68 int c; | |
69 | |
70 hd = (char *) getenv ("HOME"); | |
71 | |
72 md = (char *) xmalloc (strlen (hd) + 10); | |
73 strcpy (md, hd); | |
74 strcat (md, "/Messages"); | |
75 | |
76 mdd = (char *) xmalloc (strlen (md) + 11); | |
77 strcpy (mdd, md); | |
78 strcat (mdd, "/Directory"); | |
79 | |
80 cflen = 100; | |
81 cf = (char *) xmalloc (cflen); | |
82 | |
83 mddf = fopen (mdd, "r"); | |
11425
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
84 if (!mddf) |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
85 sysfail (mdd); |
37 | 86 if (argc > 1) |
11425
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
87 mfile = argv[1]; |
37 | 88 else |
89 { | |
90 mfile = (char *) xmalloc (strlen (hd) + 7); | |
91 strcpy (mfile, hd); | |
92 strcat (mfile, "/OMAIL"); | |
93 } | |
11425
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
94 mfilef = fopen (mfile, "w"); |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
95 if (!mfilef) |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
96 sysfail (mfile); |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
97 |
37 | 98 skip_to_lf (mddf); |
99 while (fscanf (mddf, "%4c%14[0123456789]", pre, name) != EOF) | |
100 { | |
101 if (cflen < strlen (md) + strlen (name) + 2) | |
102 { | |
103 cflen = strlen (md) + strlen (name) + 2; | |
104 cf = (char *) xrealloc (cf, cflen); | |
105 } | |
106 strcpy (cf, md); | |
107 strcat (cf,"/"); | |
108 strcat (cf, name); | |
109 cff = fopen (cf, "r"); | |
11425
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
110 if (!cff) |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
111 perror (cf); |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
112 else |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
113 { |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
114 while ((c = getc(cff)) != EOF) |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
115 putc (c, mfilef); |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
116 putc ('\n', mfilef); |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
117 skip_to_lf (mddf); |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
118 fclose (cff); |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
119 } |
37 | 120 } |
121 fclose (mddf); | |
42412 | 122 fclose (mfilef); |
55442
a47704955f8d
Throughout, replace 0 destined for `exit' arg with `EXIT_SUCCESS'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
123 return EXIT_SUCCESS; |
37 | 124 } |
125 | |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
126 void |
37 | 127 skip_to_lf (stream) |
128 FILE *stream; | |
129 { | |
130 register int c; | |
11425
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
131 while ((c = getc(stream)) != EOF && c != '\n') |
37 | 132 ; |
133 } | |
134 | |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
135 |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
136 void |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
137 error (s1, s2) |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
138 char *s1, *s2; |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
139 { |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
140 fprintf (stderr, "cvtmail: "); |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
141 fprintf (stderr, s1, s2); |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
142 fprintf (stderr, "\n"); |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
143 } |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
144 |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
145 /* Print error message and exit. */ |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
146 |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
147 void |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
148 fatal (s1, s2) |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
149 char *s1, *s2; |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
150 { |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
151 error (s1, s2); |
55442
a47704955f8d
Throughout, replace 0 destined for `exit' arg with `EXIT_SUCCESS'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
152 exit (EXIT_FAILURE); |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
153 } |
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
154 |
11425
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
155 void |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
156 sysfail (s) |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
157 char *s; |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
158 { |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
159 fprintf (stderr, "cvtmail: "); |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
160 perror (s); |
55442
a47704955f8d
Throughout, replace 0 destined for `exit' arg with `EXIT_SUCCESS'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
161 exit (EXIT_FAILURE); |
11425
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
162 } |
bcb88697b70b
(main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents:
9491
diff
changeset
|
163 |
6107
8cc2a5d2e728
* cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents:
37
diff
changeset
|
164 char * |
37 | 165 xmalloc (size) |
6107
8cc2a5d2e728
* cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents:
37
diff
changeset
|
166 unsigned size; |
37 | 167 { |
49803
c6c565402859
Cast result of malloc and realloc.
Richard M. Stallman <rms@gnu.org>
parents:
42412
diff
changeset
|
168 char *result = (char *) malloc (size); |
37 | 169 if (!result) |
170 fatal ("virtual memory exhausted", 0); | |
171 return result; | |
172 } | |
173 | |
6107
8cc2a5d2e728
* cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents:
37
diff
changeset
|
174 char * |
37 | 175 xrealloc (ptr, size) |
176 char *ptr; | |
6107
8cc2a5d2e728
* cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents:
37
diff
changeset
|
177 unsigned size; |
37 | 178 { |
49803
c6c565402859
Cast result of malloc and realloc.
Richard M. Stallman <rms@gnu.org>
parents:
42412
diff
changeset
|
179 char *result = (char *) realloc (ptr, size); |
37 | 180 if (!result) |
40684
e3eadbc9fda7
(xrealloc): Always pass two args to `fatal'.
Richard M. Stallman <rms@gnu.org>
parents:
15719
diff
changeset
|
181 fatal ("virtual memory exhausted", 0); |
37 | 182 return result; |
183 } | |
52401 | 184 |
185 /* arch-tag: b93c25a9-9012-44f1-b78b-9cc7aed44a7a | |
186 (do not change this comment) */ | |
55442
a47704955f8d
Throughout, replace 0 destined for `exit' arg with `EXIT_SUCCESS'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
187 |
a47704955f8d
Throughout, replace 0 destined for `exit' arg with `EXIT_SUCCESS'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
188 /* cvtmail.c ends here */ |