Mercurial > hg > xmms-sid
diff src/xs_support.c @ 359:b1a858b8cb1a
Re-indentation all (non-generated) code.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 07 Nov 2005 09:50:04 +0000 |
parents | dd201740a720 |
children | 933b9ea5923e |
line wrap: on
line diff
--- a/src/xs_support.c Mon Nov 07 09:49:04 2005 +0000 +++ b/src/xs_support.c Mon Nov 07 09:50:04 2005 +0000 @@ -27,168 +27,191 @@ /* Bigendian file reading functions */ -guint16 xs_rd_be16(FILE *f) +guint16 xs_rd_be16(FILE * f) { - return (((guint16) fgetc(f)) << 8) | - ((guint16) fgetc(f)); + return (((guint16) fgetc(f)) << 8) | ((guint16) fgetc(f)); } -guint32 xs_rd_be32(FILE *f) +guint32 xs_rd_be32(FILE * f) { - return (((guint32) fgetc(f)) << 24) | - (((guint32) fgetc(f)) << 16) | - (((guint32) fgetc(f)) << 8) | - ((guint32) fgetc(f)); + return (((guint32) fgetc(f)) << 24) | + (((guint32) fgetc(f)) << 16) | (((guint32) fgetc(f)) << 8) | ((guint32) fgetc(f)); } -size_t xs_rd_str(FILE *f, gchar *s, size_t l) +size_t xs_rd_str(FILE * f, gchar * s, size_t l) { - return fread(s, sizeof(gchar), l, f); + return fread(s, sizeof(gchar), l, f); } /* Copy a string */ -gchar *xs_strncpy(gchar *pDest, gchar *pSource, size_t n) +gchar *xs_strncpy(gchar * pDest, gchar * pSource, size_t n) { - gchar *s, *d; - size_t i; - - /* Check the string pointers */ - if (!pSource || !pDest) return pDest; + gchar *s, *d; + size_t i; + + /* Check the string pointers */ + if (!pSource || !pDest) + return pDest; - /* Copy to the destination */ - i = n; s = pSource; d = pDest; - while (*s && (i > 0)) { *(d++) = *(s++); i--; } + /* Copy to the destination */ + i = n; + s = pSource; + d = pDest; + while (*s && (i > 0)) { + *(d++) = *(s++); + i--; + } - /* Fill rest of space with zeros */ - while (i > 0) { *(d++) = 0; i--; } - - /* Ensure that last is always zero */ - pDest[n - 1] = 0; + /* Fill rest of space with zeros */ + while (i > 0) { + *(d++) = 0; + i--; + } - return pDest; + /* Ensure that last is always zero */ + pDest[n - 1] = 0; + + return pDest; } /* Copy a given string over in *ppResult. */ -gint xs_pstrcpy(gchar **ppResult, const gchar *pStr) +gint xs_pstrcpy(gchar ** ppResult, const gchar * pStr) { - /* Check the string pointers */ - if (!ppResult || !pStr) return -1; + /* Check the string pointers */ + if (!ppResult || !pStr) + return -1; - /* Allocate memory for destination */ - if (*ppResult) g_free(*ppResult); - *ppResult = (gchar *) g_malloc(strlen(pStr) + 1); - if (!*ppResult) return -2; + /* Allocate memory for destination */ + if (*ppResult) + g_free(*ppResult); + *ppResult = (gchar *) g_malloc(strlen(pStr) + 1); + if (!*ppResult) + return -2; - /* Copy to the destination */ - strcpy(*ppResult, pStr); + /* Copy to the destination */ + strcpy(*ppResult, pStr); - return 0; + return 0; } /* Concatenates a given string into string pointed by *ppResult. */ -gint xs_pstrcat(gchar **ppResult, const gchar *pStr) +gint xs_pstrcat(gchar ** ppResult, const gchar * pStr) { - /* Check the string pointers */ - if (!ppResult || !pStr) return -1; + /* Check the string pointers */ + if (!ppResult || !pStr) + return -1; - if (*ppResult != NULL) - { - *ppResult = (gchar *) g_realloc(*ppResult, strlen(*ppResult) + strlen(pStr) + 1); - if (*ppResult == NULL) return -1; - strcat(*ppResult, pStr); - } else - { - *ppResult = (gchar *) g_malloc(strlen(pStr) + 1); - if (*ppResult == NULL) return -1; - strcpy(*ppResult, pStr); + if (*ppResult != NULL) { + *ppResult = (gchar *) g_realloc(*ppResult, strlen(*ppResult) + strlen(pStr) + 1); + if (*ppResult == NULL) + return -1; + strcat(*ppResult, pStr); + } else { + *ppResult = (gchar *) g_malloc(strlen(pStr) + 1); + if (*ppResult == NULL) + return -1; + strcpy(*ppResult, pStr); } - return 0; + return 0; } /* Concatenate a given string up to given dest size or \n. * If size max is reached, change the end to "..." */ -void xs_pnstrcat(gchar *pDest, size_t iSize, gchar *pStr) +void xs_pnstrcat(gchar * pDest, size_t iSize, gchar * pStr) { - size_t i, n; - gchar *s, *d; - - d = pDest; i = 0; - while (*d && (i < iSize)) { i++; d++; } - - s = pStr; - while (*s && (*s != '\n') && (i < iSize)) - { - *d = *s; - d++; s++; i++; - } + size_t i, n; + gchar *s, *d; + + d = pDest; + i = 0; + while (*d && (i < iSize)) { + i++; + d++; + } - *d = 0; + s = pStr; + while (*s && (*s != '\n') && (i < iSize)) { + *d = *s; + d++; + s++; + i++; + } + + *d = 0; - if (i >= iSize) - { - i--; d--; n = 3; - while ((i > 0) && (n > 0)) - { - *d = '.'; - d--; i--; n--; + if (i >= iSize) { + i--; + d--; + n = 3; + while ((i > 0) && (n > 0)) { + *d = '.'; + d--; + i--; + n--; } - } + } } /* Locate character in string */ -gchar *xs_strrchr(gchar *pcStr, gchar ch) +gchar *xs_strrchr(gchar * pcStr, gchar ch) { - gchar *lastPos = NULL; + gchar *lastPos = NULL; - while (*pcStr) - { - if (*pcStr == ch) lastPos = pcStr; - pcStr++; - } + while (*pcStr) { + if (*pcStr == ch) + lastPos = pcStr; + pcStr++; + } - return lastPos; + return lastPos; } -void xs_findnext(gchar *pcStr, guint *piPos) +void xs_findnext(gchar * pcStr, guint * piPos) { - while (pcStr[*piPos] && isspace(pcStr[*piPos])) (*piPos)++; + while (pcStr[*piPos] && isspace(pcStr[*piPos])) + (*piPos)++; } -void xs_findeol(gchar *pcStr, guint *piPos) +void xs_findeol(gchar * pcStr, guint * piPos) { - while (pcStr[*piPos] && (pcStr[*piPos] != '\n') && (pcStr[*piPos] != '\r')) (*piPos)++; + while (pcStr[*piPos] && (pcStr[*piPos] != '\n') && (pcStr[*piPos] != '\r')) + (*piPos)++; } -void xs_findnum(gchar *pcStr, guint *piPos) +void xs_findnum(gchar * pcStr, guint * piPos) { - while (pcStr[*piPos] && isdigit(pcStr[*piPos])) (*piPos)++; + while (pcStr[*piPos] && isdigit(pcStr[*piPos])) + (*piPos)++; } #ifndef HAVE_MEMSET void *xs_memset(void *p, int c, size_t n) { - gchar *dp; - - dp = (gchar *) p; - while (n--) { *dp = (gchar) c; n--; } + gchar *dp; - return p; + dp = (gchar *) p; + while (n--) { + *dp = (gchar) c; + n--; + } + + return p; } #endif