1 |
/* |
/* |
2 |
* Copyright (C) 2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2005-2006 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: misc.c,v 1.2 2005/05/07 02:13:29 debug Exp $ |
* $Id: misc.c,v 1.5 2006/02/25 12:55:19 debug Exp $ |
29 |
|
* |
30 |
|
* This file contains things that don't fit anywhere else, and fake/dummy |
31 |
|
* implementations of libc functions that are missing on some systems. |
32 |
*/ |
*/ |
33 |
|
|
34 |
#include <stdio.h> |
#include <stdio.h> |
35 |
#include <stdlib.h> |
#include <stdlib.h> |
36 |
|
#include <string.h> |
37 |
#include <fcntl.h> |
#include <fcntl.h> |
38 |
|
|
39 |
#include "misc.h" |
#include "misc.h" |
127 |
return h; |
return h; |
128 |
} |
} |
129 |
|
|
130 |
|
|
131 |
|
#ifdef USE_STRLCPY_REPLACEMENTS |
132 |
|
/* |
133 |
|
* mystrlcpy(): |
134 |
|
* |
135 |
|
* Quick hack strlcpy() replacement for systems that lack that function. |
136 |
|
* NOTE: No length checking is done. |
137 |
|
*/ |
138 |
|
size_t mystrlcpy(char *dst, const char *src, size_t size) |
139 |
|
{ |
140 |
|
strcpy(dst, src); |
141 |
|
return strlen(src); |
142 |
|
} |
143 |
|
|
144 |
|
|
145 |
|
/* |
146 |
|
* mystrlcat(): |
147 |
|
* |
148 |
|
* Quick hack strlcat() replacement for systems that lack that function. |
149 |
|
* NOTE: No length checking is done. |
150 |
|
*/ |
151 |
|
size_t mystrlcat(char *dst, const char *src, size_t size) |
152 |
|
{ |
153 |
|
size_t orig_dst_len = strlen(dst); |
154 |
|
strcat(dst, src); |
155 |
|
return strlen(src) + orig_dst_len; |
156 |
|
} |
157 |
|
#endif |
158 |
|
|