示例#1
0
void report_dialog_show(GtkTreeModel * model, GtkWidget * parent)
{
    gboolean success;
    ReportDialog *rd = report_dialog_new(model, parent);

    if (gtk_dialog_run(GTK_DIALOG(rd->dialog)) == GTK_RESPONSE_ACCEPT) {
        shell_status_update("Generating report...");
        gtk_widget_hide(rd->dialog);
        shell_view_set_enabled(FALSE);
        shell_status_set_enabled(TRUE);

        success = report_generate(rd);

        shell_status_set_enabled(FALSE);

        if (success)
            shell_status_update("Report saved.");
        else
            shell_status_update("Error while creating the report.");
    }

    set_all_active(rd, FALSE);
    gtk_widget_destroy(rd->dialog);
    g_free(rd);
}
示例#2
0
int main(int argc, char **argv) {
  FILE *output_file,*code_file, *report_file;
  char char_input, ch;
  int state,i;
  int nrGroup,length,code_aux;
  char buffer[DICT_MAX_SIZE], aux[DICT_MAX_SIZE];
  dictionary_t dict;
  char *word, *previous_word;
  int first;
  


  if(argc < 2) {
    printf("Usage.\n");
    printf("  %s <coded file> [<dictionary file>]\n",argv[0]);
    exit(-1);
  }

    
    
  filename=get_filename(argv[1]);
  
  //printf("filename (%s)\n",filename);

  strcpy(input_filename,argv[1]);
  
  strcpy(output_filename,filename);
  strcat(output_filename,".dout");

  strcpy(report_filename,filename);
  strcat(report_filename,".drel");
  
  
  init_dict(&dict);
  
  if(argc == 3) 
  {
    have_dictionary=1;
    filename_dictionary=argv[2];
    init_dictionary_from_file(argv[2],&dict);
  }
  else
  {
    have_dictionary=0; 
    init_dictionary_with_ASCII_table(&dict);
  }

  //print_dictionary(&dict);
  
  
  
  // le arquivo codificado
  code_file = fopen(argv[1],"r");
  if (code_file == NULL) {
    printf("Error opening coded file %s.\n",argv[1]);
  }
  
  
  output_file = fopen(output_filename,"w");
  if (output_file == NULL) {
    printf("Error opening coded file output.txt.\n");
  }  
  state=C_GROUP;
  char_input = fgetc(code_file);
  nrGroup=0;
  length=0;
  code_aux=0;
  i=0;  
  first=1;
  cont_0=0;
  cont_1=0;
  while(char_input != EOF) 
  { 
    if(char_input=='1')
        cont_1++;
    else
        cont_0++;
        
    if(state==C_GROUP)
    {
        if(char_input=='1')
            nrGroup=nrGroup+ (int)pow(2,7-i);
            
        if(i==7)
        {
            state=C_LENGTH;
            i=-1;
        }
    }
    else if(state==C_LENGTH)
    {
        if(char_input=='1')
            length=length+ (int)pow(2,7-i);
            
        if(i==7)
        {
            state=C_CODES;
            i=-1;
        }
    }
    else if(state==C_CODES)
    {
        if(char_input=='1')
            code_aux=code_aux+ (int)pow(2,length-1-i);
    
        if(i==(length-1))
        {
            if(code_aux<size_dictionary(&dict))
	        {
		        word=search_in_dictionary(code_aux,&dict);
		        if(first==1)
		        { 
                    printf("(%s)",word);
                    fprintf(output_file, "%s",word);
			        first=0;
			        previous_word=word;
		        }
		        else
		        {
                    printf("(%s)",word);
                    fprintf(output_file, "%s",word);
			        buffer[0]=word[0];
			        buffer[1]='\0';
			        aux[0]='\0';
			        strcat(aux,previous_word);
			        strcat(aux, buffer);
			        insert_in_dictionary(aux,&dict);
			        previous_word=word;
		        }
            }
	        else
	        {
  
			    buffer[0]=word[0];
			    buffer[1]='\0';
			    strcat(previous_word, buffer);

        		insert_in_dictionary(previous_word,&dict);
			    previous_word=word;
                printf("(%s)",previous_word);
                fprintf(output_file, "%s",previous_word);
                }

                i=-1;
                code_aux=0;
            }
    }
    
    
    char_input = fgetc(code_file);
    i++;
  }


  printf("\ngroup number: %d\n",nrGroup);  
  printf("code length: %d\n",length); 
  fclose(output_file); 

  report_generate(argv[1],"output.dout");
  return 0;
  
}