Exemple #1
0
void update_dump()
{
	if(hex_dlg != NULL)
		dump_hex();
	if(text_dlg != NULL)
		dump_text();
}
Exemple #2
0
/** Dumps a secondary title. */
void
dump_subtitle(const char *str)
{
#ifdef DUMP_LOG
    dump_text("  %s\n", str);
    dump_html("<h3>%s</h3>\n", str);
#endif
}
Exemple #3
0
/** Ends a blockquote in the dump. */
void
dump_blockquote_end(void)
{
#ifdef DUMP_LOG
    dump_text("\n", "");
    dump_html("</blockquote>\n", "");
#endif
}
std::wstring xlsx_text_context::Impl::end_span2()
{
    const std::wstring content = dump_text();
    span_style_name_ = L"";
	
	in_span = false;
    return content;
}
void xlsx_text_context::Impl::end_paragraph()
{
    if (!in_comment && !in_draw)
	{
		dump_text();
		paragraph_style_name_ = L"";
	}
	in_paragraph = false;
}
void xlsx_text_context::Impl::end_span() //odf корявенько написан - возможны повторы стилей в последовательных кусках текста
//пока с анализом стилей тока комменты - остальные текстовые куски как есть.. с охрененным возможно дубляжом
{
     if (!in_comment && !in_draw)
	 {
		dump_text();
		span_style_name_=L"";
	 }
	 in_span=false;
}
Exemple #7
0
int main(int argc, const char *argv[])
{
	const char *infile = NULL;
	const char *outfile = NULL;
	FILE *out = stdout;
	int codepage = 0;

	while (*++argv)
	{
		if (!strcmp(*argv, "-o"))
		{
			if (outfile)
				usage();

			outfile = *++argv;

			if (!outfile)
				usage();

			out = fopen(outfile, "wt");

			if (!out)
				usage();

			continue;
		}

		if (!infile)
		{
			infile = *argv;
			continue;
		}

		if (!codepage)
		{
			codepage = atoi(*argv);
			continue;
		}

		usage();
	}

	if (!infile || !codepage)
		usage();

	if (load_mmo(infile))
		return 1;

	dump_text(out, codepage);

	return 0;
}
/*
 * Given the archive name (ar_name), the chunk types to output (chunk_mode),
 * and some other parameters such as the read filter, open one file and dumps
 * text formatted output to that file.  The number of reads is updated in the
 * \"num_reads\" parameter.
 *
 * Returns 0 on success.
 */
int process_srf_to_text_files(char *ar_name, char chunk_mode, int num_reads_only_mode, int filter_mode, read_filter_t *read_filter, long *num_reads) {
    srf_t *srf;
    char name[1024], dir2[1024];
    ztr_t *ztr;
    int last_lane = 0, last_tile = 0;
    /*               dump */
    FILE *files[] = {NULL};

    if (NULL == (srf = srf_open(ar_name, "rb"))) {
	perror(ar_name);
	return 1;
    }

    char *cp = strrchr(ar_name, '.');
    if (cp) *cp = 0;
    sprintf(dir2, "%s.run", ar_name);
    mkdir(dir2, 0777);

    while (NULL != (ztr = srf_next_ztr(srf, name, 0))) {
	int lane, tile, x, y;

	parse_name(name, &lane, &tile, &x, &y);

	if (last_lane != lane || last_tile != tile) {
	    fprintf(stderr, "New tile: %d/%d\n", lane, tile);
	    last_lane = lane;
	    last_tile = tile;

	    if (files[0]) { fclose(files[0]); files[0] = NULL; }

	    if (chunk_mode) {
		files[0] = fopen_text(dir2, lane, tile);
	    }
	}

	if(!num_reads_only_mode) {
	    if(!filter_mode || (filter_mode && check_read_name(read_filter, name))) {
		dump_text(ztr, name, chunk_mode, files);
		++(*num_reads);
	    }
	} else {
	    ++(*num_reads);
	}

	delete_ztr(ztr);
    }

    if (files[0]) fclose(files[0]);

    srf_destroy(srf, 1);
    return 0;
}
Exemple #9
0
        /*!
         Used to dump out a record to a std::ostream object.
         \param strm std::ostream to write to
         \param ptr Resource base object to dump
         */
        static void
        dump_record ( std::ostream& strm, dns::resource_base_t * ptr )
        {
          switch( ptr->rtype() )
          {
          case dns::type_a:
            dump_a(strm, ptr);
            break;

          case dns::type_ns:
            dump_ns(strm, ptr);
            break;

          case dns::type_cname:
            dump_cname(strm, ptr);
            break;

          case dns::type_soa:
            dump_soa(strm, ptr);
            break;

          case dns::type_ptr:
            dump_ptr(strm, ptr);
            break;

          case dns::type_hinfo:
            dump_hinfo(strm, ptr);
            break;

          case dns::type_mx:
            dump_mx(strm, ptr);
            break;

          case dns::type_txt:
            dump_text(strm, ptr);
            break;

          case dns::type_a6:
            dump_a6(strm, ptr);
            break;

          case dns::type_srv:
            dump_srv(strm, ptr);
            break;

          default:
            strm << "Unhandled record type!" << std::endl;
            break;
          }
        }
Exemple #10
0
void xlsx_text_context::Impl::start_paragraph(const std::wstring & styleName)
{
    if (paragraphs_cout_++ > 0)
    {	
		if (paragraph_style_name_ != styleName)
		{
			dump_text();
		}
	}else
	{
		text_.str(std::wstring());
	}
	paragraph_style_name_ = styleName;
	in_paragraph = true;
}
Exemple #11
0
void xlsx_text_context::Impl::start_span(const std::wstring & styleName)//кусок текста в абзаце(параграфе) со своими свойствами - этто может быть и 1 буква
{
     if (!in_comment && !in_draw)
	 {
		 text_.str(std::wstring());
	 }
	 else
	 {
		if (span_style_name_ !=styleName || in_span)
		{
			dump_text();
		}
	 }
	 span_style_name_ = styleName;
	 in_span=true;
}
/**
 * Stores in a hashmap the tokens of an e-mail body.
 */
map_t tokenizebody(char *email){
    char *res;
    
    rfc2822eml ret= parser_mail(email);
    map_t tokenmap;
    
    //printf("before dump_text\n");
    res=dump_text(ret);
    //printf("after dum_text\n");
    
    (res!=NULL)?(tokenmap=tokenize(res)):(tokenmap=NULL);
    
    //free(res);
    free_mail(ret);
    //freeEMLParser();
    
    return tokenmap;
}
Exemple #13
0
int
main (int    argc,
      char **argv)
{
  gchar *text;

  g_setenv ("PANGO_RC_FILE", "./pangorc", TRUE);

  if (argc < 2)
    fail ("must give a filename on the command line");

  if (!g_file_get_contents (argv[1], &text, NULL, NULL))
    fail ("Couldn't open sample text file");

  dump_text (text);

  g_free (text);

  return 0;
}
Exemple #14
0
int dump_roms(byte **rom, int nroms, int abits, int fmt)
{
  char fname[MAXFILENAME];
  int ix;
  FILE *ofp;
  unsigned int romsize = (1 << abits);

  fprintf(stderr, "%d ROM images to be written, %u bytes per image\n",
          nroms, romsize);

  for(ix = 0; ix < nroms; ix++) {
    if(rom[ix] != NULL) {
      sprintf(fname, g_ftmpl, ix);

      if((ofp = fopen(fname, "w")) == NULL) {
        fprintf(stderr, "Unable to open output file '%s' for writing\n",
                fname);
        return 0;
      }

      fprintf(stderr, "Writing ROM #%d to file '%s'\n", ix, fname);
      switch(fmt) {
      case BINARY_FMT:
        dump_raw(rom[ix], romsize, ofp);
        break;
      case TEXT_FMT:
        dump_text(rom[ix], romsize, ofp);
        break;
      default:
        dump_intel(rom[ix], romsize, ofp);
        break;
      }
      fclose(ofp);
    }
  }

  return 1;

} /* end dump_roms() */
Exemple #15
0
int do_serial_comms(const char *ttyfile, const char *baudrate, struct record *root)
{
	int fd;
	int len;
	speed_t speed;
	uint8_t *ptr;
	struct record *rec;
	const uint8_t BACKSPACE[] = {0x08};
	const uint8_t ERASE_ALL[] = {0x00};
	const uint8_t ACK = 0x06;
	ptr = io_buffer;

	if (baudrate_to_speed_t(baudrate, &speed)) {
		fprintf(stderr, "unsupported baudrate, %s\n", baudrate);
		return -1;
	}

	fd = serial_open(ttyfile, speed);
	if (fd < 0) {
		fprintf(stderr, "error opening serial port\n");
		return -1;
	}

	fprintf(stdout, "Putting card into download mode.\n");
	//Set PROG and reset
	set_dtr(fd, true);
	set_rts(fd, true);

	sleep(1);
	

	fprintf(stdout, "Trying to synchronize with ADuC70xx: ");
	fflush(stdout);
	
	while (serial_read_fully(fd, ptr, 1, 100));
	
	set_rts(fd, false);
	

	do {
		len = serial_write_fully(fd, BACKSPACE, sizeof(BACKSPACE), 1000);
		len = serial_read_fully(fd, ptr, 24, 100);
		
	} while (!((len > 6) && (memcmp(ptr, "ADuC70", 6) == 0)));

	//Disable PROG
	set_dtr(fd, false);
	
	while (serial_read_fully(fd, ptr, 1, 100));

	if ((len > 6) && (memcmp(ptr, "ADuC70", 6) == 0)) {
		int product_len = (memchr(ptr, ' ', 24) - (void *)ptr);
		fprintf(stdout, "Found %.*s\n", product_len, ptr);

		fprintf(stdout, "Erasing: ");
		fflush(stdout);

		len = fill_packet(ptr, 'E', 0x00000000, ERASE_ALL, sizeof(ERASE_ALL));
		len = serial_write_fully(fd, ptr, len, 1000);
		len = serial_read_fully(fd, ptr, 1, 10000);

		if ((len <= 0) || (ptr[0] != ACK)) {
			fprintf(stdout, "FAILED\n");
			goto error;
		}

		fprintf(stdout, "OK\n");

		rec = root;
		while (rec != NULL) {
			int count = 0;
			uint32_t address = rec->address;
			uint8_t *data = data_buffer;
			struct record *drec;

			for (drec = rec; ((drec != NULL) && ((address + count) == drec->address) && ((count + drec->count) < DATA_BUFFER_SIZE)); drec = drec->next) {
				memcpy(data, drec->data, drec->count);
				data += drec->count;
				count += drec->count;
			}
			rec = drec;

			fprintf(stdout, "Writting (%#x): ", address);
			fflush(stdout);

			len = fill_packet(ptr, 'W', address, data_buffer, count);
			len = serial_write_fully(fd, ptr, len, 1000);
			len = serial_read_fully(fd, ptr, 1, 10000);

			if ((len <= 0) || (ptr[0] != ACK)) {
				fprintf(stdout, "FAILED\n");
				goto error;
			}

			fprintf(stdout, "OK\n");
		}

		if (reset) {
			fprintf(stdout, "Resetting: ");
			fflush(stdout);

			len = fill_packet(ptr, 'R', 0x00000001, NULL, 0);
			len = serial_write_fully(fd, ptr, len, 1000);
			len = serial_read_fully(fd, ptr, 1, 10000);

			if ((len <= 0) || (ptr[0] != ACK)) {
				fprintf(stdout, "FAILED\n");
				goto error;
			}

			fprintf(stdout, "OK\n");
		}
	} else {
		fprintf(stdout, "FAILED\n");
		goto error;
	}

	if (follow) {
		int count = 600;
		while (count--) {
			len = serial_read(fd, ptr, 16, 1000);
			if (len > 0) {
				dump_text(stdout, ptr, len);
			}
		}
	}

error:
	if (serial_close(fd) < 0) {
		fprintf(stderr, "error closing serial port\n");
		return -1;
	}

	return 0;
}
Exemple #16
0
void recorder_t::output () {
  merge_and_sort();
  dump_byte();
  if (text_mode)
    dump_text();
}
Exemple #17
0
void xlsx_text_context::Impl::start_hyperlink()
{
	dump_text();
}
/*
 * Main method.
 */
int main(int argc, char **argv) {
    int i;
    long num_reads = 0;
    int num_reads_mode = 0;
    int num_reads_only_mode = 0;
    int filter_mode = 0;
    char *ar_name = NULL;
    srf_t *srf = NULL;
    char name[512];
    ztr_t *ztr = NULL;
    read_filter_t *read_filter = NULL;
    char *filter_value = NULL;

    int c;
    int errflg = 0;
    extern char *optarg;
    extern int optind, optopt;

    char chunk_mode = ALL;
    char type_mode = TEXT;
    char destination_mode = CONSOLE_DEST;
    FILE **files = NULL;
    int verbose = 0;

    if (argc < 2) {
	fprintf(stderr, "Please specify an archive name.\n");
	usage(1);
    }

    while ((c = getopt(argc, argv, ":c:d:f:not:v")) != -1) {
        switch (c) {
        case 'c':
	    chunk_mode = 0;
	    if(get_chunk_types(optarg, &chunk_mode) || !chunk_mode) {
                fprintf(stderr,
			"Invalid value \"%s\" given to option -%c.\n", optarg, c);
		errflg++;
	    }
	    break;
        case 'd':
	    destination_mode = 0;
	    if(get_destination_types(optarg, &destination_mode) || !destination_mode) {
                fprintf(stderr,
			"Invalid value \"%s\" given to option -%c.\n", optarg, c);
		errflg++;
	    }
	    break;
        case 'f':
	    if (num_reads_only_mode) {
		fprintf(stderr,
			"Option -%c is exclusing with option -o.\n", c);
                errflg++;
	    } else {
		filter_mode++;
		filter_value = optarg;
	    }
            break;
        case 'n':
	    if (num_reads_only_mode) {
		fprintf(stderr,
			"Option -%c is exclusing with option -o.\n", c);
                errflg++;
	    }
            else
                num_reads_mode++;
            break;
        case 'o':
	    if (num_reads_mode) {
		fprintf(stderr,
			"Option -%c is exclusing with option -n.\n", c);
                errflg++;
	    } else if (filter_mode) {
		fprintf(stderr,
			"Option -%c is exclusing with option -f.\n", c);
                errflg++;
	    } else
                num_reads_only_mode++;
            break;
        case 't':
	    type_mode=0;
	    if(get_type_of_output(optarg, &type_mode) || !type_mode) {
                fprintf(stderr,
			"Invalid value \"%s\" given to option -%c.\n", optarg, c);
		errflg++;
	    }
	    break;
        case 'v':
	    verbose++;
            break;
        case ':':       /* -? without operand */
            fprintf(stderr,
                    "Option -%c requires an operand\n", optopt);
            errflg++;
            break;
        case '?':
            fprintf(stderr,
                    "Unrecognised option: -%c\n", optopt);
            errflg++;
        }
    }

    if (errflg) {
	usage(1);
    }

    if(optind + 1 != argc) {
        fprintf(stderr, "The archive name must be the last argument.\n");
        usage(1);
    } else {
        ar_name = argv[optind];
    }
    
    if(filter_mode) {
	read_filter = get_read_filter(filter_value);
	if(verbose) {
	    dump_read_filter(read_filter);
	}
    }

    if(chunk_mode && verbose) {
	dump_chunk_mode(chunk_mode);
    }

    if(type_mode && verbose) {
	dump_type_mode(type_mode);
    }

    if(destination_mode && verbose) {
	dump_destination_mode(destination_mode);
    }

    if (!access(ar_name, R_OK)) {
	if(verbose) {
	    printf("Dumping from archive %s.\n", ar_name);
	}
    } else {
        fprintf(stderr, "Archive %s not found.\n", ar_name);
    }

    if(destination_mode & NONE_DEST) {
	if (NULL == (srf = srf_open(ar_name, "rb"))) {
	    perror(ar_name);
	    return 1;
	}

	while (NULL != (ztr = srf_next_ztr(srf, name, 0))) {
	    if(!num_reads_only_mode) {
		if(!filter_mode || (filter_mode && check_read_name(read_filter, name))) {
		    ++num_reads;
		}
	    } else {
		++num_reads;
	    }
	    delete_ztr(ztr);
	}
    }

    if(destination_mode & CONSOLE_DEST) {
	/* Cosole means stdout. */
	files = malloc((sizeof(FILE *))*5);
	for(i = 0; i < 5; i++) {
	    files[i] = stdout;
	}

	if (NULL == (srf = srf_open(ar_name, "rb"))) {
	    perror(ar_name);
	    return 1;
	}

	while (NULL != (ztr = srf_next_ztr(srf, name, 0))) {
	    if(!num_reads_only_mode) {
		if(!filter_mode || (filter_mode && check_read_name(read_filter, name))) {
		    if(type_mode & SOLEXA) {
			dump_solexa(ztr, name, chunk_mode, files);
		    } else if(type_mode & TEXT) {
			dump_text(ztr, name, chunk_mode, files);
		    } else {
			fprintf(stderr, "Assertion error on type_mode (%c).\nExiting.\n", type_mode);
			exit(1);
		    }
		    ++num_reads;
		}
	    } else {
		++num_reads;
	    }
	    delete_ztr(ztr);
	}
    }

    if(destination_mode & FILE_DEST) {
	if(type_mode & SOLEXA) {
	    process_srf_to_solexa_files(ar_name, chunk_mode, num_reads_only_mode, filter_mode, read_filter, &num_reads);
	} else if(type_mode & TEXT) {
	    process_srf_to_text_files(ar_name, chunk_mode, num_reads_only_mode, filter_mode, read_filter, &num_reads);
	} else {
	    fprintf(stderr, "Assertion error on type_mode (%c).\nExiting.\n", type_mode);
	    exit(1);
	}
    }

    if(num_reads_mode || num_reads_only_mode) {
	printf("\nReads: %ld\n", num_reads);
    }

    srf_destroy(srf, 1);

    return 0;
}