BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
risortlib.c File Reference
#include "blitzlib.h"
#include "blitzobj.h"
#include "blitzexec.h"
#include <proto/utility.h>

Macros

#define __NOLIBBASE__
#define UTILITY_BASE_NAME   util
#define FIRSTITEM   ((WORD)offsetof(struct bb_listhead, used) - (WORD)sizeof(struct bb_listhead))
#define CURRITEM   ((WORD)offsetof(struct bb_listhead, current) - (WORD)sizeof(struct bb_listhead))
#define FIELD(item, off, type)

Functions

void _stringlistsort2 (void)
void _stringlistsort (void)
void _listbase (void)
void _stringlistsortitem2 (void)
void _stringlistsortitem (void)
void _stringsortdir (void)
void _sortpriorityoffset (void)
void risortlib_libinit (void)
void risortlib_libfinit (void)
static void libinit_c (void)
 init: open utility.library (any version).
static void libfinit_c (void)
 finit: close utility.library if init opened it.
static void sortpriorityoffset_c (UWORD off)
 SortPriorityOffset offset: the offset of a long priority in the items' data, compared before the string.
static void stringsortdir_c (UWORD dir)
 StringSortDir direction: the order of the string sorts.
static ULONG listbase_c (ULONG list)
 ListBase(list): the address of a list (the array argument).
static BB_BOOL dosort (UBYTE *list, UWORD size, WORD off, WORD hdr)
 The sort of StringSort/StringSortItem: a selection sort of the items' data from the start item on.
static BB_BOOL stringlistsort2_c (UBYTE *list, UWORD size)
 StringSort list,sizeof.type: sort the list from its first item by the string at offset 0 of the data (see dosort).
static BB_BOOL stringlistsort_c (UBYTE *list, UWORD size, UWORD off)
 StringSort list,sizeof.type,offset: sort the list from its first item by the string at offset of the data (see dosort).
static BB_BOOL stringlistsortitem2_c (UBYTE *list, UWORD size)
 StringSortItem list,sizeof.type: sort the list from its current item by the string at offset 0 of the data (see dosort).
static BB_BOOL stringlistsortitem_c (UBYTE *list, UWORD size, UWORD off)
 StringSortItem list,sizeof.type,offset: sort the list from its current item by the string at offset of the data (see dosort).

Variables

static struct Library * utillibbase
static const char utillibname [] = "utility.library"
static UWORD sortdir
static LONG priority
static WORD priorityoffset = -1
static struct bb_listitem * lpntr

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

◆ CURRITEM

#define CURRITEM   ((WORD)offsetof(struct bb_listhead, current) - (WORD)sizeof(struct bb_listhead))

◆ FIELD

#define FIELD ( item,
off,
type )
Value:
(*(type *)((UBYTE *)(item) + 8 + (off)))
UWORD type
Definition editlib.c:263
Definition menuslib.c:221

◆ FIRSTITEM

#define FIRSTITEM   ((WORD)offsetof(struct bb_listhead, used) - (WORD)sizeof(struct bb_listhead))

◆ UTILITY_BASE_NAME

#define UTILITY_BASE_NAME   util

Function Documentation

◆ _listbase()

void _listbase ( void )

◆ _sortpriorityoffset()

void _sortpriorityoffset ( void )

◆ _stringlistsort()

void _stringlistsort ( void )

◆ _stringlistsort2()

void _stringlistsort2 ( void )

◆ _stringlistsortitem()

void _stringlistsortitem ( void )

◆ _stringlistsortitem2()

void _stringlistsortitem2 ( void )

◆ _stringsortdir()

void _stringsortdir ( void )

◆ dosort()

BB_BOOL dosort ( UBYTE * list,
UWORD size,
WORD off,
WORD hdr )
static

The sort of StringSort/StringSortItem: a selection sort of the items' data from the start item on.

Each item is compared with all following ones (by the priority if SortPriorityOffset enabled it, then utility.library Stricmp, case-insensitive, in the StringSortDir order) and the data (size bytes) swapped where the order is wrong; after a swap the item in front is compared with its new string and priority (Fixed (#826)). The priority is read only when it is enabled (Fixed (#825)). A size of 0 returns BB_FALSE before anything is swapped (Fixed (#827): the original swapped 65536 bytes).

Parameters
listd0: the list ("lIsT" at -4)
sized1: sizeof.type, the bytes swapped
offd5: the offset of the string field (a string pointer)
hdrd6: the list header field of the start item (-28 the first, -32 the current item)
Returns
BB_TRUE when done; BB_FALSE without utility.library, for a size of 0, if it is no list, the start item is 0 or a string pointer is 0 (then stopped where it was)

◆ libfinit_c()

void libfinit_c ( void )
static

finit: close utility.library if init opened it.

Fixed (#824): the original closed it also when OpenLibrary failed (CloseLibrary(0), which exec 1.x does not catch).

◆ libinit_c()

void libinit_c ( void )
static

init: open utility.library (any version).

Without it every sort returns 0.

◆ listbase_c()

ULONG listbase_c ( ULONG list)
static

ListBase(list): the address of a list (the array argument).

Parameters
listd0: the list
Returns
d0: the same address, unchanged

◆ risortlib_libfinit()

void risortlib_libfinit ( void )

◆ risortlib_libinit()

void risortlib_libinit ( void )

◆ sortpriorityoffset_c()

void sortpriorityoffset_c ( UWORD off)
static

SortPriorityOffset offset: the offset of a long priority in the items' data, compared before the string.

Signed; the larger priority comes first, equal priorities are sorted by the string. -1 (the default, every negative value) disables it.

Parameters
offd0.w: the offset in the data, -1 = disabled

◆ stringlistsort2_c()

BB_BOOL stringlistsort2_c ( UBYTE * list,
UWORD size )
static

StringSort list,sizeof.type: sort the list from its first item by the string at offset 0 of the data (see dosort).

Parameters
listd0: the list
sized1.w: sizeof.type
Returns
d0: BB_TRUE when done, BB_FALSE on failure

◆ stringlistsort_c()

BB_BOOL stringlistsort_c ( UBYTE * list,
UWORD size,
UWORD off )
static

StringSort list,sizeof.type,offset: sort the list from its first item by the string at offset of the data (see dosort).

Parameters
listd0: the list
sized1.w: sizeof.type
offd2.w: the offset of the string field
Returns
d0: BB_TRUE when done, BB_FALSE on failure

◆ stringlistsortitem2_c()

BB_BOOL stringlistsortitem2_c ( UBYTE * list,
UWORD size )
static

StringSortItem list,sizeof.type: sort the list from its current item by the string at offset 0 of the data (see dosort).

Parameters
listd0: the list
sized1.w: sizeof.type
Returns
d0: BB_TRUE when done, BB_FALSE on failure

◆ stringlistsortitem_c()

BB_BOOL stringlistsortitem_c ( UBYTE * list,
UWORD size,
UWORD off )
static

StringSortItem list,sizeof.type,offset: sort the list from its current item by the string at offset of the data (see dosort).

Parameters
listd0: the list
sized1.w: sizeof.type
offd2.w: the offset of the string field
Returns
d0: BB_TRUE when done, BB_FALSE on failure

◆ stringsortdir_c()

void stringsortdir_c ( UWORD dir)
static

StringSortDir direction: the order of the string sorts.

Parameters
dird0.w: 0 ascending, any other value descending

Variable Documentation

◆ lpntr

struct bb_listitem* lpntr
static

◆ priority

LONG priority
static

◆ priorityoffset

WORD priorityoffset = -1
static

◆ sortdir

UWORD sortdir
static

◆ utillibbase

struct Library* utillibbase
static

◆ utillibname

const char utillibname[] = "utility.library"
static