mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
added strocpy()
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3238 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
0e133595d1
commit
b886e97d5e
@ -778,6 +778,20 @@ char *escape_string(const char *str)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int strocpy(char *dest, const char *src, size_t dstsize)
|
||||||
|
{
|
||||||
|
if (dstsize == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
while (*src != '\0' && dstsize > 1) {
|
||||||
|
*dest++ = *src++;
|
||||||
|
dstsize--;
|
||||||
|
}
|
||||||
|
|
||||||
|
*dest++ = '\0';
|
||||||
|
return *src == '\0' ? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
int nearest_power(int num)
|
int nearest_power(int num)
|
||||||
{
|
{
|
||||||
int n = 1;
|
int n = 1;
|
||||||
|
@ -101,6 +101,9 @@ int expand_escape(const char **data);
|
|||||||
/* Escape all '"', "'" and '\' chars with '\' */
|
/* Escape all '"', "'" and '\' chars with '\' */
|
||||||
char *escape_string(const char *str);
|
char *escape_string(const char *str);
|
||||||
|
|
||||||
|
/* Like strlcpy(), but return -1 if buffer was overflown, 0 if not. */
|
||||||
|
int strocpy(char *dest, const char *src, size_t dstsize);
|
||||||
|
|
||||||
int nearest_power(int num);
|
int nearest_power(int num);
|
||||||
|
|
||||||
/* Returns TRUE / FALSE */
|
/* Returns TRUE / FALSE */
|
||||||
|
Loading…
Reference in New Issue
Block a user