-
Notifications
You must be signed in to change notification settings - Fork 0
/
utilities.h
78 lines (60 loc) · 2.25 KB
/
utilities.h
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* WINHOMEFS This is a filesystem use for mouting
* and sharing a windows home directory with a linux
* instance without creating the big mess.
*
* This file system is written by John-Charles D. Sokolow
* Copyright (C) 2011-1012 John-Charles D. Sokolow <john.charles.sokolow@gmail.com>
*
* Based heavily on the example fuse file system "fusexmp_fh.c"
* Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
*
*
* License: 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; Version 2 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.
*/
#include <stdio.h>
#include <stdlib.h>
#ifndef UTILITIES_H
#define UTILITIES_H
typedef struct {
int length;
char ** data;
int sorted;
} list_t;
int startswith( const char * string, const char * term );
int endswith( const char * string, const char * term );
char * substring( const char * string, int start, int end );
list_t * list_t_new( );
list_t * list_t_new_from_file( char * path );
list_t * list_t_new_listdir( const char * path );
void list_t_append( list_t * list, char * string );
void list_t_append_unique( list_t * list, char * string );
void list_t_extend( list_t * list, list_t * second );
void list_t_extend_unique( list_t * list, list_t * second );
int list_t_contains( list_t * list, char * string );
void list_t_print( list_t * list );
void list_t_printf( FILE * file, list_t * list );
void list_t_sort( list_t * list );
void list_t_free( list_t * list );
char * add( const char * str1, const char * str2 );
char * cat( char * str1, const char * str2, int do_free );
char * join( list_t * path, char * delim );
/** In prep for implementing a dictionary, this is for
* eventual use with attribute, and resolution caching.
* */
typedef struct {
char * key;
char * val;
int age;
} cache_dict_t_node;
typedef struct {
cache_dict_t_node * list;
int length;
} cache_dict_t;
FILE * log_f( const char * title, const char * message );
#endif