#include <stdlib.h>
#include <string.h>
-ARGS *args_init(int init_argc, char **init_args)
+struct args *
+args_init(int init_argc, char **init_args)
{
- ARGS *args;
+ struct args *args;
int i;
- args = (ARGS *)x_malloc(sizeof(ARGS));
+ args = (struct args *)x_malloc(sizeof(struct args));
args->argc = 0;
args->argv = (char **)x_malloc(sizeof(char *));
args->argv[0] = NULL;
return args;
}
-ARGS *args_init_from_string(const char *command)
+struct args *
+args_init_from_string(const char *command)
{
- ARGS *args;
+ struct args *args;
char *p = x_strdup(command);
char *q = p;
char *word;
return args;
}
-ARGS *args_copy(ARGS *args)
+struct args *
+args_copy(struct args *args)
{
return args_init(args->argc, args->argv);
}
-void args_free(ARGS *args)
+void
+args_free(struct args *args)
{
int i;
for (i = 0; i < args->argc; ++i) {
free(args);
}
-void args_add(ARGS *args, const char *s)
+void
+args_add(struct args *args, const char *s)
{
args->argv = (char**)x_realloc(args->argv, (args->argc + 2) * sizeof(char *));
args->argv[args->argc] = x_strdup(s);
}
/* pop the last element off the args list */
-void args_pop(ARGS *args, int n)
+void
+args_pop(struct args *args, int n)
{
while (n--) {
args->argc--;
}
/* remove the first element of the argument list */
-void args_remove_first(ARGS *args)
+void
+args_remove_first(struct args *args)
{
free(args->argv[0]);
memmove(&args->argv[0],
}
/* add an argument into the front of the argument list */
-void args_add_prefix(ARGS *args, const char *s)
+void
+args_add_prefix(struct args *args, const char *s)
{
args->argv = (char**)x_realloc(args->argv, (args->argc + 2) * sizeof(char *));
memmove(&args->argv[1], &args->argv[0],
}
/* strip any arguments beginning with the specified prefix */
-void args_strip(ARGS *args, const char *prefix)
+void
+args_strip(struct args *args, const char *prefix)
{
int i;
for (i=0; i<args->argc; ) {
* Format args to a space-separated string. Does not quote spaces. Caller
* frees.
*/
-char *args_to_string(ARGS *args)
+char *
+args_to_string(struct args *args)
{
char *result;
char **p;
}
/* Returns 1 if args1 equals args2, else 0. */
-int args_equal(ARGS *args1, ARGS *args2)
+int
+args_equal(struct args *args1, struct args *args2)
{
int i;
if (args1->argc != args2->argc) {
static char *base_dir;
/* the original argument list */
-static ARGS *orig_args;
+static struct args *orig_args;
/* the source file */
static char *input_file;
}
/* run the real compiler and put the result in cache */
-static void to_cache(ARGS *args)
+static void to_cache(struct args *args)
{
char *tmp_stdout, *tmp_stderr, *tmp_obj;
struct stat st;
* Returns the hash as a heap-allocated hex string.
*/
static struct file_hash *
-get_object_name_from_cpp(ARGS *args, struct mdfour *hash)
+get_object_name_from_cpp(struct args *args, struct mdfour *hash)
{
char *input_base;
char *tmp;
* Update a hash sum with information common for the direct and preprocessor
* modes.
*/
-static void calculate_common_hash(ARGS *args, struct mdfour *hash)
+static void calculate_common_hash(struct args *args, struct mdfour *hash)
{
struct stat st;
const char *compilercheck;
* modes and calculate the object hash. Returns the object hash on success,
* otherwise NULL. Caller frees.
*/
-static struct file_hash *calculate_object_hash(
- ARGS *args, struct mdfour *hash, int direct_mode)
+static struct file_hash *
+calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
{
int i;
char *manifest_name;
* -E; this is added later. Returns 0 on failure, otherwise 1.
*/
int
-cc_process_args(ARGS *orig_args, ARGS **preprocessor_args, ARGS **compiler_args)
+cc_process_args(struct args *orig_args, struct args **preprocessor_args,
+ struct args **compiler_args)
{
int i;
int found_c_opt = 0;
int dependency_filename_specified = 0;
/* is the dependency makefile target name specified with -MT or -MQ? */
int dependency_target_specified = 0;
- ARGS *stripped_args;
+ struct args *stripped_args;
int argc = orig_args->argc;
char **argv = orig_args->argv;
struct mdfour cpp_hash;
/* Arguments (except -E) to send to the preprocessor. */
- ARGS *preprocessor_args;
+ struct args *preprocessor_args;
/* Arguments to send to the real compiler. */
- ARGS *compiler_args;
+ struct args *compiler_args;
find_compiler(argc, argv);
void print_command(FILE *fp, char **argv);
void print_executed_command(FILE *fp, char **argv);
-typedef struct {
+/* ------------------------------------------------------------------------- */
+/* args */
+
+struct args {
char **argv;
int argc;
-} ARGS;
+};
+struct args *args_init(int, char **);
+struct args *args_init_from_string(const char *);
+struct args *args_copy(struct args *args);
+void args_free(struct args *args);
+void args_add(struct args *args, const char *s);
+void args_add_prefix(struct args *args, const char *s);
+void args_pop(struct args *args, int n);
+void args_strip(struct args *args, const char *prefix);
+void args_remove_first(struct args *args);
+char *args_to_string(struct args *args);
+int args_equal(struct args *args1, struct args *args2);
-ARGS *args_init(int , char **);
-ARGS *args_init_from_string(const char *);
-ARGS *args_copy(ARGS *args);
-void args_free(ARGS *args);
-void args_add(ARGS *args, const char *s);
-void args_add_prefix(ARGS *args, const char *s);
-void args_pop(ARGS *args, int n);
-void args_strip(ARGS *args, const char *prefix);
-void args_remove_first(ARGS *args);
-char *args_to_string(ARGS *args);
-int args_equal(ARGS *args1, ARGS *args2);
+/* ------------------------------------------------------------------------- */
int
-cc_process_args(ARGS *orig_args,
- ARGS **preprocessor_args,
- ARGS **compiler_args);
+cc_process_args(struct args *orig_args,
+ struct args **preprocessor_args,
+ struct args **compiler_args);
#if HAVE_COMPAR_FN_T
#define COMPAR_FN_T __compar_fn_t
int
cct_check_args_eq(const char *file, int line, const char *expression,
- ARGS *expected, ARGS *actual, int free1, int free2)
+ struct args *expected, struct args *actual,
+ int free1, int free2)
{
int result;
int cct_check_str_eq(const char *file, int line, const char *expression,
char *expected, char *actual, int free1, int free2);
int cct_check_args_eq(const char *file, int line, const char *expression,
- ARGS *expected, ARGS *actual, int free1, int free2);
+ struct args *expected, struct args *actual,
+ int free1, int free2);
#endif