BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
filereq_core.c File Reference
#include "filereq_env.h"
#include "filereq_core.h"
#include <dos/dos.h>
#include <dos/dosextens.h>
#include <intuition/intuition.h>
#include <intuition/screens.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <proto/graphics.h>

Data Structures

struct  fq_params
struct  fq_border
struct  fq_line
struct  fq_data

Macros

#define FQ_SWAP(r)
#define FQ_LINES   64
#define FQ_MAXHEIGHT   (FQ_LINES * 8 + 85)
#define FQ_LDFLAGS   (LDF_READ | LDF_VOLUMES | LDF_ASSIGNS | LDF_DEVICES)
#define FQ_PATHMAX   159
#define FQ_FILEMAX   63
#define __NOLIBBASE__
#define DOS_BASE_NAME   fq.dosbase
#define INTUITION_BASE_NAME   fq.intbase
#define GRAPHICS_BASE_NAME   fq.gfxbase
#define W(p, o)
#define L(p, o)
#define B(p, o)
#define P(p, o)
#define FQ_BUTTON(next, x, w, flags, frame, text, id)
#define FQ_BORDER(f, n, l, t, fp, bp, next, ...)
#define FQ_BUTTONFRAME(f, w)
#define FQ_SPC10   " "
#define FQ_SPC80
#define FQ_LINE(n)
#define FQ_LINES8(n)

Functions

static void refresh (struct Gadget *gad, LONG n)
static ULONG length (const UBYTE *s)
static ULONG nodesize (const UBYTE *name)
static void say (const UBYTE *msg)
static int take (UBYTE *dst, const UBYTE *src, ULONG max)
static void freelist (void)
static UWORD addentry (UBYTE type, const UBYTE *name)
static void fill (void)
static void refreshlist (void)
static void refreshprop (void)
static void setpot (void)
static void propbody (void)
static void listrefresh (void)
static void addvisible (UBYTE type, const UBYTE *name)
static void redraw2 (void)
static ULONG calctop (void)
static void scrollpot (void)
static void layout (UWORD d1, UWORD d2)
static void redraw (void)
static ULONG takemsg (struct IntuiMessage *m)
static ULONG waitmsg (void)
static ULONG pollmsg (void)
static int currentpath (struct FileInfoBlock *fib)
static void setheight (void)
static void closelibs (void)
ULONG fq_request (void)
 Run the file requester with the parameters in fq_args.
void fq_finit (void)
 The end of the program: undo the requester's CD (fixed #157).

Variables

static struct fq_data fq
ULONG fq_args [4]
 The parameters of fq_request(), set before the call.
static APTR oldwinptr
static struct Process * task
static UBYTE * firstvis
static UWORD code
static BPTR startdir
static BPTR cdlock
ULONG fq_maxlen [2] = { 0xffffffffUL, 0xffffffffUL }
 The most characters (without the 0) the caller's path and file buffers take, set before the call (fixed #1042).
static ULONG pathmax
static ULONG filemax
static const UBYTE * notice
static UBYTE * stitle
static const UBYTE msg_path [] = "Path too long"
static const UBYTE msg_name [] = "Name too long"

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

◆ B

#define B ( p,
o )
Value:
(*(UBYTE *)((UBYTE *)(p) + (o)))

◆ DOS_BASE_NAME

#define DOS_BASE_NAME   fq.dosbase

◆ FQ_BORDER

#define FQ_BORDER ( f,
n,
l,
t,
fp,
bp,
next,
... )
Value:
{ { (l), (t), (fp), (bp), JAM2, 3, fq.f[n].xy, (next) }, \
{ __VA_ARGS__ } }
ULONG WORD UWORD UWORD border ULONG ULONG struct bb_bitmap *dst void UWORD n
Definition 2dlib.c:2498
static struct fq_data fq
Definition filereq_core.c:237
struct portnode * next
Definition utillib.c:115

◆ FQ_BUTTON

#define FQ_BUTTON ( next,
x,
w,
flags,
frame,
text,
id )
Value:
{ (next), (x), -16, (w), 12, GFLG_RELBOTTOM | (flags), GACT_RELVERIFY, \
GTYP_BOOLGADGET, &(frame)[0].b, NULL, &(text), 0, NULL, (id), NULL }
ULONG x
Definition 2dlib.c:2491
UBYTE flags[2]
Definition 2dlib.c:297
struct TagItem w
Definition asllib.c:192
Definition basictest_read.c:318

◆ FQ_BUTTONFRAME

#define FQ_BUTTONFRAME ( f,
w )
Value:
{ FQ_BORDER(f, 0, 0, 0, 1, 2, &fq.f[1].b, (w), 0, 0, 0, 0, 11), \
FQ_BORDER(f, 1, 0, 0, 2, 1, NULL, (w), 1, (w), 11, 1, 11) }
#define FQ_BORDER(f, n, l, t, fp, bp, next,...)
Definition filereq_core.c:1131

◆ FQ_FILEMAX

#define FQ_FILEMAX   63

◆ FQ_LDFLAGS

#define FQ_LDFLAGS   (LDF_READ | LDF_VOLUMES | LDF_ASSIGNS | LDF_DEVICES)

◆ FQ_LINE

#define FQ_LINE ( n)
Value:
{ { NULL, 20, 8 * ((n) + 1), 256, 8, 0, GACT_RELVERIFY, \
GTYP_BOOLGADGET, NULL, NULL, &fq.line[n].itext, 0, NULL, 0, NULL }, \
{ 1, 0, JAM2, 0, 0, NULL, fq.line[n].text, NULL }, \
#define FQ_SPC80
Definition filereq_core.c:1141

◆ FQ_LINES

#define FQ_LINES   64

◆ FQ_LINES8

#define FQ_LINES8 ( n)
Value:
FQ_LINE((n) + 0), FQ_LINE((n) + 1), FQ_LINE((n) + 2), FQ_LINE((n) + 3), \
FQ_LINE((n) + 4), FQ_LINE((n) + 5), FQ_LINE((n) + 6), FQ_LINE((n) + 7)
#define FQ_LINE(n)
Definition filereq_core.c:1145

◆ FQ_MAXHEIGHT

#define FQ_MAXHEIGHT   (FQ_LINES * 8 + 85)

◆ FQ_PATHMAX

#define FQ_PATHMAX   159

◆ FQ_SPC10

#define FQ_SPC10   " "

◆ FQ_SPC80

#define FQ_SPC80
Value:
#define FQ_SPC10
Definition filereq_core.c:1140

◆ FQ_SWAP

#define FQ_SWAP ( r)
Value:
((ULONG)(r) << 16 | (ULONG)(r) >> 16) /* SWAP */

◆ GRAPHICS_BASE_NAME

#define GRAPHICS_BASE_NAME   fq.gfxbase

◆ INTUITION_BASE_NAME

#define INTUITION_BASE_NAME   fq.intbase

◆ L

#define L ( p,
o )
Value:
(*(ULONG *)((UBYTE *)(p) + (o)))

◆ P

#define P ( p,
o )
Value:
(*(UBYTE **)((UBYTE *)(p) + (o)))

◆ W

#define W ( p,
o )
Value:
(*(WORD *)((UBYTE *)(p) + (o)))

Function Documentation

◆ addentry()

UWORD addentry ( UBYTE type,
const UBYTE * name )
static

◆ addvisible()

void addvisible ( UBYTE type,
const UBYTE * name )
static

◆ calctop()

ULONG calctop ( void )
static

◆ closelibs()

void closelibs ( void )
static

◆ currentpath()

int currentpath ( struct FileInfoBlock * fib)
static

◆ fill()

void fill ( void )
static

◆ fq_finit()

void fq_finit ( void )

The end of the program: undo the requester's CD (fixed #157).

The gadget "CD" makes the path the current directory of the process and keeps the directory before the first CD. fq_finit makes that directory current again and unlocks the requester's own lock (not a lock the program made current itself since); nothing when CD was not used. Called once at the end: freqlib's finit, the end of TED. Opens and closes dos.library itself.

◆ fq_request()

ULONG fq_request ( void )

Run the file requester with the parameters in fq_args.

Original entry: code+4 ($CA in freqlib), the parameter block in a0. Opens dos, intuition and graphics at every call and closes them at its end (fixed #154); the other fixed original bugs are listed in filereq_core.c.

Returns
the address of the result "path/file" (inside the data block), or 0 (cancel, close gadget, no memory/window; DIFF: the original returns an uninitialized long when memory, a library or the window cannot be opened)

◆ freelist()

void freelist ( void )
static

◆ layout()

void layout ( UWORD d1,
UWORD d2 )
static

◆ length()

ULONG length ( const UBYTE * s)
static

◆ listrefresh()

void listrefresh ( void )
static

◆ nodesize()

ULONG nodesize ( const UBYTE * name)
static

◆ pollmsg()

ULONG pollmsg ( void )
static

◆ propbody()

void propbody ( void )
static

◆ redraw()

void redraw ( void )
static

◆ redraw2()

void redraw2 ( void )
static

◆ refresh()

void refresh ( struct Gadget * gad,
LONG n )
static

◆ refreshlist()

void refreshlist ( void )
static

◆ refreshprop()

void refreshprop ( void )
static

◆ say()

void say ( const UBYTE * msg)
static

◆ scrollpot()

void scrollpot ( void )
static

◆ setheight()

void setheight ( void )
static

◆ setpot()

void setpot ( void )
static

◆ take()

int take ( UBYTE * dst,
const UBYTE * src,
ULONG max )
static

◆ takemsg()

ULONG takemsg ( struct IntuiMessage * m)
static

◆ waitmsg()

ULONG waitmsg ( void )
static

Variable Documentation

◆ cdlock

BPTR cdlock
static

◆ code

UWORD code
static

◆ filemax

ULONG filemax
static

◆ firstvis

UBYTE* firstvis
static

◆ fq

struct fq_data fq
static

◆ fq_args

ULONG fq_args[4]

The parameters of fq_request(), set before the call.

The same order as the 4-long reqstruct of TED and the parameter block of freqlib:

  • [0] path buffer (160 bytes, in/out: the start path; on OK the path chosen; see fq_maxlen)
  • [1] file buffer (64 bytes, in/out: the start file; on OK the file chosen; see fq_maxlen)
  • [2] window title
  • [3] screen (0 = Workbench)

◆ fq_maxlen

ULONG fq_maxlen[2] = { 0xffffffffUL, 0xffffffffUL }

The most characters (without the 0) the caller's path and file buffers take, set before the call (fixed #1042).

  • [0] path buffer
  • [1] file buffer

The requester takes the smaller of this and its own limit (159 for the path, 63 for the file: its buffers of 160 and 64 bytes). A start string, a click or a path that does not fit is refused with a notice in the screen title of the window. Initially no limit of the caller (0xFFFFFFFF): TED's buffers (192 and 64 bytes) hold what the requester's own do. freqlib sets the MaxLen of Pathname$ and Filename$ at every call.

◆ msg_name

const UBYTE msg_name[] = "Name too long"
static

◆ msg_path

const UBYTE msg_path[] = "Path too long"
static

◆ notice

const UBYTE* notice
static

◆ oldwinptr

APTR oldwinptr
static

◆ pathmax

ULONG pathmax
static

◆ startdir

BPTR startdir
static

◆ stitle

UBYTE* stitle
static

◆ task

struct Process* task
static