Changeset 7 in code for trunk/lib


Ignore:
Timestamp:
Jun 18, 2022, 8:45:45 PM (3 years ago)
Author:
fox
Message:

Implement author & topic filter for txt pull

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/header_pack.ml

    r3 r7  
    6969        | _ -> prerr_endline ("Invalid record pattern"); false
    7070
     71let numof_texts pack = List.length (Msgpck.to_list pack.texts)
     72
     73let iteri fn pack =
     74        let of_pck i = function Msgpck.List (id::time::title::authors::topics::[]) ->
     75                let t = match time with Msgpck.Int i -> Int32.of_int i | Msgpck.Uint32 i -> i
     76                        | x -> Msgpck.to_uint32 x in
     77                let id = to_id id in
     78                let title = Msgpck.to_string title in
     79                let topics = to_str_list topics in
     80                let authors = to_str_list authors in
     81                fn i id t title authors topics
     82        | _  -> prerr_endline ("\n\nInvalid record structure\n\n")
     83        in List.iteri of_pck (Msgpck.to_list pack.texts);
    7184
    7285(*let pack_filename ?(filename="index.pck") archive =*)
Note: See TracChangeset for help on using the changeset viewer.