コード例 #1
0
ファイル: filter.c プロジェクト: rubicks/rlwrap
char *pass_through_filter(int tag, const char *buffer) {
    char *filtered;
    DPRINTF3(DEBUG_FILTERING, "to filter (%s, %d bytes) %s", tag2description(tag), (int) strlen(buffer), mangle_string_for_debug_log(buffer, MANGLE_LENGTH));
    if (filter_pid ==0)
        return mysavestring(buffer);
    write_to_filter((expected_tag = tag), buffer);
    filtered = read_from_filter(tag);
    DPRINTF2(DEBUG_FILTERING, "from filter (%d bytes) %s", (int) strlen(filtered), mangle_string_for_debug_log(filtered, MANGLE_LENGTH));
    return filtered;
}
コード例 #2
0
ファイル: filter.c プロジェクト: crashcoredump/rlwrap
static char *read_from_filter(int tag) {
  uint8_t  tag8;
  DEBUG_RANDOM_SLEEP;
  assert (!out_of_band(tag));  
  while (read_patiently2(filter_output_fd, &tag8, sizeof(uint8_t), 1000, "from filter"), out_of_band(tag8))
    handle_out_of_band(tag8, read_tagless());
         
  if (tag8 != tag)
    myerror(FATAL|USE_ERRNO, "Tag mismatch, expected %s from filter, but got %s", tag2description(tag), tag2description(tag8));
  
  return read_tagless();
}