The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
index.c File Reference

librat: the package index of the repository (index.conf). More...

#include "internal.h"
#include <stdlib.h>
#include <string.h>

Macros

#define INDEX_PACKAGES_MAX   65536
 the most packages in an index
#define PACKAGE_SIZE_MAX   (UINT64_C(1) << 40)
 the largest package file that an index can give

Functions

int rat_index_parse (const char *text, const char *arch, rat_index_t *index, rat_error_t *err)
 read the text of index.conf and check every field.
void rat_remote_clear (rat_remote_t *remote)
 release the strings of one package of an index
void rat_index_free (rat_index_t *index)
 release the memory of an index (not the struct itself).
const rat_remote_t * rat_index_find (const rat_index_t *index, const char *name)
 a package of the index by name.
bool rat_remote_matches (const rat_remote_t *remote, const char *word)
 true if word is in the name or the description of the package, without a difference between capitals and small letters.
int rat_index_similar (const rat_index_t *index, const char *name, const char **names_out, int max)
 the names in the index that are near a name that it does not have, for a "did you mean" message: one or two letters different, or a name that contains it.

Detailed Description

librat: the package index of the repository (index.conf).

the index is a libconf file. the keys before the first section are about the whole index; each section is one package, with the fields of .RATINFO and the file, its size and its SHA-256:

generated = 2026-12-02
sequence = 7
arch = i686

[lua]
name = lua
version = 5.4.9
release = 1
arch = i686
file = lua-5.4.9-1-i686.rat
size = 119010
sha256 = 3c9e...
installed_size = 223507
description = The Lua programming language interpreter
licence = MIT

the parser checks every field, because the index decides which file rat downloads and which SHA-256 it must have.

Macro Definition Documentation

◆ INDEX_PACKAGES_MAX

#define INDEX_PACKAGES_MAX   65536

the most packages in an index

◆ PACKAGE_SIZE_MAX

#define PACKAGE_SIZE_MAX   (UINT64_C(1) << 40)

the largest package file that an index can give

Function Documentation

◆ rat_index_parse()

int rat_index_parse ( const char * text,
const char * arch,
rat_index_t * index,
rat_error_t * err )

read the text of index.conf and check every field.

the signature must be checked before.

Parameters
archthe architecture that the index must be for.
Returns
0, or -1.

◆ rat_remote_clear()

void rat_remote_clear ( rat_remote_t * remote)

release the strings of one package of an index

◆ rat_index_free()

void rat_index_free ( rat_index_t * index)

release the memory of an index (not the struct itself).

◆ rat_index_find()

const rat_remote_t * rat_index_find ( const rat_index_t * index,
const char * name )

a package of the index by name.

Returns
the package, or NULL if the index does not have it.

◆ rat_remote_matches()

bool rat_remote_matches ( const rat_remote_t * remote,
const char * word )

true if word is in the name or the description of the package, without a difference between capitals and small letters.

◆ rat_index_similar()

int rat_index_similar ( const rat_index_t * index,
const char * name,
const char ** names_out,
int max )

the names in the index that are near a name that it does not have, for a "did you mean" message: one or two letters different, or a name that contains it.

Parameters
names_outgets pointers into the index.
Returns
the number of names, at most max.