mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-01 14:55:10 +00:00
parser - Fix const char warnings
This patch addresses a bunch of the compiler string conversion warnings that were introduced with the C++-ification patch. Signed-off-by: Steve Beattie <steve@nxnw.org> Acked-by: Tyler Hicks <tyhicks@canonical.com>
This commit is contained in:
@@ -62,7 +62,7 @@ void aare_delete_ruleset(aare_ruleset_t *rules)
|
|||||||
aare_reset_matchflags();
|
aare_reset_matchflags();
|
||||||
}
|
}
|
||||||
|
|
||||||
int aare_add_rule(aare_ruleset_t *rules, char *rule, int deny,
|
int aare_add_rule(aare_ruleset_t *rules, const char *rule, int deny,
|
||||||
uint32_t perms, uint32_t audit, dfaflags_t flags)
|
uint32_t perms, uint32_t audit, dfaflags_t flags)
|
||||||
{
|
{
|
||||||
return aare_add_rule_vec(rules, deny, perms, audit, 1, &rule, flags);
|
return aare_add_rule_vec(rules, deny, perms, audit, 1, &rule, flags);
|
||||||
@@ -96,7 +96,7 @@ void aare_reset_matchflags(void)
|
|||||||
|
|
||||||
int aare_add_rule_vec(aare_ruleset_t *rules, int deny,
|
int aare_add_rule_vec(aare_ruleset_t *rules, int deny,
|
||||||
uint32_t perms, uint32_t audit,
|
uint32_t perms, uint32_t audit,
|
||||||
int count, char **rulev, dfaflags_t flags)
|
int count, const char **rulev, dfaflags_t flags)
|
||||||
{
|
{
|
||||||
Node *tree = NULL, *accept;
|
Node *tree = NULL, *accept;
|
||||||
int exact_match;
|
int exact_match;
|
||||||
|
@@ -35,10 +35,10 @@ typedef struct aare_ruleset aare_ruleset_t;
|
|||||||
|
|
||||||
aare_ruleset_t *aare_new_ruleset(int reverse);
|
aare_ruleset_t *aare_new_ruleset(int reverse);
|
||||||
void aare_delete_ruleset(aare_ruleset_t *rules);
|
void aare_delete_ruleset(aare_ruleset_t *rules);
|
||||||
int aare_add_rule(aare_ruleset_t *rules, char *rule, int deny, uint32_t perms,
|
int aare_add_rule(aare_ruleset_t *rules, const char *rule, int deny, uint32_t perms,
|
||||||
uint32_t audit, dfaflags_t flags);
|
uint32_t audit, dfaflags_t flags);
|
||||||
int aare_add_rule_vec(aare_ruleset_t *rules, int deny, uint32_t perms,
|
int aare_add_rule_vec(aare_ruleset_t *rules, int deny, uint32_t perms,
|
||||||
uint32_t audit, int count, char **rulev,
|
uint32_t audit, int count, const char **rulev,
|
||||||
dfaflags_t flags);
|
dfaflags_t flags);
|
||||||
void *aare_create_dfa(aare_ruleset_t *rules, size_t *size, dfaflags_t flags);
|
void *aare_create_dfa(aare_ruleset_t *rules, size_t *size, dfaflags_t flags);
|
||||||
void aare_reset_matchflags(void);
|
void aare_reset_matchflags(void);
|
||||||
|
@@ -230,14 +230,14 @@ extern int names_only;
|
|||||||
extern int option;
|
extern int option;
|
||||||
extern int current_lineno;
|
extern int current_lineno;
|
||||||
extern dfaflags_t dfaflags;
|
extern dfaflags_t dfaflags;
|
||||||
extern char *progname;
|
extern const char *progname;
|
||||||
extern char *subdomainbase;
|
extern char *subdomainbase;
|
||||||
extern char *profilename;
|
extern char *profilename;
|
||||||
extern char *profile_ns;
|
extern char *profile_ns;
|
||||||
extern char *current_filename;
|
extern char *current_filename;
|
||||||
extern FILE *ofile;
|
extern FILE *ofile;
|
||||||
extern int read_implies_exec;
|
extern int read_implies_exec;
|
||||||
extern void pwarn(char *fmt, ...) __attribute__((__format__(__printf__, 1, 2)));
|
extern void pwarn(const char *fmt, ...) __attribute__((__format__(__printf__, 1, 2)));
|
||||||
|
|
||||||
/* from parser_main (cannot be used in tst builds) */
|
/* from parser_main (cannot be used in tst builds) */
|
||||||
extern int force_complain;
|
extern int force_complain;
|
||||||
@@ -252,7 +252,7 @@ extern void yyerror(const char *msg, ...);
|
|||||||
extern int yylex(void);
|
extern int yylex(void);
|
||||||
|
|
||||||
/* parser_include.c */
|
/* parser_include.c */
|
||||||
extern char *basedir;
|
extern const char *basedir;
|
||||||
|
|
||||||
/* parser_regex.c */
|
/* parser_regex.c */
|
||||||
extern int process_regex(Profile *prof);
|
extern int process_regex(Profile *prof);
|
||||||
@@ -267,7 +267,7 @@ extern int process_policy_ents(Profile *prof);
|
|||||||
|
|
||||||
/* parser_variable.c */
|
/* parser_variable.c */
|
||||||
extern int process_variables(Profile *prof);
|
extern int process_variables(Profile *prof);
|
||||||
extern struct var_string *split_out_var(char *string);
|
extern struct var_string *split_out_var(const char *string);
|
||||||
extern void free_var_string(struct var_string *var);
|
extern void free_var_string(struct var_string *var);
|
||||||
|
|
||||||
/* parser_misc.c */
|
/* parser_misc.c */
|
||||||
@@ -279,9 +279,9 @@ extern struct cond_entry *new_cond_entry(char *name, int eq, struct value_list *
|
|||||||
extern void free_cond_entry(struct cond_entry *ent);
|
extern void free_cond_entry(struct cond_entry *ent);
|
||||||
extern void free_cond_list(struct cond_entry *ents);
|
extern void free_cond_list(struct cond_entry *ents);
|
||||||
extern void print_cond_entry(struct cond_entry *ent);
|
extern void print_cond_entry(struct cond_entry *ent);
|
||||||
extern char *processid(char *string, int len);
|
extern char *processid(const char *string, int len);
|
||||||
extern char *processquoted(char *string, int len);
|
extern char *processquoted(const char *string, int len);
|
||||||
extern char *processunquoted(char *string, int len);
|
extern char *processunquoted(const char *string, int len);
|
||||||
extern int get_keyword_token(const char *keyword);
|
extern int get_keyword_token(const char *keyword);
|
||||||
extern int name_to_capability(const char *keyword);
|
extern int name_to_capability(const char *keyword);
|
||||||
extern int get_rlimit(const char *name);
|
extern int get_rlimit(const char *name);
|
||||||
|
@@ -36,7 +36,7 @@ int option = OPTION_ADD;
|
|||||||
dfaflags_t dfaflags = (dfaflags_t)(DFA_CONTROL_TREE_NORMAL | DFA_CONTROL_TREE_SIMPLE | DFA_CONTROL_MINIMIZE | DFA_CONTROL_MINIMIZE_HASH_TRANS);
|
dfaflags_t dfaflags = (dfaflags_t)(DFA_CONTROL_TREE_NORMAL | DFA_CONTROL_TREE_SIMPLE | DFA_CONTROL_MINIMIZE | DFA_CONTROL_MINIMIZE_HASH_TRANS);
|
||||||
|
|
||||||
char *subdomainbase = NULL;
|
char *subdomainbase = NULL;
|
||||||
char *progname = __FILE__;
|
const char *progname = __FILE__;
|
||||||
char *profile_ns = NULL;
|
char *profile_ns = NULL;
|
||||||
char *profilename = NULL;
|
char *profilename = NULL;
|
||||||
char *current_filename = NULL;
|
char *current_filename = NULL;
|
||||||
@@ -49,7 +49,7 @@ int read_implies_exec = 1;
|
|||||||
int read_implies_exec = 0;
|
int read_implies_exec = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void pwarn(char *fmt, ...)
|
void pwarn(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list arg;
|
va_list arg;
|
||||||
char *newfmt;
|
char *newfmt;
|
||||||
|
@@ -73,9 +73,9 @@ static char *stripblanks(char *s);
|
|||||||
/* default base directory is /etc/subdomain.d, it can be overriden
|
/* default base directory is /etc/subdomain.d, it can be overriden
|
||||||
with the -b option. */
|
with the -b option. */
|
||||||
|
|
||||||
char *basedir;
|
const char *basedir;
|
||||||
static char *default_basedir = "/etc/apparmor.d";
|
static const char *default_basedir = "/etc/apparmor.d";
|
||||||
static char *old_basedir = "/etc/subdomain.d";
|
static const char *old_basedir = "/etc/subdomain.d";
|
||||||
|
|
||||||
|
|
||||||
/* set up basedir so that it can be overridden/used later. */
|
/* set up basedir so that it can be overridden/used later. */
|
||||||
@@ -130,7 +130,7 @@ void set_base_dir(char *dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Add a directory to the search path. */
|
/* Add a directory to the search path. */
|
||||||
int add_search_dir(char *dir)
|
int add_search_dir(const char *dir)
|
||||||
{
|
{
|
||||||
char *t;
|
char *t;
|
||||||
if (npath >= MAX_PATH) {
|
if (npath >= MAX_PATH) {
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
extern int preprocess_only;
|
extern int preprocess_only;
|
||||||
|
|
||||||
extern int add_search_dir(char *dir);
|
extern int add_search_dir(const char *dir);
|
||||||
extern void init_base_dir(void);
|
extern void init_base_dir(void);
|
||||||
extern void set_base_dir(char *dir);
|
extern void set_base_dir(char *dir);
|
||||||
extern void parse_default_paths(void);
|
extern void parse_default_paths(void);
|
||||||
|
@@ -327,7 +327,7 @@ inline int sd_write64(sd_serialize *p, u64 b)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int sd_write_name(sd_serialize *p, char *name)
|
inline int sd_write_name(sd_serialize *p, const char *name)
|
||||||
{
|
{
|
||||||
long size = 0;
|
long size = 0;
|
||||||
PDEBUG("Writing name '%s'\n", name);
|
PDEBUG("Writing name '%s'\n", name);
|
||||||
@@ -362,7 +362,7 @@ inline int sd_write_blob(sd_serialize *p, void *b, int buf_size, char *name)
|
|||||||
|
|
||||||
#define align64(X) (((size_t) (X) + (size_t) 7) & ~((size_t) 7))
|
#define align64(X) (((size_t) (X) + (size_t) 7) & ~((size_t) 7))
|
||||||
inline int sd_write_aligned_blob(sd_serialize *p, void *b, int buf_size,
|
inline int sd_write_aligned_blob(sd_serialize *p, void *b, int buf_size,
|
||||||
char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
size_t pad;
|
size_t pad;
|
||||||
u32 tmp;
|
u32 tmp;
|
||||||
@@ -381,7 +381,7 @@ inline int sd_write_aligned_blob(sd_serialize *p, void *b, int buf_size,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sd_write_strn(sd_serialize *p, char *b, int size, char *name)
|
static int sd_write_strn(sd_serialize *p, char *b, int size, const char *name)
|
||||||
{
|
{
|
||||||
u16 tmp;
|
u16 tmp;
|
||||||
if (!sd_write_name(p, name))
|
if (!sd_write_name(p, name))
|
||||||
@@ -396,12 +396,12 @@ static int sd_write_strn(sd_serialize *p, char *b, int size, char *name)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int sd_write_string(sd_serialize *p, char *b, char *name)
|
inline int sd_write_string(sd_serialize *p, char *b, const char *name)
|
||||||
{
|
{
|
||||||
return sd_write_strn(p, b, strlen(b) + 1, name);
|
return sd_write_strn(p, b, strlen(b) + 1, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int sd_write_struct(sd_serialize *p, char *name)
|
inline int sd_write_struct(sd_serialize *p, const char *name)
|
||||||
{
|
{
|
||||||
if (!sd_write_name(p, name))
|
if (!sd_write_name(p, name))
|
||||||
return 0;
|
return 0;
|
||||||
@@ -417,7 +417,7 @@ inline int sd_write_structend(sd_serialize *p)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int sd_write_array(sd_serialize *p, char *name, int size)
|
inline int sd_write_array(sd_serialize *p, const char *name, int size)
|
||||||
{
|
{
|
||||||
u16 tmp;
|
u16 tmp;
|
||||||
if (!sd_write_name(p, name))
|
if (!sd_write_name(p, name))
|
||||||
@@ -437,7 +437,7 @@ inline int sd_write_arrayend(sd_serialize *p)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int sd_write_list(sd_serialize *p, char *name)
|
inline int sd_write_list(sd_serialize *p, const char *name)
|
||||||
{
|
{
|
||||||
if (!sd_write_name(p, name))
|
if (!sd_write_name(p, name))
|
||||||
return 0;
|
return 0;
|
||||||
@@ -724,7 +724,7 @@ int __sd_serialize_profile(int option, Profile *prof)
|
|||||||
if (kernel_load) fd = open(filename, O_WRONLY);
|
if (kernel_load) fd = open(filename, O_WRONLY);
|
||||||
break;
|
break;
|
||||||
case OPTION_STDOUT:
|
case OPTION_STDOUT:
|
||||||
filename = "stdout";
|
filename = strdup("stdout");
|
||||||
fd = dup(1);
|
fd = dup(1);
|
||||||
break;
|
break;
|
||||||
case OPTION_OFILE:
|
case OPTION_OFILE:
|
||||||
@@ -745,8 +745,7 @@ int __sd_serialize_profile(int option, Profile *prof)
|
|||||||
|
|
||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
if (option != OPTION_STDOUT && option != OPTION_OFILE)
|
free(filename);
|
||||||
free(filename);
|
|
||||||
|
|
||||||
if (option == OPTION_REMOVE) {
|
if (option == OPTION_REMOVE) {
|
||||||
char *name, *ns = NULL;
|
char *name, *ns = NULL;
|
||||||
|
@@ -134,7 +134,7 @@ static void display_version(void)
|
|||||||
parser_copyright);
|
parser_copyright);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void display_usage(char *command)
|
static void display_usage(const char *command)
|
||||||
{
|
{
|
||||||
display_version();
|
display_version();
|
||||||
printf("\nUsage: %s [options] [profile]\n\n"
|
printf("\nUsage: %s [options] [profile]\n\n"
|
||||||
@@ -298,7 +298,7 @@ static int handle_flag_table(optflag_table_t *table, const char *optarg,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void display_dump(char *command)
|
static void display_dump(const char *command)
|
||||||
{
|
{
|
||||||
display_version();
|
display_version();
|
||||||
printf("\n%s: --dump [Option]\n\n"
|
printf("\n%s: --dump [Option]\n\n"
|
||||||
@@ -310,7 +310,7 @@ static void display_dump(char *command)
|
|||||||
print_flag_table(dumpflag_table);
|
print_flag_table(dumpflag_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void display_optimize(char *command)
|
static void display_optimize(const char *command)
|
||||||
{
|
{
|
||||||
display_version();
|
display_version();
|
||||||
printf("\n%s: -O [Option]\n\n"
|
printf("\n%s: -O [Option]\n\n"
|
||||||
@@ -617,7 +617,7 @@ int find_subdomainfs_mountpoint(void)
|
|||||||
"mounted?\nUse --subdomainfs to override.\n"),
|
"mounted?\nUse --subdomainfs to override.\n"),
|
||||||
MOUNTED_FS);
|
MOUNTED_FS);
|
||||||
} else {
|
} else {
|
||||||
subdomainbase = DEFAULT_APPARMORFS;
|
subdomainbase = strdup(DEFAULT_APPARMORFS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -788,7 +788,7 @@ out:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_flags_string(char **flags, char *flags_file) {
|
static void get_flags_string(char **flags, const char *flags_file) {
|
||||||
char *pos;
|
char *pos;
|
||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
@@ -384,7 +384,7 @@ struct aa_network_entry *network_entry(const char *family, const char *type,
|
|||||||
return entry;
|
return entry;
|
||||||
};
|
};
|
||||||
|
|
||||||
char *processunquoted(char *string, int len)
|
char *processunquoted(const char *string, int len)
|
||||||
{
|
{
|
||||||
char *tmp, *s;
|
char *tmp, *s;
|
||||||
int l;
|
int l;
|
||||||
@@ -420,7 +420,7 @@ char *processunquoted(char *string, int len)
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *processid(char *string, int len)
|
char *processid(const char *string, int len)
|
||||||
{
|
{
|
||||||
/* lexer should never call this fn if len <= 0 */
|
/* lexer should never call this fn if len <= 0 */
|
||||||
assert(len > 0);
|
assert(len > 0);
|
||||||
@@ -433,7 +433,7 @@ char *processid(char *string, int len)
|
|||||||
/* rewrite a quoted string substituting escaped characters for the
|
/* rewrite a quoted string substituting escaped characters for the
|
||||||
* real thing. Strip the quotes around the string */
|
* real thing. Strip the quotes around the string */
|
||||||
|
|
||||||
char *processquoted(char *string, int len)
|
char *processquoted(const char *string, int len)
|
||||||
{
|
{
|
||||||
char *tmp, *s;
|
char *tmp, *s;
|
||||||
int l;
|
int l;
|
||||||
@@ -1235,7 +1235,7 @@ int test_str_to_boolean(void)
|
|||||||
int test_processunquoted(void)
|
int test_processunquoted(void)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
char *teststring, *processedstring;
|
const char *teststring, *processedstring;
|
||||||
|
|
||||||
teststring = "";
|
teststring = "";
|
||||||
MY_TEST(strcmp(teststring, processunquoted(teststring, strlen(teststring))) == 0,
|
MY_TEST(strcmp(teststring, processunquoted(teststring, strlen(teststring))) == 0,
|
||||||
@@ -1263,7 +1263,7 @@ int test_processunquoted(void)
|
|||||||
int test_processquoted(void)
|
int test_processquoted(void)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
char *teststring, *processedstring;
|
const char *teststring, *processedstring;
|
||||||
char *out;
|
char *out;
|
||||||
|
|
||||||
teststring = "";
|
teststring = "";
|
||||||
|
@@ -494,7 +494,7 @@ static int process_dfa_entry(aare_ruleset_t *dfarules, struct cod_entry *entry)
|
|||||||
/* add the pair rule */
|
/* add the pair rule */
|
||||||
char lbuf[PATH_MAX + 8];
|
char lbuf[PATH_MAX + 8];
|
||||||
int perms = AA_LINK_BITS & entry->mode;
|
int perms = AA_LINK_BITS & entry->mode;
|
||||||
char *vec[2];
|
const char *vec[2];
|
||||||
int pos;
|
int pos;
|
||||||
vec[0] = tbuf;
|
vec[0] = tbuf;
|
||||||
if (entry->link_name) {
|
if (entry->link_name) {
|
||||||
@@ -512,7 +512,7 @@ static int process_dfa_entry(aare_ruleset_t *dfarules, struct cod_entry *entry)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (entry->mode & AA_CHANGE_PROFILE) {
|
if (entry->mode & AA_CHANGE_PROFILE) {
|
||||||
char *vec[3];
|
const char *vec[3];
|
||||||
char lbuf[PATH_MAX + 8];
|
char lbuf[PATH_MAX + 8];
|
||||||
int index = 1;
|
int index = 1;
|
||||||
|
|
||||||
@@ -538,7 +538,7 @@ static int process_dfa_entry(aare_ruleset_t *dfarules, struct cod_entry *entry)
|
|||||||
if (entry->mode & (AA_USER_PTRACE | AA_OTHER_PTRACE)) {
|
if (entry->mode & (AA_USER_PTRACE | AA_OTHER_PTRACE)) {
|
||||||
int mode = entry->mode & (AA_USER_PTRACE | AA_OTHER_PTRACE);
|
int mode = entry->mode & (AA_USER_PTRACE | AA_OTHER_PTRACE);
|
||||||
if (entry->ns) {
|
if (entry->ns) {
|
||||||
char *vec[2];
|
const char *vec[2];
|
||||||
vec[0] = entry->ns;
|
vec[0] = entry->ns;
|
||||||
vec[1] = entry->name;
|
vec[1] = entry->name;
|
||||||
if (!aare_add_rule_vec(dfarules, 0, mode, 0, 2, vec, dfaflags))
|
if (!aare_add_rule_vec(dfarules, 0, mode, 0, 2, vec, dfaflags))
|
||||||
@@ -767,7 +767,8 @@ static int process_mnt_entry(aare_ruleset_t *dfarules, struct mnt_entry *entry)
|
|||||||
char typebuf[PATH_MAX + 3];
|
char typebuf[PATH_MAX + 3];
|
||||||
char flagsbuf[PATH_MAX + 3];
|
char flagsbuf[PATH_MAX + 3];
|
||||||
char optsbuf[PATH_MAX + 3];
|
char optsbuf[PATH_MAX + 3];
|
||||||
char *p, *vec[5];
|
char *p;
|
||||||
|
const char *vec[5];
|
||||||
int count = 0;
|
int count = 0;
|
||||||
unsigned int flags, inv_flags;
|
unsigned int flags, inv_flags;
|
||||||
|
|
||||||
@@ -1033,7 +1034,8 @@ static int process_dbus_entry(aare_ruleset_t *dfarules, struct dbus_entry *entry
|
|||||||
char pathbuf[PATH_MAX + 3];
|
char pathbuf[PATH_MAX + 3];
|
||||||
char ifacebuf[PATH_MAX + 3];
|
char ifacebuf[PATH_MAX + 3];
|
||||||
char memberbuf[PATH_MAX + 3];
|
char memberbuf[PATH_MAX + 3];
|
||||||
char *p, *vec[6];
|
char *p;
|
||||||
|
const char *vec[6];
|
||||||
|
|
||||||
pattern_t ptype;
|
pattern_t ptype;
|
||||||
int pos;
|
int pos;
|
||||||
|
@@ -32,9 +32,9 @@
|
|||||||
#include "mount.h"
|
#include "mount.h"
|
||||||
#include "dbus.h"
|
#include "dbus.h"
|
||||||
|
|
||||||
static inline char *get_var_end(char *var)
|
static inline const char *get_var_end(const char *var)
|
||||||
{
|
{
|
||||||
char *eptr = var;
|
const char *eptr = var;
|
||||||
|
|
||||||
while (*eptr) {
|
while (*eptr) {
|
||||||
if (*eptr == '}')
|
if (*eptr == '}')
|
||||||
@@ -52,8 +52,8 @@ static inline char *get_var_end(char *var)
|
|||||||
return NULL; /* no terminating '}' */
|
return NULL; /* no terminating '}' */
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct var_string *split_string(char *string, char *var_begin,
|
static struct var_string *split_string(const char *string, const char *var_begin,
|
||||||
char *var_end)
|
const char *var_end)
|
||||||
{
|
{
|
||||||
struct var_string *n = (struct var_string *) calloc(1, sizeof(struct var_string));
|
struct var_string *n = (struct var_string *) calloc(1, sizeof(struct var_string));
|
||||||
unsigned int offset = strlen("@{");
|
unsigned int offset = strlen("@{");
|
||||||
@@ -75,10 +75,10 @@ static struct var_string *split_string(char *string, char *var_begin,
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct var_string *split_out_var(char *string)
|
struct var_string *split_out_var(const char *string)
|
||||||
{
|
{
|
||||||
struct var_string *n = NULL;
|
struct var_string *n = NULL;
|
||||||
char *sptr;
|
const char *sptr;
|
||||||
BOOL bEscape = 0; /* flag to indicate escape */
|
BOOL bEscape = 0; /* flag to indicate escape */
|
||||||
|
|
||||||
if (!string) /* shouldn't happen */
|
if (!string) /* shouldn't happen */
|
||||||
@@ -99,7 +99,7 @@ struct var_string *split_out_var(char *string)
|
|||||||
if (bEscape) {
|
if (bEscape) {
|
||||||
bEscape = FALSE;
|
bEscape = FALSE;
|
||||||
} else if (*(sptr + 1) == '{') {
|
} else if (*(sptr + 1) == '{') {
|
||||||
char *eptr = get_var_end(sptr + 2);
|
const char *eptr = get_var_end(sptr + 2);
|
||||||
if (!eptr)
|
if (!eptr)
|
||||||
break; /* no variable end found */
|
break; /* no variable end found */
|
||||||
if (eptr == sptr + 2) {
|
if (eptr == sptr + 2) {
|
||||||
@@ -325,8 +325,8 @@ int process_profile_variables(Profile *prof)
|
|||||||
int test_get_var_end(void)
|
int test_get_var_end(void)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
char *retchar;
|
const char *retchar;
|
||||||
char *testchar;
|
const char *testchar;
|
||||||
|
|
||||||
testchar = "TRUE}";
|
testchar = "TRUE}";
|
||||||
retchar = get_var_end(testchar);
|
retchar = get_var_end(testchar);
|
||||||
@@ -356,9 +356,9 @@ int test_split_string(void)
|
|||||||
int rc = 0;
|
int rc = 0;
|
||||||
char *tst_string, *var_start, *var_end;
|
char *tst_string, *var_start, *var_end;
|
||||||
struct var_string *ret_struct;
|
struct var_string *ret_struct;
|
||||||
char *prefix = "abcdefg";
|
const char *prefix = "abcdefg";
|
||||||
char *var = "boogie";
|
const char *var = "boogie";
|
||||||
char *suffix = "suffixication";
|
const char *suffix = "suffixication";
|
||||||
|
|
||||||
asprintf(&tst_string, "%s@{%s}%s", prefix, var, suffix);
|
asprintf(&tst_string, "%s@{%s}%s", prefix, var, suffix);
|
||||||
var_start = tst_string + strlen(prefix);
|
var_start = tst_string + strlen(prefix);
|
||||||
@@ -404,11 +404,11 @@ int test_split_out_var(void)
|
|||||||
int rc = 0;
|
int rc = 0;
|
||||||
char *tst_string, *tmp;
|
char *tst_string, *tmp;
|
||||||
struct var_string *ret_struct;
|
struct var_string *ret_struct;
|
||||||
char *prefix = "abcdefg";
|
const char *prefix = "abcdefg";
|
||||||
char *var = "boogie";
|
const char *var = "boogie";
|
||||||
char *var2 = "V4rW1thNum5";
|
const char *var2 = "V4rW1thNum5";
|
||||||
char *var3 = "boogie_board";
|
const char *var3 = "boogie_board";
|
||||||
char *suffix = "suffixication";
|
const char *suffix = "suffixication";
|
||||||
|
|
||||||
/* simple case */
|
/* simple case */
|
||||||
asprintf(&tst_string, "%s@{%s}%s", prefix, var, suffix);
|
asprintf(&tst_string, "%s@{%s}%s", prefix, var, suffix);
|
||||||
|
Reference in New Issue
Block a user