rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
log_select.c File Reference

Keeping the entries a bounded list can show, and ordering them for it: LOGS' order over the file manager's page keeping (fm_select.h). More...

#include "log_select.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "log_name.h"

Functions

static int by_rank (const void *a, const void *b)
 The pages' order: log_name_rank() of two entries' names.
static int by_display_order (const void *a, const void *b)
 The order the browse list draws: directories first, then the pages' own order.
int log_select_keep (log_viewer_file_t *set, int count, int capacity, const log_viewer_file_t *cand)
 Offer cand to a set in log_name_rank() order.
void log_select_page_begin (log_select_page_t *sel, log_viewer_file_t *set, int capacity, const log_viewer_page_t *page)
 Start choosing page into set.
void log_select_page_offer (log_select_page_t *sel, const log_viewer_file_t *cand)
 Offer one directory entry; it is copied if it is kept.
int log_select_page_end (log_select_page_t *sel, log_viewer_page_t *page)
 End the walk: put the set into the order the browse list draws (log_select_sort()) and write page's ahead and held.
void log_select_sort (log_viewer_file_t *set, int count)
 Put count entries into the order the browse list draws them in: directories first, then log_name_rank() order – runs newest first, then the other names, case-insensitively.
static bool is_csv (const char *name)
 Whether name ends in ".csv", case folded, after a base name.
bool log_select_lists (const char *name)
 Whether the list holds a file of this name: a CSV file, or a report.

Detailed Description

Keeping the entries a bounded list can show, and ordering them for it: LOGS' order over the file manager's page keeping (fm_select.h).

SPDX-License-Identifier: MIT

Function Documentation

◆ by_display_order()

int by_display_order ( const void * a,
const void * b )
static

The order the browse list draws: directories first, then the pages' own order.

Parameters
aa log_viewer_file_t
ba log_viewer_file_t
Returns
negative when a is drawn above b

◆ by_rank()

int by_rank ( const void * a,
const void * b )
static

The pages' order: log_name_rank() of two entries' names.

Parameters
aa log_viewer_file_t
ba log_viewer_file_t
Returns
negative when a ranks ahead, positive when b does

◆ is_csv()

bool is_csv ( const char * name)
static

Whether name ends in ".csv", case folded, after a base name.

Parameters
namea file's name
Returns
true for "RUN.CSV" and "sweep.csv", false for ".csv" alone

◆ log_select_keep()

int log_select_keep ( log_viewer_file_t * set,
int count,
int capacity,
const log_viewer_file_t * cand )

Offer cand to a set in log_name_rank() order.

The count is the same one that came back from the last call, so a set never drifts past its capacity. A candidate that ranks below a full set is dropped and the count does not move.

Parameters
setthe entries, in log_name_rank() order
countentries in set
capacityroom in set
candthe entry offered; copied when it is kept
Returns
the count after the offer

◆ log_select_lists()

bool log_select_lists ( const char * name)

Whether the list holds a file of this name: a CSV file, or a report.

A report is a name log_report_number() takes, the same rule FILES labels a report by (fm_kind_of()): ATESTnnn.TXT beside its ATESTnnn.CSV or without it, LIMITnnn.TXT, which a LIMIT RUN writes with no CSV, and the SERVOnnn.TXT of firmware 0.21.0 and older. A run and its report are two rows, the run first (log_name_rank()); OPEN reads the CSV into the import and the report as text, and DELETE on the run takes its report along. Any other ".TXT" is not listed. One walk of a folder decides it name by name.

Parameters
namea file's name in the folder; NULL is none
Returns
true for a name ending in ".csv", any case, after a base name, and for a report; false for every other name and for NULL

◆ log_select_page_begin()

void log_select_page_begin ( log_select_page_t * sel,
log_viewer_file_t * set,
int capacity,
const log_viewer_page_t * page )

Start choosing page into set.

The key is copied, so page may change while the walk runs.

Parameters
selthe walk's state
setroom for capacity entries
capacityentries set takes
pagewhich page; NULL for the first

◆ log_select_page_end()

int log_select_page_end ( log_select_page_t * sel,
log_viewer_page_t * page )

End the walk: put the set into the order the browse list draws (log_select_sort()) and write page's ahead and held.

Parameters
selthe walk's state
pagetakes ahead and held; may be NULL
Returns
the entries held

◆ log_select_page_offer()

void log_select_page_offer ( log_select_page_t * sel,
const log_viewer_file_t * cand )

Offer one directory entry; it is copied if it is kept.

Parameters
selthe walk's state
candthe entry

◆ log_select_sort()

void log_select_sort ( log_viewer_file_t * set,
int count )

Put count entries into the order the browse list draws them in: directories first, then log_name_rank() order – runs newest first, then the other names, case-insensitively.

Parameters
setthe entries
counthow many