From 6e50104da42731c24f1fcbfe2859cb51cb9409d2 Mon Sep 17 00:00:00 2001 From: Diptanshu8 Date: Wed, 28 Jun 2017 21:35:32 +0000 Subject: [PATCH] Cyclic rotation and python script argv passing solved --- linux/api_testing.py | 10 +++------- src/ccextractor.c | 23 +++++++---------------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/linux/api_testing.py b/linux/api_testing.py index de6c6333..1f9440c7 100644 --- a/linux/api_testing.py +++ b/linux/api_testing.py @@ -2,14 +2,10 @@ import ccextractor as cc import os import time import sys -sample = " ".join(sys.argv[1:]) -print 'Name of sample is {0}'.format(sample) -time.sleep(1) s = cc.api_init_options() cc.checking_configuration_file(s) -params = [str(sample)] -for i in params: +for i in sys.argv[1:]: cc.api_add_param(s,str(i)) -compile_ret = cc.compile_params(s,len(params)); +compile_ret = cc.compile_params(s,len(sys.argv[1:])); start_ret = cc.api_start(s); -os.system('clear') +#os.system('clear') diff --git a/src/ccextractor.c b/src/ccextractor.c index ebae1da9..2e6d4a24 100644 --- a/src/ccextractor.c +++ b/src/ccextractor.c @@ -434,24 +434,15 @@ void checking_configuration_file(struct ccx_s_options api_options){ int compile_params(struct ccx_s_options *api_options,int argc){ printf("Inside compile params\n"); - char** temp = malloc(api_options->argument_count*sizeof(char *)); - int i=0; - while(iargument_count){ - temp[i]=malloc(strlen(api_options->myarguments[i])); - strcpy(temp[i],api_options->myarguments[i]); - i++; - } api_options->myarguments = realloc(api_options->myarguments, (api_options->argument_count+1) * sizeof *api_options->myarguments); - api_options->myarguments[0] = realloc(api_options->myarguments[0],strlen("./ccextractor")+1); - strcpy(api_options->myarguments[0], "./ccextractor"); + api_options->myarguments[api_options->argument_count] = malloc(strlen("./ccextractor")+1); + strcpy(api_options->myarguments[api_options->argument_count], "./ccextractor"); api_options->argument_count++; - i=1; - while(iargument_count){ - api_options->myarguments[i] = realloc(api_options->myarguments[i],strlen(temp[i-1])); - strcpy(api_options->myarguments[i],temp[i-1]); - i++; - } - free(temp); + char* temp = api_options->myarguments[api_options->argument_count-1]; + int i; + for (i = api_options->argument_count-1; i > 0; i--) + api_options->myarguments[i] = api_options->myarguments[i-1]; + api_options->myarguments[0] = temp; int ret = parse_parameters (api_options, api_options->argument_count, api_options->myarguments); if (ret == EXIT_NO_INPUT_FILES) {