void get(){
	empty_queues();
	GtkTextBuffer *b = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_rem));
	GtkTextBuffer *s = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_step));
	GtkTextIter start_i, end;
	gtk_text_buffer_get_start_iter (b, &start_i);
  	gtk_text_buffer_get_end_iter (b, &end);
	gchar *c = gtk_text_buffer_get_text(b, &start_i, &end, FALSE);
	int i;
	for(i = strlen(c) - 1; c[i] == '\n' || c[i] == '\0' ; i++) c[i] = '\0';

	int n = arg_count(c, '\n');
	alloc_m(n);

	char **line;
	line = (char **)malloc(sizeof(char *)*(n + 1));
	splitter(c, line, "\n");
	
	for(i = 0; i < n; i++){
		char **num;
		num = (char **)malloc(sizeof(char *)*(n + 2));
		
		int nm = splitter(line[i], num, ",");

		if(nm < n + 1){
			gtk_entry_set_text(GTK_ENTRY(entry_out), "INPUT ERROR : metrix error");
			gtk_text_buffer_set_text(s, "", -1);	
			return;
		}

		int j;
		for(j = 0; j < n + 1; j++)
			if(validate(num[j]))
				m[i][j] = atof(num[j]);
			else{
				free(num);
				free(line);
				free(c);
				gtk_entry_set_text(GTK_ENTRY(entry_out), 
						"INPUT ERROR : invalide characters");
				gtk_text_buffer_set_text(s, "", -1);	
				return;
			}
		free(num);
	}
	free(line);
	int flag = solve(n + 1, n);
	if(!flag)
		gtk_entry_set_text(GTK_ENTRY(entry_out), "INPUT ERROR!");
	else 
		set_output(n);

	if(start != NULL) {
		curnt = start;
		gtk_text_buffer_set_text(s, curnt -> s, -1);
	}else 
		gtk_text_buffer_set_text(s, "", -1);	
}
Exemple #2
0
    char * XmlHelper::LoadXmlFromFile(xml_doc & doc, const char * filename)
    {
        File file;

        if (file.Open(filename, OM_READ_BINARY))
        {
            int size = file.Size();

            char * data = (char *)alloc_m(size + 1);

            file.Read(data, sizeof(char), size);
            data[size] = 0;
            LoadXmlFromMem(doc, data);

            return data;
        }

        return NULL;
    }