1 /*
2  * libpri: An implementation of Primary Rate ISDN
3  *
4  * Written by Mark Spencer <markster@digium.com>
5  *
6  * Copyright (C) 2005, Digium, Inc.
7  * All Rights Reserved.
8  */
9 
10 /*
11  * See http://www.asterisk.org for more information about
12  * the Asterisk project. Please do not directly contact
13  * any of the maintainers of this project for assistance;
14  * the project provides a web site, mailing lists and IRC
15  * channels for your use.
16  *
17  * This program is free software, distributed under the terms of
18  * the GNU General Public License Version 2 as published by the
19  * Free Software Foundation. See the LICENSE file included with
20  * this program for more details.
21  *
22  * In addition, when this program is distributed with Asterisk in
23  * any form that would qualify as a 'combined work' or as a
24  * 'derivative work' (but not mere aggregation), you can redistribute
25  * and/or modify the combination under the terms of the license
26  * provided with that copy of Asterisk, instead of the license
27  * terms granted here.
28  */
29 
30 #include <string.h>
31 #include <unistd.h>
32 #include <stdlib.h>
33 
34 #include "compiler.h"
35 #include "libpri.h"
36 #include "pri_internal.h"
37 
libpri_copy_string(char * dst,const char * src,size_t size)38 void libpri_copy_string(char *dst, const char *src, size_t size)
39 {
40 	while (*src && size) {
41 		*dst++ = *src++;
42 		size--;
43 	}
44 	if (__builtin_expect(!size, 0))
45 		dst--;
46 	*dst = '\0';
47 }
48