Exemplo n.º 1
0
int32_t ocl_add_from_file(const char * file, char ** source, int32_t prepend) {
	int32_t ierr = 0;
	char buffer[OCL_MAX_SOURCE_LENGTH];
	char path_file[OCL_MAX_SOURCE_LENGTH];
	char * file_string = NULL;
	struct stat st;

	// test for file existence
	if(stat(file, &st) != -1) {
		file_string = file_to_string(file);
	}
	else {
		// try appending the kernel path
		char * _paths = getenv("OCL_KERNEL_PATH") == NULL ? NULL :
			strdup(getenv("OCL_KERNEL_PATH"));
		char * _free_chars = _paths;
		char * _path = NULL;
		int32_t found = 0;

		while((_path = strsep(&_paths, ":")) != NULL) {
			sprintf(path_file, "%s/%s", _path, file);

			if(stat(path_file, &st) != -1) {
				file_string = file_to_string(path_file);
				found = 1;
				break;
			} // if
		} // while

		free(_free_chars);

		if(found == 0) {
			warning("File %s does not exist!\n", file);
			ierr = 1;
		} // if
	} // if

	if(ierr != 1) {
		// copy everything into temporary buffer
		if(prepend == 1) {
			sprintf(buffer, "%s%s", file_string,
				(*source == NULL) ? "" : *source);
		}
		else {
			sprintf(buffer, "%s%s",
				(*source == NULL) ? "" : *source, file_string);
		} // if

		// allocate new storage
		free(*source);
		*source = strndup(buffer, strlen(buffer));
	} // if

	// free locally allocated data
	free(file_string);

	return ierr;
} // ocl_concat_from_file
Exemplo n.º 2
0
int read_json(int argc, char **argv, cJSON **result)
{
	char *file_name;
	char *file;
	cJSON *json;
	int error;

	file_name = (argc >= 2) ? argv[1] : "netsocket.json";
	log_info("Opening file %s...", file_name);
	error = file_to_string(file_name, &file);
	if (error)
		return error;

	json = cJSON_Parse(file);
	if (!json) {
		log_err("JSON syntax error.");
		log_err("The JSON parser got confused around about here:");
		log_err("%s", cJSON_GetErrorPtr());
		free(file);
		return 1;
	}

	free(file);
	*result = json;
	return 0;
}
Exemplo n.º 3
0
int main(int argc, char *argv[]) {
    //regex_test();
    /*
    CFG<Parse_data> *cfg = read_grammar(ss.str());
    if (cfg)
        cout << endl << cfg->str() << endl << endl;
        */
    SymbolTable *symtab = new SymbolTable();
    Lexer<int> *lexer = read_lexer(file_to_string(argv[1]), symtab);
    CFG<int> *cfg = read_grammar(file_to_string(argv[2]), symtab);
    //cout << cfg->dfa->str() << endl << endl;
    cfg->parse(lexer->lex(file_to_string(argv[3]), true, true), true);

    // for (int i = 0; i < lexer->rules.size()-2; ++i) {
    //     cout << lexer->rules[i].regex.dfa->str() << endl;
    // }
    
    return 0;
}
Exemplo n.º 4
0
int parse_file(char *file_name)
{
	char *buffer;
	int error;

	error = file_to_string(file_name, &buffer);
	if (error)
		return error;

	error = do_parsing(buffer);
	free(buffer);
	return error;
}
Exemplo n.º 5
0
int main(int argc, char *argv[])
{
    fn = argv[1];
    FILE *fp;
    fp = fopen(fn, "r");
    char *longs ; // the file is turn into a string
    char *item ;
    int nl;

    char type[512];
    char val_name[512];
    char *val_defn;
    int count ; 

    char key[512];
    struct nlist *kd;

    longs = file_to_string(fp);
    nl = 0;
    clear_comment(longs, ' '); // all the comments region are replaced by blanks
    if ((item = strtok(longs, ";")) != NULL){
        count = item_to_value(item, type, val_name, &val_defn);
        if (count == 3){
            fprintf(stdout, ">> %12s,%12s,%s\n", type, val_name, val_defn);
            nl ++;
            install(val_name, val_defn);
        }
        //fprintf(stdout, "%i: %s\n", nl, item);
    }

    while ((item = strtok(NULL, ";"))!= NULL){
        count = item_to_value(item, type, val_name, &val_defn);
        if (count == 3){
            nl++;
            fprintf(stdout, ">> %12s,%12s,%s\n", type, val_name, val_defn);
            install(val_name, val_defn);
        //fprintf(stdout, "%i: %s\n", nl, item);
        }
    }

    printf("%s\n", "input the key name: ");
    while(scanf("%s", key) !=  EOF){
        kd = lookup(key);
        printf("key(%s) = %s\n", key, (kd == NULL)? "Not found" : kd-> defn);
        printf("%s\n", "input the key name: ");
    }
    
    return 0;
}
Exemplo n.º 6
0
int sum_file_util(const char *infile_path){
  std::string str = file_to_string(infile_path);
  int sum = 0;
  char *lineptr = str.data();
  char *endptr = nullptr;
  while(1){
    int tmp = strtol(lineptr, &endptr, 0);
    if(lineptr == endptr){
      return sum;
    }
    sum += tmp;
    lineptr = endptr;
  }
  return sum;
}
Exemplo n.º 7
0
/**
 * Builds a script file and adds its code to the bytecode output buffer and
 * stores references to its functions and variables in the Compiler object.
 * If the file has already been built in this instance of Compiler, the
 * function returns true without doing anything to prevent duplicate code.
 * After several input buffers of scripts have been built, you can copy the
 * bytecode to a buffer for execution using compiler_bytecode().
 * compiler: an instance of compiler that will receive the bytecode.
 * input: an input buffer that contains the script code.
 * inputLen: the number of bytes in length of the input.
 * returns: true if the compile operation succeeds, and false if it fails.
 */
bool compiler_build_file(Compiler * compiler, char * fileName) {
  assert(compiler != NULL);
  assert(fileName != NULL);
  
  bool result;
  bool prevExists;
  size_t codeFileSize = 0;
  char * codeFileText;

  /* mark this script file as already compiled */
  if(!set_add(compiler->compiledScripts, fileName, 
	      strlen(fileName), &prevExists)) {
    compiler->err = COMPILERERR_ALLOC_FAILED;
    return false;
  }

  /* check if script was previously included in this Compiler instance */
  if(prevExists) {
    /* don't rebuild a second time. the code is already in the bytecode */
    return true;
  }

  /* load entire file into a buffer for compilation */
  codeFileText = file_to_string(fileName, &codeFileSize);

  /* check that file opened correctly */
  if(codeFileText == NULL) {
    compiler->err = COMPILERERR_SOURCE_FILE_READ_ERR;
    return false;
  }

  /* build the code */
  result = compiler_build(compiler, codeFileText, codeFileSize);
  free(codeFileText);
  
  return result;
}
Exemplo n.º 8
0
int main(int argc, char **argv){
  
  QCoreApplication::setLibraryPaths(QStringList());
  
  QApplication app(argc,argv);

  QString filename = fromBase64(argv[1]);

  QString running_plugin_names = fromBase64(argv[2]);
  
  QString emergency_save_filename = fromBase64(argv[3]);
    
  Crash_Type crash_type = QString(argv[4])=="is_crash" ? CT_CRASH : QString(argv[4])=="is_error" ? CT_ERROR : CT_WARNING;

  send_crash_message_to_server(file_to_string(filename), running_plugin_names, emergency_save_filename, crash_type);

  if (crash_type==CT_CRASH)
    delete_file(filename);
  else
    clear_file(filename);

  
  return 0;
}
Exemplo n.º 9
0
void CRASHREPORTER_send_message(const char *additional_information, const char **messages, int num_messages, Crash_Type crash_type){
  QString plugin_names = get_plugin_names();
  
  QString tosend = QString(additional_information) + "\n\n";

  tosend += VERSION "\n\n";

  tosend += "OpenGL vendor: " + QString((GE_vendor_string==NULL ? "(null)" : (const char*)GE_vendor_string )) + "\n";
  tosend += "OpenGL renderer: " + QString((GE_renderer_string==NULL ? "(null)" : (const char*)GE_renderer_string)) + "\n";
  tosend += "OpenGL version: " + QString((GE_version_string==NULL ? "(null)" : (const char*)GE_version_string)) + "\n";
  tosend += QString("OpenGL flags: %1").arg(GE_opengl_version_flags, 0, 16) + "\n\n";

  tosend += "Running plugins: " + plugin_names + "\n\n";

  tosend += "Running time: " + QString::number(running_time.elapsed()) + "\n\n";

  tosend += "\n\n";

    
  for(int i=0;i<num_messages;i++)
    tosend += QString::number(i) + ": "+messages[i] + "\n";

  tosend += "\n\n";

  int event_pos = g_event_pos;

  tosend += "start event_pos: " + QString::number(event_pos) + "\n";

  for(int i=event_pos-1; i>=0 ; i--)
    tosend += QString(g_event_log[i]) + "\n";

  for(int i=NUM_EVENTS-1; i>=event_pos ; i--)
    tosend += QString(g_event_log[i]) + "\n";

  tosend += "end event_pos: " + QString::number(g_event_pos) + "\n";
  
  tosend += "\n\n";

#if defined(FOR_LINUX)
  tosend += "LINUX\n\n";
  tosend += "/etc/os-release: "+file_to_string("/etc/os-release");
  tosend += "\n\n";
  tosend += "/proc/version: "+file_to_string("/proc/version");
  tosend += "\n\n";
  tosend += "/proc/cpuinfo: "+file_to_string("/proc/cpuinfo");
#endif

  // start process
  {
    QString program = QCoreApplication::applicationDirPath() + QDir::separator() + "crashreporter";
#if FOR_WINDOWS
    program += ".exe";
#endif

    QTemporaryFile *file;
    
    if (crash_type==CT_CRASH) {
      file = new QTemporaryFile;
    } else {
      if (g_crashreporter_file==NULL) {
        g_crashreporter_file = new QTemporaryFile;
        g_crashreporter_file->setAutoRemove(false); // We delete it in the sub process. This process is just going to exit as soon as possible.
      }
      file = g_crashreporter_file;
    }

    bool save_mixer_tree;
    
    if (crash_type==CT_CRASH)
      save_mixer_tree = false; // Don't want to risk crashing inside the crash handler.
    else
      save_mixer_tree = true;
    
    string_to_file(tosend, file, save_mixer_tree);

    /*
      Whether to block
      ================
                                    RELEASE      !RELEASE
                                -------------------------
      Crash in main thread      |     no [1]       yes [2]
      Crash in other thread     |     no [1]       yes [2]
      Assert in main thread     |     no [4]       yes [2]
      Assert in other thread    |     no [4]       yes [2,3]

      [1] When crashing in RELEASE mode, it doesn't matter wheter we block or not, because
          radium will exit immediately after finishing this function anyway, and it's
          probably better to do that as quickly as possible.

      [2] Ideally, this should happen though:
          1. All threads immediately freezes
          2. A dialog pops up asking whether to:
             a) Stop program (causing gdb to kick in)
             b) Ignore
             c) Run assert crashreporter

      [3] This can be annoying if the assert happens in the audio thread though.

      [4] Asserts are not really supposed to happen, but there are a lot of them, 
          and they might pop up unnecessarily (for instance a bug in the asserts themselves):
          * Blocking might cause the program to be non-functional unnecessarily.
          * Blocking could prevent the user from saving the current song,
            for instance if the assert window just pops up immediately after closing it.
     */

#ifdef RELEASE
    bool do_block = false;
#else
    bool do_block = true;
#endif

    QTemporaryFile emergency_save_file("radium_crash_save");

#if 0
    bool dosave = is_crash && Undo_num_undos_since_last_save()>0;
#else
    bool dosave = false; // saving inside a forked version of the program didn't really work that well. Maybe it works better in windows.
#endif
    
    if (dosave)
      emergency_save_file.open();
    
    run_program(program,
                toBase64(file->fileName()),
                toBase64(plugin_names),
                toBase64(dosave ? emergency_save_file.fileName() : NOEMERGENCYSAVE),
                crash_type==CT_CRASH ? "is_crash" : crash_type==CT_ERROR ? "is_error" : "is_warning",
                do_block
                );

    if (dosave)
      Save_Clean(STRING_create(emergency_save_file.fileName()),root,false);
  }
  
}
Exemplo n.º 10
0
void matrix_mult_gpu(float *mat1, float *mat2, float *out, int n)
{
	size_t global_size;
	size_t local_size;

	char *kernel_src;

	cl_int err;
	cl_platform_id platform_id;
	cl_device_id device_id;
	cl_uint max_compute_units;
	size_t max_workgroup_size;

	cl_context context;
	cl_command_queue commands;
	cl_program program;
	cl_kernel kernel;
	cl_mem d_mat1;
	cl_mem d_mat2;
	cl_mem d_out;

	cl_event event;
	cl_ulong start, end;

	/* start OpenCL */
	err = clGetPlatformIDs(1, &platform_id,NULL);
	clErrorHandling("clGetPlatformIDs");

	err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, NULL);
	clErrorHandling("clGetDeviceIDs");

	context = clCreateContext(0, 1, &device_id, NULL, NULL, &err);
	clErrorHandling("clCreateContext");

	commands = clCreateCommandQueue(context, device_id, CL_QUEUE_PROFILING_ENABLE, &err);
	clErrorHandling("clCreateCommandQueue");

	/* create kernel */
	kernel_src = file_to_string(KERNEL_SRC);
	program = clCreateProgramWithSource(context, 1, (const char**) &kernel_src, NULL, &err);
	free(kernel_src);
	clErrorHandling("clCreateProgramWithSource");

	err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL);
	clErrorHandling("clBuildProgram");

	kernel = clCreateKernel(program, "matrix_mult", &err);
	clErrorHandling("clCreateKernel");

	/* allocate memory and send to gpu */
	d_mat1 = clCreateBuffer(context, CL_MEM_READ_ONLY, sizeof(float) * n * n, NULL, &err);
	d_mat2 = clCreateBuffer(context, CL_MEM_READ_ONLY, sizeof(float) * n * n, NULL, &err);
	d_out = clCreateBuffer(context, CL_MEM_WRITE_ONLY, sizeof(float) * n * n, NULL, &err);
	clErrorHandling("clCreateBuffer");

	err  = clEnqueueWriteBuffer(commands, d_mat1, CL_TRUE, 0, sizeof(float) * n * n, mat1, 0, NULL, NULL);
	err |= clEnqueueWriteBuffer(commands, d_mat2, CL_TRUE, 0, sizeof(float) * n * n, mat2, 0, NULL, NULL);
	clErrorHandling("clEnqueueWriteBuffer");

	err  = clGetDeviceInfo(device_id, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(cl_uint), &max_compute_units, NULL);
	err |= clGetDeviceInfo(device_id, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), &max_workgroup_size, NULL);
	clErrorHandling("clGetDeviceInfo");

	/* prepare kernel args */
	err  = clSetKernelArg(kernel, 0, sizeof(cl_mem), &d_mat1);
	err |= clSetKernelArg(kernel, 1, sizeof(cl_mem), &d_mat2);
	err |= clSetKernelArg(kernel, 2, sizeof(cl_mem), &d_out);
	err |= clSetKernelArg(kernel, 3, sizeof(unsigned int), &n);

	/* execute */
	local_size = n / max_compute_units / 8;
	if (local_size > max_workgroup_size)
		local_size = max_workgroup_size;

	/*
	 *	Usually it would be
	 *	global_size = local_size * max_compute_units;
	 *	but that would only be valid if local_size = n / max_compute_units;
	 *	local_size is n / max_compute_units / 8 because it obtains its hightest performance.
	 */
	global_size = n;

	err = clEnqueueNDRangeKernel(commands, kernel, 1, NULL, &global_size, &local_size, 0, NULL, &event);
	clErrorHandling("clEnqueueNDRangeKernel");

	clWaitForEvents(1, &event);
	clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_START, sizeof(cl_ulong), &start, NULL);
	clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END, sizeof(cl_ulong), &end, NULL);
	fprintf(stderr, "Time for event (ms): %10.5f \n", (end - start) / 1000000.0);

	err = clFinish(commands);
	clErrorHandling("clFinish");

	/* transfer back */
	err = clEnqueueReadBuffer(commands, d_out, CL_TRUE, 0, sizeof(float) * n * n, out, 0, NULL, NULL);
	clErrorHandling("clEnqueueReadBuffer");

	MATRIX_PRINT_SAMPLE;

	/* cleanup*/
	clReleaseMemObject(d_mat1);
	clReleaseMemObject(d_mat2);
	clReleaseMemObject(d_out);
	clReleaseProgram(program);
	clReleaseKernel(kernel);
	clReleaseCommandQueue(commands);
	clReleaseContext(context);
	clReleaseEvent(event);
}
Exemplo n.º 11
0
/*
 * Find all interrupts in a file f.
 */
struct proc_interrupts get_interrupts(int cpu) {
	char *interruptsString;
	interruptsString = file_to_string("/proc/interrupts"); // Read a file with interrupts into a string
	struct proc_interrupts result = get_interrupts_from_string(interruptsString, cpu);
	return result;
}
Exemplo n.º 12
0
int main(int argc, char** argv)
{
    std::string filename;
    try
    {
        configuration config;
        std::string copyright_filename;
        std::string output_style;

        // Read/get configuration
        {
            namespace po = boost::program_options;
            po::options_description description;

            std::string convenience_headers;

            description.add_options()
                ("help", "Help message")
                ("version", "Version description")
                ("xml", po::value<std::string>(&filename), 
                            "Name of XML file written by Doxygen")
                ("start_include", po::value<std::string>(&config.start_include), 
                            "Start include")
                ("convenience_header_path", po::value<std::string>(&config.convenience_header_path), 
                            "Convenience header path")
                ("convenience_headers", po::value<std::string>(&convenience_headers), 
                            "Convenience header(s) (comma-separated)")
                ("skip_namespace", po::value<std::string>(&config.skip_namespace), 
                            "Namespace to skip (e.g. boost::mylib::)")
                ("copyright", po::value<std::string>(&copyright_filename), 
                            "Name of QBK file including (commented) copyright and license")

                ("output_style", po::value<std::string>(&output_style),
                            "Docbook output style. Available values: 'alt'")
                ("output_member_variables", po::value<bool>(&config.output_member_variables), 
                            "Output member variables inside the class")
            ;

            po::variables_map varmap;

            if (argc == 2 && ! boost::starts_with(argv[1], "--"))
            {
                // (especially for debugging) options might go into an INI file
                std::ifstream config_file (argv[1], std::ifstream::in);
                po::store(po::parse_config_file(config_file, description), varmap);
            }
            else
            {
                po::store(po::parse_command_line(argc, argv, description), varmap);
            }

            po::notify(varmap);

            if (varmap.count("version"))
            {
                std::cout << version << std::endl;
                return 0;
            }
            else if (varmap.count("help"))
            {
                std::cout 
                    << program_description(true) << std::endl 
                    << "Available options:" << std::endl
                    << description << std::endl;
                return 0;
            }
            else if (filename.empty())
            {
                std::cout 
                    << program_description(true) << std::endl 
                    << "Allowed options:" << std::endl
                    << description << std::endl;
                return 1;
            }

            // Split CSV with headerfile names into configuration
            if (! convenience_headers.empty())
            {
                boost::split(config.convenience_headers, convenience_headers, boost::is_any_of(","));
            }
        }

        // Set output style
        if ( "alt" == output_style )
            config.output_style = configuration::alt;

        // Read files into strings
        std::string xml_string = file_to_string(filename);
        std::string license = copyright_filename.empty() 
            ? "" 
            : file_to_string(copyright_filename);

        // Parse the XML outputted by Doxygen
        xml_doc xml(xml_string.c_str());

        documentation doc;
        parse(xml.first_node(), config, doc);

        // Check for duplicate function names
        for (std::size_t i = 0; i < doc.functions.size(); i++)
        {
            function& f1 = doc.functions[i];
            for (std::size_t j = i + 1; j < doc.functions.size(); j++)
            {
                function& f2 = doc.functions[j];

                if (f1.name == f2.name)
                {
                    // It is not a unique function, so e.g. an overload,
                    // so a description must distinguish them.
                    // Difference is either the number of parameters, or a const / non-const version
                    // Use the "\qbk{distinguish,with strategy}" in the source code to distinguish
                    f1.unique = false;
                    f2.unique = false;
                }
            }
        }


        // Write copyright/license (keep inspect silent)
        if (! license.empty())
        {
            std::cout << license << std::endl;
        }

        // Write warning comment
        std::cout
            << "[/ Generated by " << program_description(false) << ", don't change, will be overwritten automatically]" << std::endl
            << "[/ Generated from " << filename << "]" << std::endl;

        if ( configuration::def == config.output_style )
        {
            // Write the rest: functions, defines, classes or structs
            BOOST_FOREACH(function const& f, doc.functions)
            {
                quickbook_output(f, config, std::cout);
            }
            BOOST_FOREACH(function const& f, doc.defines)
            {
                quickbook_output(f, config, std::cout);
            }
            BOOST_FOREACH(enumeration const& e, doc.enumerations)
            {
                quickbook_output(e, config, std::cout);
            }

            if (! doc.cos.name.empty())
            {
                std::sort(doc.cos.functions.begin(), doc.cos.functions.end(), sort_on_line<function>());
                quickbook_output(doc.cos, config, std::cout);
            }
        }
        else if ( configuration::alt == config.output_style )
        {
            if (! doc.cos.name.empty())
            {
                std::sort(doc.cos.functions.begin(), doc.cos.functions.end(), sort_on_line<function>());
                quickbook_output_alt(doc.cos, config, std::cout);
            }

            if ( !doc.group_id.empty() )
                quickbook_output_alt(doc, config, std::cout);
        }
    }
Exemplo n.º 13
0
int
main(int argc, char* argv[]) {
	/*init of all tabs and vars*/
	char* alphabet = "abcdefghijklmnopqrstuvwxyz";
	char* clef     = "notaverysmartkey";
	char* tab;
	int taillalpha = 26;
	int tailletab;
	int tailleclef;
	int* iclef;
	int* itab;
	Boolean casetwo      = FALSE;
	Boolean unknown_char = FALSE;

	/*test options */
	int c;

	while(1) {
		int option_index                    = 0;
		static struct option long_options[] = {{"alphabet", required_argument, 0, 'a'},
		                                       {"help", no_argument, 0, 'h'},
		                                       {"skip", no_argument, 0, 's'},
		                                       {"key", required_argument, 0, 'k'}};

		c = getopt_long(argc, argv, "a:hk:s", long_options, &option_index);
		if(c == -1) {
			break;
		}

		switch(c) {

			case 'a':
				printf("option a with value of '%s'\n", optarg);
				alphabet = file_to_string(optarg);
				break;

			case 'h':
				print_man(TRUE);
				return 0;
				break;

			case 's':
				printf("option c with value of '%s'\n", optarg);
				unknown_char = TRUE;
				break;

			case 'k':
				printf("option d with value '%s'\n", optarg);
				clef = file_to_string(optarg);
				break;

			default:
				printf("?? getopt returned character code 0%o ??\n", c);
				return 1;
				break;
		}
	}

	/*test args*/

	switch(argc - optind) {
		case 0:
			/*in no argument read tab from keyboard*/
			printf("pas d'argument entrer une chaine\n");
			tab = calloc(100, sizeof(char));
			fgets(tab, 99, stdin);
			break;
		case 1:
			/* if one argument then read file and put it in tab*/
			printf("arg 1 %s\n", argv[optind]);
			tab = file_to_string(argv[optind]);
			printf("tableau lue dans %s = %s\n", argv[optind], tab);
			break;
		case 2:
			/*if 2 argumpent read file an put it in tab then set casetow to true*/
			printf("arg2 %s\n", argv[optind - 1]);
			casetwo = TRUE;
			tab     = file_to_string(argv[optind]);
			break;
		default:
			print_man(TRUE);
			return 1;
			break;
	}

	if(unknown_char == TRUE) {
		/* remove uknow char if -s */
		printf("remove unknown char\n");
		rm_unknown_char(tab, alphabet);
	}

	tailletab  = strlen(tab);
	tailleclef = strlen(clef);
	taillalpha = strlen(alphabet);
	itab       = malloc(tailletab * sizeof(int));
	iclef      = malloc(tailleclef * sizeof(int));

	printf("taille clef %d\n", tailleclef);

	/*convert tab and key to int tab*/
	string_to_int(tab, alphabet, itab);
	string_to_int(clef, alphabet, iclef);

	/*test invalid char in the key*/
	testclef(iclef, tailleclef);

	/*decod tab with the key, minus done with a pointer to the fuction*/
	codclef(iclef, itab, tailletab, tailleclef, taillalpha, &addition);

	/*convert the final int tab to a char tab*/
	int_to_alpha(itab, tab, alphabet, tailletab);

	/*if a dest file have been specified write the result into the file elese print the result */
	if(casetwo == FALSE) {
		printf("message final: %s\n", tab);
	} else {
		/*argv[optind+1] = file name*/
		printf("ecriture de %s dans %s\n", tab, argv[optind + 1]);
		write_file(argv[optind + 1], tab);
	}

	/*free all alocations*/
	free(itab);
	free(iclef);
	free(tab);
	return 0;
}
Exemplo n.º 14
0
 void Csv::load(const Path &path, const string &seperators)
 {
   load(file_to_string(path), seperators);
 }