annotate src/osdep/wce/nl_wce.c @ 0:ada5e610ab86

imap-2007e
author yuuji@gentei.org
date Mon, 14 Sep 2009 15:17:45 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
1 /* ========================================================================
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
2 * Copyright 1988-2006 University of Washington
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
3 *
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
4 * Licensed under the Apache License, Version 2.0 (the "License");
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
5 * you may not use this file except in compliance with the License.
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
6 * You may obtain a copy of the License at
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
7 *
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
8 * http://www.apache.org/licenses/LICENSE-2.0
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
9 *
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
10 *
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
11 * ========================================================================
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
12 */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
13
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
14 /*
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
15 * Program: Windows/TOPS-20 newline routines
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
16 *
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
17 * Author: Mark Crispin
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
18 * Networks and Distributed Computing
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
19 * Computing & Communications
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
20 * University of Washington
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
21 * Administration Building, AG-44
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
22 * Seattle, WA 98195
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
23 * Internet: MRC@CAC.Washington.EDU
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
24 *
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
25 * Date: 1 August 1988
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
26 * Last Edited: 30 August 2006
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
27 */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
28
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
29 /* Copy string with CRLF newlines
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
30 * Accepts: destination string
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
31 * pointer to size of destination string buffer
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
32 * source string
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
33 * length of source string
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
34 * Returns: length of copied string
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
35 */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
36
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
37 unsigned long strcrlfcpy (unsigned char **dst,unsigned long *dstl,
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
38 unsigned char *src,unsigned long srcl)
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
39 {
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
40 /* flush destination buffer if too small */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
41 if (*dst && (srcl > *dstl)) fs_give ((void **) dst);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
42 if (!*dst) { /* make a new buffer if needed */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
43 *dst = (char *) fs_get ((size_t) (*dstl = srcl) + 1);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
44 if (dstl) *dstl = srcl; /* return new buffer length to main program */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
45 }
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
46 /* copy strings */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
47 if (srcl) memcpy (*dst,src,(size_t) srcl);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
48 *(*dst + srcl) = '\0'; /* tie off destination */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
49 return srcl; /* return length */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
50 }
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
51
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
52
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
53 /* Length of string after strcrlfcpy applied
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
54 * Accepts: source string
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
55 * Returns: length of string
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
56 */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
57
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
58 unsigned long strcrlflen (STRING *s)
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
59 {
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
60 return SIZE (s); /* no-brainer on DOS! */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
61 }

yatex.org