fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
at master 77 lines 4.0 kB view raw
1/***************************************************************************** 2 * pce * 3 *****************************************************************************/ 4 5/***************************************************************************** 6 * File name: src/lib/string.h * 7 * Created: 2009-06-23 by Hampa Hug <hampa@hampa.ch> * 8 * Copyright: (C) 2009 Hampa Hug <hampa@hampa.ch> * 9 *****************************************************************************/ 10 11/***************************************************************************** 12 * This program is free software. You can redistribute it and / or modify it * 13 * under the terms of the GNU General Public License version 2 as published * 14 * by the Free Software Foundation. * 15 * * 16 * This program is distributed in the hope that it will be useful, but * 17 * WITHOUT ANY WARRANTY, without even the implied warranty of * 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * 19 * Public License for more details. * 20 *****************************************************************************/ 21 22 23#ifndef PCE_LIB_STRING_H 24#define PCE_LIB_STRING_H 1 25 26 27/*!*************************************************************************** 28 * @short Concatenate two strings 29 * @param str1 The first string 30 * @param str2 The second string 31 * @return The concatenation of str1 and str2, allocated with malloc() 32 *****************************************************************************/ 33char *str_cat_alloc (const char *str1, const char *str2); 34 35/*!*************************************************************************** 36 * @short Copy a part of a string 37 * @param str The source string 38 * @param cnt The maximum number of bytes to be copied 39 * @return The new string, allocated with malloc() 40 *****************************************************************************/ 41char *str_cut_alloc (const char *str, unsigned long cnt); 42 43/*!*************************************************************************** 44 * @short Copy a string 45 * @param str The source string 46 * @return The new string, allocated with malloc() 47 *****************************************************************************/ 48char *str_copy_alloc (const char *str); 49 50/*!*************************************************************************** 51 * @short Remove characters from the start and/or end of a string 52 * @param str The source string 53 * @param left Characters to be removed from the start or NULL 54 * @param right Characters to be removed from the right or NULL 55 * @return The new string, allocated with malloc() 56 *****************************************************************************/ 57char *str_trim (char *str, const char *left, const char *right); 58 59/*!*************************************************************************** 60 * @short Remove characters from the start of a string 61 * @param str The source string 62 * @param left Characters to be removed from the start or NULL 63 * @return The new string 64 *****************************************************************************/ 65const char *str_ltrim (const char *str, const char *left); 66 67/*!*************************************************************************** 68 * @short Extract a prefix of a string 69 * @param str The source string 70 * @param sep Characters that end the prefix 71 * @retval rest If not NULL, receives a pointer to the rest of the string 72 * @return The new string, allocated with malloc() 73 *****************************************************************************/ 74char *str_extract_alloc (const char *str, const char *sep, const char **rest); 75 76 77#endif