1 /**
2 * Copyright (C) 2008 Happy Fish / YuQing
3 *
4 * FastDFS may be copied only under the terms of the GNU General
5 * Public License V3, which may be found in the FastDFS source kit.
6 * Please visit the FastDFS Home Page http://www.fastken.com/ for more detail.
7 **/
8 
9 //client_func.h
10 
11 #include "tracker_types.h"
12 #include "client_global.h"
13 #include "fastcommon/ini_file_reader.h"
14 
15 #ifndef _CLIENT_FUNC_H_
16 #define _CLIENT_FUNC_H_
17 
18 typedef struct {
19     short file_type;
20     bool get_from_server;
21 	time_t create_timestamp;
22 	int crc32;
23 	int source_id;   //source storage id
24 	int64_t file_size;
25 	char source_ip_addr[IP_ADDRESS_SIZE];  //source storage ip address
26 } FDFSFileInfo;
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #define fdfs_client_init(filename) \
33 	fdfs_client_init_ex((&g_tracker_group), filename)
34 
35 #define fdfs_client_init_from_buffer(buffer) \
36 	fdfs_client_init_from_buffer_ex((&g_tracker_group), buffer)
37 
38 #define fdfs_client_destroy() \
39 	fdfs_client_destroy_ex((&g_tracker_group))
40 
41 /**
42 * client initial from config file
43 * params:
44 *       pTrackerGroup: tracker group
45 *	conf_filename: client config filename
46 * return: 0 success, !=0 fail, return the error code
47 **/
48 int fdfs_client_init_ex(TrackerServerGroup *pTrackerGroup, \
49 		const char *conf_filename);
50 
51 
52 /**
53 * client initial from buffer
54 * params:
55 *       pTrackerGroup: tracker group
56 *	conf_filename: client config filename
57 * return: 0 success, !=0 fail, return the error code
58 **/
59 int fdfs_client_init_from_buffer_ex(TrackerServerGroup *pTrackerGroup, \
60 		const char *buffer);
61 
62 /**
63 * load tracker server group
64 * params:
65 *       pTrackerGroup: tracker group
66 *	conf_filename: tracker server group config filename
67 * return: 0 success, !=0 fail, return the error code
68 **/
69 int fdfs_load_tracker_group(TrackerServerGroup *pTrackerGroup, \
70 		const char *conf_filename);
71 
72 /**
73 * load tracker server group
74 * params:
75 *       pTrackerGroup: tracker group
76 *	conf_filename: config filename
77 *       items: ini file items
78 *       nItemCount: ini file item count
79 * return: 0 success, !=0 fail, return the error code
80 **/
81 int fdfs_load_tracker_group_ex(TrackerServerGroup *pTrackerGroup, \
82 		const char *conf_filename, IniContext *pIniContext);
83 
84 /**
85 * copy tracker server group
86 * params:
87 *       pDestTrackerGroup: the dest tracker group
88 *       pSrcTrackerGroup: the source tracker group
89 * return: 0 success, !=0 fail, return the error code
90 **/
91 int fdfs_copy_tracker_group(TrackerServerGroup *pDestTrackerGroup, \
92 		TrackerServerGroup *pSrcTrackerGroup);
93 
94 /**
95 * client destroy function
96 * params:
97 *       pTrackerGroup: tracker group
98 * return: none
99 **/
100 void fdfs_client_destroy_ex(TrackerServerGroup *pTrackerGroup);
101 
102 /**
103 * tracker group equals
104 * params:
105 *       pGroup1: tracker group 1
106 *       pGroup2: tracker group 2
107 * return: true for equals, otherwise false
108 **/
109 bool fdfs_tracker_group_equals(TrackerServerGroup *pGroup1, \
110         TrackerServerGroup *pGroup2);
111 
112 /**
113 * get file ext name from filename, extension name do not include dot
114 * params:
115 *       filename:  the filename
116 * return: file ext name, NULL for no ext name
117 **/
118 #define fdfs_get_file_ext_name1(filename) \
119 	fdfs_get_file_ext_name_ex(filename, false)
120 
121 /**
122 * get file ext name from filename, extension name maybe include dot
123 * params:
124 *       filename:  the filename
125 * return: file ext name, NULL for no ext name
126 **/
127 #define fdfs_get_file_ext_name2(filename) \
128 	fdfs_get_file_ext_name_ex(filename, true)
129 
130 #define fdfs_get_file_ext_name(filename) \
131 	fdfs_get_file_ext_name_ex(filename, true)
132 
133 /**
134 * get file ext name from filename
135 * params:
136 *       filename:  the filename
137 *       twoExtName: two extension name as the extension name
138 * return: file ext name, NULL for no ext name
139 **/
140 const char *fdfs_get_file_ext_name_ex(const char *filename,
141 	const bool twoExtName);
142 
143 #ifdef __cplusplus
144 }
145 #endif
146 
147 #endif
148