pacemaker  1.1.16-94ff4df
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
internal.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015
3  * Andrew Beekhof <andrew@beekhof.net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
27 #ifndef CRM_COMMON_INTERNAL__H
28 #define CRM_COMMON_INTERNAL__H
29 
30 #include <glib.h> /* for gboolean */
31 #include <dirent.h> /* for struct dirent */
32 #include <sys/types.h> /* for uid_t and gid_t */
33 
34 /* internal I/O utilities (from io.c) */
35 
36 char *generate_series_filename(const char *directory, const char *series, int sequence,
37  gboolean bzip);
38 int get_last_sequence(const char *directory, const char *series);
39 void write_last_sequence(const char *directory, const char *series, int sequence, int max);
40 int crm_chown_last_sequence(const char *directory, const char *series, uid_t uid, gid_t gid);
41 
42 gboolean crm_is_writable(const char *dir, const char *file, const char *user, const char *group,
43  gboolean need_both);
44 
45 void crm_sync_directory(const char *name);
46 
47 char *crm_read_contents(const char *filename);
48 int crm_write_sync(int fd, const char *contents);
49 
50 
51 /* internal procfs utilities (from procfs.c) */
52 
53 int crm_procfs_process_info(struct dirent *entry, char *name, int *pid);
54 int crm_procfs_pid_of(const char *name);
55 
56 
57 /* internal XML schema functions (from xml.c) */
58 
59 void crm_schema_init(void);
60 void crm_schema_cleanup(void);
61 
62 
63 /* internal generic string functions (from strings.c) */
64 
65 char *crm_concat(const char *prefix, const char *suffix, char join);
66 void g_hash_destroy_str(gpointer data);
67 long long crm_int_helper(const char *text, char **end_text);
68 gboolean crm_ends_with(const char *s, const char *match);
69 char *add_list_element(char *list, const char *value);
70 bool crm_compress_string(const char *data, int length, int max, char **result,
71  unsigned int *result_len);
72 
73 static inline int
74 crm_strlen_zero(const char *s)
75 {
76  return !s || *s == '\0';
77 }
78 
79 #endif /* CRM_COMMON_INTERNAL__H */
void crm_schema_init(void)
Definition: schemas.c:241
int get_last_sequence(const char *directory, const char *series)
Definition: io.c:121
long long crm_int_helper(const char *text, char **end_text)
Definition: strings.c:80
void crm_schema_cleanup(void)
Definition: schemas.c:462
uint32_t pid
Definition: internal.h:49
char * generate_series_filename(const char *directory, const char *series, int sequence, gboolean bzip)
Definition: io.c:85
char * crm_read_contents(const char *filename)
Definition: io.c:394
char * add_list_element(char *list, const char *value)
Definition: strings.c:292
gboolean crm_ends_with(const char *s, const char *match)
Definition: strings.c:242
int crm_procfs_process_info(struct dirent *entry, char *name, int *pid)
Definition: procfs.c:46
gboolean crm_is_writable(const char *dir, const char *file, const char *user, const char *group, gboolean need_both)
Definition: io.c:278
void write_last_sequence(const char *directory, const char *series, int sequence, int max)
Definition: io.c:193
bool crm_compress_string(const char *data, int length, int max, char **result, unsigned int *result_len)
Definition: strings.c:311
int crm_write_sync(int fd, const char *contents)
Definition: io.c:440
char data[0]
Definition: internal.h:58
int crm_chown_last_sequence(const char *directory, const char *series, uid_t uid, gid_t gid)
Definition: io.c:250
void crm_sync_directory(const char *name)
Definition: io.c:357
char * crm_concat(const char *prefix, const char *suffix, char join)
Definition: strings.c:32
int crm_procfs_pid_of(const char *name)
Definition: procfs.c:117
void g_hash_destroy_str(gpointer data)
Definition: strings.c:74