pike.git / lib / modules / Standards.pmod / IIM.pmod

version» Context lines:

pike.git/lib/modules/Standards.pmod/IIM.pmod:7:      //! IPTC Information Interchange Model data   //! (aka "IPTC header") extraction.   //!   //! @url{http://www.iptc.org/IIM/@}      mapping(int:mapping(int:string)) fields =    ([    1: ([ // ENVELOPE RECORD    0: "model version", -  5: "destinatino", +  5: "destination",    20: "file format",    22: "file format version",    30: "service identifier",    40: "envelope number",    50: "product i.d.",    60: "envelope, priority",    70: "date sent",    80: "time sent",    90: "coded character set", -  100: "uno", +  100: "uno", // Unique Name of Object.    120: "arm Identifier",    122: "arm Version",    ]),    2: ([ // APPLICATION RECORD    0: "record version",    3: "object type reference",    4: "object attribut reference",    5: "object name",    7: "edit status",    8: "editorial update",    10: "urgency",    12: "subject reference", -  15: "category", -  20: "supplemental category", +  15: "category", // Obsoleted by "subject reference". +  20: "supplemental category", // Obsoleted by "subject reference".    22: "fixture identifier",    25: "keywords",    26: "content location code",    27: "content location name",    30: "release date",    35: "release time",    37: "expiration date",    38: "expiration time",    40: "special instructions",    42: "action advised",
pike.git/lib/modules/Standards.pmod/IIM.pmod:125:    mapping(string:string|array(string)) res = ([]);       // 0x0404 is IPTC IIM    array blocks = (data / "8BIM\4\4")[1..];    if (!sizeof(blocks)) {    werror("No 8BIM/IPTC IIM markers found in data\n");    return res;    }    //werror("blocks: %O\n", blocks);    foreach(blocks, string block) { -  //werror("block: %O\n", String.string2hex(block)); +  //werror("block: %x\n", block);    if (sizeof(block) < 6) {    werror("Malformed 8BIM block\n");    continue;    }       string block_type_2;    int block_length;    string info;       if (block[0]) {
pike.git/lib/modules/Standards.pmod/IIM.pmod:179:       if (segment_marker != '\x1c') {    if (segment_marker == '\x6f') {    // I have not found any documentation for this segment,    // but I use it to detect Nyhedstjeneste.    if ((record_set == 110) && (!id)) {    res->charset = ({ "iso-8859-1" });    continue;    }    } - #if 1 + #if 0    werror("Unknown segment marker: 0x%02x\n"    "record_set: %d\n"    "id: %d\n"    "data: %O\n", segment_marker, record_set, id, data);   #endif /* 1 */    break;    }       if (!has_value(indices(fields), record_set)) {    werror("Unknown record set marker: %O\n", record_set);    break;    }       //werror("%3d: ", id);    //werror("%O\n", data); -  //werror("info: %O\n", String.string2hex(info)); +  //werror("info: %x\n", info);    string label =    fields[record_set][id] ||    (string)record_set + ":" + (string)id;       if (label == "coded character set") {    string charset = ([    "\e%/@": "UTF-16", // ISO-IR 162 (NB: Actually UCS-2 level 1)    "\e%/A": "UTF-32", // ISO-IR 163 (NB: Actually UCS-4 level 1)    "\e%/B": "ISO-8859-1",// ISO-IR 125 (NB: Actually binary)    "\e%/C": "UTF-16", // ISO-IR 174 (NB: Actually UCS-2 level 2)
pike.git/lib/modules/Standards.pmod/IIM.pmod:293:    int bytes = -1;    // Note: We use the split iterator by hand to make sure '\r' is    // valid as a line terminator.    foreach(String.SplitIterator(marker, (<'\r','\n'>), 1,    fd->read_function(8192));    int lineno; string line) {    if (line[0] != '%') continue;    if (bytes < 0) sscanf(line, "%%BeginPhotoshop:%*[ ]%d", bytes);    else if (has_prefix(line, "%EndPhotoshop")) {    break; -  } else if (has_prefix(line, "% ")) { - #if constant(String.hex2string) -  photoshop_data += String.hex2string(line[2..]); - #else -  photoshop_data += Crypto.hex_to_string(line[2..]); - #endif +  } +  // Let hex2string swollow "%" and possible " ". +  photoshop_data += String.hex2string(line);    if (sizeof(photoshop_data) >= bytes) break; -  } else { - #if constant(String.hex2string) -  photoshop_data += String.hex2string(line[1..]); - #else -  photoshop_data += Crypto.hex_to_string(line[1..]); - #endif -  if (sizeof(photoshop_data) >= bytes) break; +     } -  } +     } else if (marker == "\xff\xd8") {    do {    string app = fd->read(2);    if (sizeof(app) != 2)    break;    string length_s = fd->read(2);    int length;    if (sizeof(length_s) == 2)    length = short_value(length_s);    else
pike.git/lib/modules/Standards.pmod/IIM.pmod:401:       // Remap to standard names:    charset = ([    "cp_1252":"windows1252",    "cp_2":"macintosh",    "cp_utf8": "utf8",    ])[charset] || charset;    }    //werror("Charset: %O\n", charset);    res->charset = ({ charset }); -  object decoder = Locale.Charset.decoder(charset); +  object decoder = Charset.decoder(charset);    foreach(res; string key; array(string) vals) {    res[key] = map(vals,    lambda(string val, object decoder) {    return decoder->feed(val)->drain();    }, decoder);    }    }       return res;   }