Mercurial > hg > xmms-sid
view src/xs_support.c @ 4:4bb09e405eab
Added new files for 0.8
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 03 Jun 2003 11:03:04 +0000 |
parents | |
children | dec37e16136e |
line wrap: on
line source
/* XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS) Miscellaneous support functions Written by Matti "ccr" Hamalainen <ccr@tnsp.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "xmms-sid.h" #include <stdlib.h> #include <string.h> #include <ctype.h> /* * Utility routines */ int xs_strcalloc(gchar **result, const gchar *str) { /* Check the string pointers */ if ((result == NULL) || (str == NULL)) return -1; /* Allocate memory for destination */ *result = (gchar *) g_realloc(*result, strlen(str) + 1); if (*result == NULL) return -2; /* Copy to the destination */ strcpy(*result, str); return 0; } int xs_strcat(gchar **ppcResult, const gchar *pcStr) { int ilen; /* Check the pcString pointers */ if ((ppcResult == NULL) || (pcStr == NULL)) return -1; /* Get length of the pcString to be catted */ ilen = strlen(pcStr); /* Re-allocate memory for destination */ *ppcResult = (gchar *) g_realloc(*ppcResult, strlen(*ppcResult) + ilen + 1); if (*ppcResult == NULL) return -2; /* Cat to the destination */ strcat(*ppcResult, pcStr); return 0; } int xs_strcpy(gchar **ppcResult, gint *j, const gchar *pcStr) { int ilen; /* Check the pcString pointers */ if ((ppcResult == NULL) || (pcStr == NULL) || (j == NULL)) return -1; /* Get length of the pcString to be catted */ (*j) += ilen = strlen(pcStr); /* Re-allocate memory for destination */ *ppcResult = (gchar *) g_realloc(*ppcResult, strlen(*ppcResult) + ilen + 1); if (*ppcResult == NULL) return -2; /* Cat to the destination */ strcat(*ppcResult, pcStr); return 0; } inline void xs_findnext(gchar *pcStr, gint *piPos) { /* Terminating NULL-character is not whitespace! */ while (isspace(pcStr[*piPos])) (*piPos)++; } inline void xs_findnum(gchar *pcStr, gint *piPos) { /* Terminating NULL-character is not digit! */ while (isdigit(pcStr[*piPos])) (*piPos)++; }