tin  2.6.1
About: TIN is a threaded NNTP and spool based UseNet newsreader.
  Fossies Dox: tin-2.6.1.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

joinpath.c
Go to the documentation of this file.
1/*
2 * Project : tin - a Usenet reader
3 * Module : joinpath.c
4 * Author : Thomas Dickey <dickey@invisible-island.net>
5 * Created : 1997-01-10
6 * Updated : 2008-12-04
7 * Notes :
8 *
9 * Copyright (c) 1997-2022 Thomas Dickey <dickey@invisible-island.net>
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * 1. Redistributions of source code must retain the above copyright notice,
17 * this list of conditions and the following disclaimer.
18 *
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 *
23 * 3. Neither the name of the copyright holder nor the names of its
24 * contributors may be used to endorse or promote products derived from
25 * this software without specific prior written permission.
26 *
27 * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40
41#ifndef TIN_H
42# include "tin.h"
43#endif /* !TIN_H */
44
45/*
46 * Concatenate dir+file, ensuring that we don't introduce extra '/', since some
47 * systems (e.g., Apollo) use "//" for special purposes.
48 */
49void
51 char *result,
52 size_t result_size,
53 const char *dir,
54 const char *file)
55{
56 size_t result_len;
57
58 (void) strncpy(result, dir, result_size - 1);
59 result[result_size - 1] = '\0';
60 result_len = strlen(result);
61 if ((result_len < (result_size - 1)) && (result[0] == '\0' || result[strlen(result) - 1] != '/')) {
62 (void) strcat(result, "/");
63 result_len++;
64 }
65 if (result_len < (result_size - 1)) {
66 (void) strncat(result, BlankIfNull(file), result_size - result_len - 1);
67 result[result_size - 1] = '\0';
68 }
69}
void joinpath(char *result, size_t result_size, const char *dir, const char *file)
Definition: joinpath.c:50
#define BlankIfNull(p)
Definition: tin.h:2255