1 /* -*- c-basic-offset: 8; -*-
3 * Copyright (c) 1993 W. Richard Stevens. All rights reserved.
4 * Permission to use or modify this software and its documentation only for
5 * educational purposes and without fee is hereby granted, provided that
6 * the above copyright notice appear in all copies. The author makes no
7 * representations about the suitability of this software for any purpose.
8 * It is provided "as is" without express or implied warranty.
13 /* Convert newline to return/newline. */
16 crlf_add(char *dst
, int dstsize
, const char *src
, int lenin
)
21 if ( (lenout
= lenin
) > dstsize
)
22 err_quit("crlf_add: destination not big enough");
24 for ( ; lenin
> 0; lenin
--) {
25 if ( (c
= *src
++) == '\n') {
26 if (++lenout
>= dstsize
)
27 err_quit("crlf_add: destination not big enough");
37 crlf_strip(char *dst
, int dstsize
, const char *src
, int lenin
)
42 for (lenout
= 0; lenin
> 0; lenin
--) {
43 if ( (c
= *src
++) != '\r') {
44 if (++lenout
>= dstsize
)
45 err_quit("crlf_strip: destination not big enough");