--- trunk/src/misc.c 2007/10/08 16:18:11 6 +++ trunk/src/misc.c 2007/10/08 16:22:32 42 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005 Anders Gavare. All rights reserved. + * Copyright (C) 2005-2007 Anders Gavare. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -25,13 +25,18 @@ * SUCH DAMAGE. * * - * $Id: misc.c,v 1.2 2005/05/07 02:13:29 debug Exp $ + * $Id: misc.c,v 1.9 2007/06/15 17:02:38 debug Exp $ + * + * This file contains things that don't fit anywhere else, and fake/dummy + * implementations of libc functions that are missing on some systems. */ #include #include +#include #include +#include "cpu.h" #include "misc.h" @@ -123,3 +128,46 @@ return h; } + +#ifdef USE_STRLCPY_REPLACEMENTS +/* + * mystrlcpy(): + * + * Quick hack strlcpy() replacement for systems that lack that function. + * NOTE: No length checking is done. + */ +size_t mystrlcpy(char *dst, const char *src, size_t size) +{ + strcpy(dst, src); + return strlen(src); +} + + +/* + * mystrlcat(): + * + * Quick hack strlcat() replacement for systems that lack that function. + * NOTE: No length checking is done. + */ +size_t mystrlcat(char *dst, const char *src, size_t size) +{ + size_t orig_dst_len = strlen(dst); + strcat(dst, src); + return strlen(src) + orig_dst_len; +} +#endif + + +/* + * print_separator_line(): + * + * Prints a line of "----------". + */ +void print_separator_line(void) +{ + int i = 79; + while (i-- > 0) + debug("-"); + debug("\n"); +} +