void analyze_special (font fn, font_metric fnm, array<string>& r) { if (range_exists (fnm, 0x41, 0x5a) && range_exists (fnm, 0x61, 0x7a)) { bool mono= true; metric_struct* x= fnm->get (0x41); for (int i= 0x42; i<=0x7a; i++) if (i <= 0x5a || i >= 0x61) { metric_struct* y= fnm->get (i); if (y->x2 != x->x2) { mono= false; break; } } if (mono) r << string ("mono=yes"); else r << string ("mono=no"); } if (range_exists (fnm, 0x41, 0x5a)) { glyph glL= fn->get_glyph ("L"); if (!is_nil (glL)) { bool sans= is_sans_serif (glL); if (sans) r << string ("sans=yes"); else r << string ("sans=no"); } } if (range_exists (fnm, 0x5b, 0x5b)) { glyph gl= fn->get_glyph ("["); if (!is_nil (gl)) { int sl= (int) floor (100.0 * get_slant (gl) + 0.5); r << (string ("slant=") * as_string (sl)); } } if (range_exists (fnm, 0x61, 0x7a)) { bool italic= true; glyph ga= fn->get_glyph ("a"); if (is_nil (ga)) italic= false; else { int status= italic_a_status (ga); //r << (string ("italic-a=") * as_string (status)); italic= (status == 0); } metric_struct* f= fnm->get (0x66); metric_struct* x= fnm->get (0x78); italic= italic && (f->y3 < -(x->y2/5)); if (italic) r << string ("italic=yes"); else r << string ("italic=no"); } if (range_exists (fnm, 0x41, 0x5a) && range_exists (fnm, 0x61, 0x7a)) { array<int> upr= build_range (0x41, 0x5a); array<int> lor= build_range (0x61, 0x7a); array<int> uph= decode_trace (height_trace (fnm, upr)); array<int> loh= decode_trace (height_trace (fnm, lor)); if (l1_distance (loh, uph) <= N(upr)) { metric_struct* A= fnm->get (0x41); metric_struct* a= fnm->get (0x61); int Ah= A->y4 - A->y3; int ah= a->y4 - a->y3; if (ah < ((95 * Ah) / 100)) r << string ("case=smallcaps"); else r << string ("case=caps"); } else r << string ("case=mixed"); } if (range_exists (fnm, 0x61, 0x7a)) { bool regular= (irregularity (fnm) <= 6); if (regular) r << string ("regular=yes"); else r << string ("regular=no"); } }
/* * uncompress_file * * Uncompresses the stream fin into foutname * * Inputs: * - fin: the compressed input stream * - lfout: the uncompressed output stream * - co: compression parameters * * Output: * - return: 0 if ok, <0 if there was any problem * */ int uncompress_file (FILE *fin, lFILE *lfout, co_t *co) { codec_t *codec; int size; u_char compressed_buffer[MAX_COMPRESSED_LENGTH]; u_char buffer[MAXDATABUFFER]; struct pcap_pkthdr pkthdr; int result; /* create and initialize codec */ codec = create_codec(); /* write the new header */ if (pktd_write_header (lfileno(lfout), 40, DLT_RAW) < 0) { fprintf (stderr, "Error: cannot write header in file %s\n", foutname); return -1; } /* * every time you seek the rm_offset, you *must* initialize the codec (void)fseek (fin, co->rm_offset, SEEK_CUR); init_codec (codec); */ /* parse traces */ while (1) { /* read the trace length */ size = TCPDUMP_PACKET_HEADER_LENGTH_COMPRESSED; result = fread (compressed_buffer, 1, size, fin); if (result != size) { if ((result == 0) && (feof (fin))) { break; } fprintf (stderr, "Error: fread'ing file %s\n", finname); return -1; } size = (u_int8_t)(compressed_buffer[0]); /* look for escaped packets */ if (size == COMPRESSION_INIT_CODEC) { /* codec initialization requested */ init_codec (codec); continue; } else if (size == COMPRESSION_PADDING) { /* padding (empty) trace */ continue; } /* get the rest of the compressed packet */ result = fread (compressed_buffer+TCPDUMP_PACKET_HEADER_LENGTH_COMPRESSED, 1, size-TCPDUMP_PACKET_HEADER_LENGTH_COMPRESSED, fin); if (result != (size-TCPDUMP_PACKET_HEADER_LENGTH_COMPRESSED)) { if ((size == 0) && (feof (fin))) { break; } fprintf (stderr, "Error: freading file %s (%i)\n", finname, size); return -1; } /* decode the packet */ size = decode_trace (codec, compressed_buffer, &pkthdr, buffer); if (size < 0) { fprintf (stderr, "Error: decoding trace\n"); return -1; } /* write the uncompressed packet */ /* result = fwrite(buffer, 1, size, fout); */ result = lfwrite(lfout, buffer, size); if (result != size) { fprintf (stderr, "Error: fwriting file %s\n", foutname); return -1; } } return 0; }