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

fw_release.h says what is read and how strictly. More...

#include "fw_release.h"
#include <stdio.h>
#include <string.h>

Enumerations

enum  {
  SC_TOP = 0 , SC_FIRST , SC_NEXT , SC_ELEM ,
  SC_KEY0 , SC_KEY , SC_KSTR , SC_KESC ,
  SC_COLON , SC_VALUE , SC_TSTR , SC_VSTR ,
  SC_VESC , SC_SCALAR , SC_AFTER , SC_DEEP ,
  SC_DSTR , SC_DESC
}
enum  { WANT_OTHER = 0 , WANT_TAG , WANT_DRAFT }

Functions

const char * fw_rel_err_str (fw_rel_err_t e)
static bool url_bytes (const char *s, size_t n)
bool fw_release_parse_version (const char *s, size_t n, fw_version_t *out)
fw_rel_err_t fw_release_parse_tag (const char *loc, size_t n, bool cut, fw_version_t *out)
fw_rel_status_t fw_release_status (int status)
fw_rel_err_t fw_release_redirect (const char *loc, size_t n, bool cut, unsigned hops)
fw_rel_err_t fw_release_length (int64_t length, bool chunked, uint32_t cap)
static int hex (char ch)
static bool name_char (char ch)
fw_rel_err_t fw_release_parse_sums (const char *text, size_t n, const char *name, uint8_t out[FW_SHA256_BYTES])
static bool json_space (uint8_t ch)
static bool json_scalar (uint8_t ch)
void fw_release_scan_init (fw_rel_scan_t *s)
static void scan_end (fw_rel_scan_t *s, fw_rel_err_t e)
static bool scan_open (fw_rel_scan_t *s, bool array)
static bool scan_close (fw_rel_scan_t *s, bool array)
static void scan_finish (fw_rel_scan_t *s)
static void scan_begin_release (fw_rel_scan_t *s)
static void scan_end_release (fw_rel_scan_t *s)
 A release's '}': each needs its tag; a draft's is passed over.
static void scan_key (fw_rel_scan_t *s)
static void scan_tag (fw_rel_scan_t *s)
static void scan_draft (fw_rel_scan_t *s)
static void scan_value (fw_rel_scan_t *s, uint8_t ch)
static void scan_object (fw_rel_scan_t *s, uint8_t ch)
static void scan_deep (fw_rel_scan_t *s, uint8_t ch)
static void scan_array (fw_rel_scan_t *s, uint8_t ch)
static void scan_byte (fw_rel_scan_t *s, uint8_t ch)
bool fw_release_scan_feed (fw_rel_scan_t *s, const uint8_t *d, size_t n)
fw_rel_err_t fw_release_scan_end (const fw_rel_scan_t *s, fw_version_t *out)
bool fw_release_scan_line (const fw_rel_scan_t *s, fw_version_t *out)
 The highest no-draft release of the panel's release line among those the scan read.
bool fw_release_line_capped (void)
 Whether the panel's release line is capped at FW_REL_LINE_MAJOR.FW_REL_LINE_MINOR.
void fw_release_set_line_capped (bool capped)
 Caps the panel's release line at FW_REL_LINE_MAJOR.FW_REL_LINE_MINOR, or lifts the cap. The panel keeps FW_REL_LINE_CAPPED; the host suite holds both lines.
bool fw_release_in_line (fw_version_t v)
 Whether a version is of the panel's release line.
bool fw_release_offered (fw_version_t found, fw_version_t running, bool running_ok)
 Whether a release is offered to the panel.
void fw_release_version_text (fw_version_t v, char out[FW_REL_VER_TEXT])
void fw_release_image_name (fw_version_t v, char out[FW_REL_NAME_MAX])
 The file name of a release's panel image.
bool fw_release_url (fw_version_t v, const char *file, char *out, size_t cap)

Variables

const char *const FW_REL_HOSTS []
static bool s_line_capped = FW_REL_LINE_CAPPED
 Whether the release line is capped; fw_release_line_capped().

Detailed Description

fw_release.h says what is read and how strictly.

SPDX-License-Identifier: MIT

Function Documentation

◆ fw_rel_err_str()

const char * fw_rel_err_str ( fw_rel_err_t e)

The English name of e, for the console.

◆ fw_release_image_name()

void fw_release_image_name ( fw_version_t v,
char out[FW_REL_NAME_MAX] )

The file name of a release's panel image.

Writes "rcbench-panel-p4-v0.20.0.bin" for version 0.20.0. The longest name, for 65535.65535.65535, fills FW_REL_NAME_MAX bytes with its terminator.

Parameters
vVersion of the release.
outReceives the name, terminated.

◆ fw_release_in_line()

bool fw_release_in_line ( fw_version_t v)

Whether a version is of the panel's release line.

Parameters
vthe version
Returns
true for every version while the line is not capped (fw_release_line_capped()); once capped, true for MAJOR FW_REL_LINE_MAJOR and MINOR FW_REL_LINE_MINOR, any PATCH

◆ fw_release_length()

fw_rel_err_t fw_release_length ( int64_t length,
bool chunked,
uint32_t cap )

A body's announced size: length as the client read Content-Length, -1 for none, and chunked. FW_REL_OK, or NO_LENGTH, EMPTY or TOO_BIG against cap bytes.

◆ fw_release_line_capped()

bool fw_release_line_capped ( void )

Whether the panel's release line is capped at FW_REL_LINE_MAJOR.FW_REL_LINE_MINOR.

Returns
FW_REL_LINE_CAPPED until fw_release_set_line_capped() sets it

◆ fw_release_offered()

bool fw_release_offered ( fw_version_t found,
fw_version_t running,
bool running_ok )

Whether a release is offered to the panel.

Only one of the panel's release line (fw_release_in_line()) and strictly newer than the running build. Each part counts as a number: 0.22.10 is newer than 0.22.9.

Parameters
foundthe release a check found
runningthe version the panel runs
running_okfalse when the running version did not parse
Returns
true when found is offered; false always when running_ok is false

◆ fw_release_parse_sums()

fw_rel_err_t fw_release_parse_sums ( const char * text,
size_t n,
const char * name,
uint8_t out[FW_SHA256_BYTES] )

The SHA-256 SHA256SUMS gives for name: text of n bytes, not terminated. FW_REL_OK and out, or LONG, SUMS_BAD, SUMS_NONE or SUMS_TWICE.

◆ fw_release_parse_tag()

fw_rel_err_t fw_release_parse_tag ( const char * loc,
size_t n,
bool cut,
fw_version_t * out )

The release a redirect from FW_REL_LATEST_URL names: loc of n bytes, not terminated; cut when the header was longer than the buffer that took it. FW_REL_OK and out, or MISSING, LONG, CHAR, PLACE or VERSION.

◆ fw_release_parse_version()

bool fw_release_parse_version ( const char * s,
size_t n,
fw_version_t * out )

"MAJOR.MINOR.PATCH" in exactly n bytes of s, by the tag's rule: digits only, at most 5 a part, each part 0 to 65535, no leading zero.

◆ fw_release_redirect()

fw_rel_err_t fw_release_redirect ( const char * loc,
size_t n,
bool cut,
unsigned hops )

Whether a download may follow a redirect to loc (n bytes, cut as above) after hops redirects already followed. FW_REL_OK, or MISSING, LONG, CHAR, PLACE (not https://, or no path), HOST or HOPS.

◆ fw_release_scan_end()

fw_rel_err_t fw_release_scan_end ( const fw_rel_scan_t * s,
fw_version_t * out )

The scan's result once the answer is whole: FW_REL_OK and the highest no-draft release in out, or TAG_NONE (a release without a tag, none but drafts, or the answer ended before the array or the FW_REL_API_RELEASES-th release did), TAG_LONG, TAG_FORM, SCAN_LONG or VERSION.

◆ fw_release_scan_feed()

bool fw_release_scan_feed ( fw_rel_scan_t * s,
const uint8_t * d,
size_t n )

n more bytes of the answer. True once the scan has ended: the tag read, or the answer refused; bytes fed after that are not looked at.

◆ fw_release_scan_line()

bool fw_release_scan_line ( const fw_rel_scan_t * s,
fw_version_t * out )

The highest no-draft release of the panel's release line among those the scan read.

Parameters
sthe scan, ended; NULL reads as none
outthe release, when there is one; untouched otherwise; may be NULL
Returns
true once the scan ended with FW_REL_OK and read a no-draft release of the line; false otherwise

◆ fw_release_set_line_capped()

void fw_release_set_line_capped ( bool capped)

Caps the panel's release line at FW_REL_LINE_MAJOR.FW_REL_LINE_MINOR, or lifts the cap. The panel keeps FW_REL_LINE_CAPPED; the host suite holds both lines.

Parameters
cappedtrue for the ESP32-S3 panel's 0.22 line, false for every release

◆ fw_release_url()

bool fw_release_url ( fw_version_t v,
const char * file,
char * out,
size_t cap )

The download URL of file in release v into out of cap bytes; false when it does not fit.

◆ fw_release_version_text()

void fw_release_version_text ( fw_version_t v,
char out[FW_REL_VER_TEXT] )

"0.20.0" into out of FW_REL_VER_TEXT bytes.

◆ scan_end_release()

void scan_end_release ( fw_rel_scan_t * s)
static

A release's '}': each needs its tag; a draft's is passed over.

A no-draft release raises the highest so far and, when it is of the panel's release line, the line's highest so far.

Parameters
sthe scan

Variable Documentation

◆ FW_REL_HOSTS

const char* const FW_REL_HOSTS[]
Initial value:
= {
"github.com",
"release-assets.githubusercontent.com",
"objects.githubusercontent.com",
NULL,
}

The hosts a download follows, NULL-terminated.