File: gstring.h

package info (click to toggle)
rdiff-backup-fs 1.0.0-8
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 952 kB
  • sloc: sh: 3,800; ansic: 2,944; makefile: 23
file content (58 lines) | stat: -rw-r--r-- 1,420 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef _GSTRING_
#define _GSTRING_

#include "../headers.h"

int gstrcpy(char **, const char *);

int gstrncpy(char **, const char *, int);

int gmstrcpy(char **, const char *, ...);

int gstrsub(const char *, const char *);

int gstrcat(char **, const char *);

int gmstrcat(char **, const char *, ...);

int gstrsort(char **, int);

/*
 * swaps two strings; first will be held under the location of the second and vice vers;
 *
 * @1: pointer to the location of the first string;
 * @2: pointer to the location of the second string;
 * 
 * returns: 0 on success, -1 otherwise;
 */
int gstrswp(char **, char **);

#define gstralloc(length) calloc(length + 1, sizeof(char))

#define gstrdel(string){				\
	    if (string != NULL){			\
			free(string);				\
			string = NULL;				\
	    }								\
	}
    
#define gstrlistdel(list, size) {       \
    int k = 0;                          \
    if (list) {                         \
        for (k = 0; k < size; k++)      \
            if (list[k]) {              \
                free(list[k]);          \
                list[k] = NULL;         \
            }                           \
        free(list);                     \
        list = NULL;                    \
    }                                   \
}
	
#ifdef HAVE_GETLINE
	#define gstrline(line, length, file) getline(line, length, file)
#else
	int gstrline(char **, size_t *, FILE *);
#endif

#endif