home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of A1200
/
World_Of_A1200.iso
/
programs
/
monitors
/
rsys
/
rsyssrc.lha
/
RSysDisplays.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-09-19
|
14KB
|
507 lines
/*
***************************************************************************
*
* Datei:
* RSysDisplays.c
*
* Inhalt:
*
* --- Globale Routinen ---
*
* int DisplayDiskInfo ( char *filename , int with_tree );
* int DisplayFileInfo ( char *filename );
* int DisplayFontInfo ( struct objectid *obj );
* int DisplayLibraryInfo ( struct objectid *obj );
* int DisplayLockInfo ( struct objectid *obj );
* int DisplayPortInfo ( struct objectid *obj );
* int DisplayScreenInfo ( struct objectid *obj );
* int DisplayTaskInfo ( struct objectid *obj );
* int DisplayWindowInfo ( struct objectid *obj );
* void DisplayDirectoryInfo ( char *filename );
* void DisplayResourceInfo ( struct objectid *obj );
* void DisplaySoftDevInfo ( struct objectid *obj );
*
* --- Lokale Routinen ---
*
* static char *makelibflags ( struct Library *lib , char *flags );
* static void savecpyid ( char *IDStr , struct Library *lib );
*
* Bemerkungen:
* Funktionen zur Anzeige weiterer Informationen zu ausgewählten
* Objekten.
*
* Erstellungsdatum:
* 07-Jul-93 Rolf Böhme
*
* Änderungen:
* 07-Jul-93 Rolf Böhme Erstellung
*
***************************************************************************
*/
#include "RSys.h"
/*
* DisplayDiskInfo() zeigt eine Info über ein Volume an.
* Auf Wunsch kann die Verzeichnisstruktur angezeigt
* werden
*/
int
DisplayDiskInfo(char *filename, int with_tree)
{
int sel;
long free = 0L,used = 0L,percentused = 0L;
char state[5],type[6];
DPOS;
FreeBytes(filename, &free, &used, &percentused, state, type);
sel = MyEasyRequest(SysWnd, (UBYTE *) NAME " - Volume/Device Info",
(UBYTE *) ((with_tree) ? "Tree|Continue" : "Continue"),
(UBYTE *) "Name : %-20.20s\n"
"Size : %7ld KBytes\n"
"Free : %7ld KBytes\n"
"Used : %7ld KBytes\n"
"%% used : %3ld%%\n"
"State : %s\n"
"Type : %s",
filename,
free + used,
free, used, percentused,
state, type);
return sel;
}
/*
* DisplayFileInfo() zeigt Infos über eine Datei an.
* Handelt es sich um ein Executable, kann eine Hunk-Liste
* erzeugt werden lassen
*/
int
DisplayFileInfo(char *filename)
{
char path[MAXFULLNAME],
*help,
file[MAXFULLNAME];
int sel,
ftype = filetype(filename);
DPOS;
strncpy(path, filename,MAXFULLNAME);
help = (char *)PathPart((UBYTE *) path);
*help = STRINGEND;
strncpy(file, (char *)FilePart((UBYTE *) filename),MAXFULLNAME);
sel = MyEasyRequest(NULL, (UBYTE *) NAME " - File Info",
(UBYTE *) ((ftype == TYPE_EXECUTABLE) ?
"Hunk list|Continue" : "Continue"),
(UBYTE *) "Filename : %-20.20s\n"
"Path : %s\n"
"Size : %ld Bytes\n"
"Type : %s",
file, path, SizeOfFile(filename),
mess[ftype]);
if (ftype != TYPE_EXECUTABLE) return TRUE;
return sel;
}
/*
* DisplayDirectoryInfo() zeigt Infos über ein Verzeichnis
* an
*/
void
DisplayDirectoryInfo(char *filename)
{
int count,
Dirs = 0;
long Size = 0L;
char path[MAXFULLNAME],
*help;
BPTR lock;
DPOS;
strncpy(path, filename,MAXFULLNAME);
help = (char *)PathPart((UBYTE *) path);
*help = STRINGEND;
if (lock = Lock((UBYTE *) path, MODE_OLDFILE))
{
count = SizeOfDir(lock, &Size, &Dirs);
UnLock(lock);
}
else count = Size = Dirs = 0;
MyEasyRequest(NULL, (UBYTE *) NAME " - Directory Info", (UBYTE *) "Continue",
(UBYTE *) "Path : %s\n"
"# Files : %ld\n"
"# Sub-Dirs : %ld\n"
"Total : %ld Bytes",
path, count, Dirs, Size);
return;
}
/*
* DisplayTaskInfo() zeigt Infos über einen Task an. Auf
* Wunsch kann der Task gekillt, ein Signal gesendet oder
* die Priorität geändert werden
*/
int
DisplayTaskInfo(struct objectid *obj)
{
struct Task *task = (struct Task *) obj->address,display_task;
char *status[]=
{
"Invalid", "Adding ", "Running", "Ready ", "Waiting", "Except", "Remove"
};
int sel = 7,
wins = 0,
scrs = 0,
ports = 0;
DPOS;
Disable();
CopyMem(task,&display_task,sizeof(struct Task));
Enable();
CountAssocObjects(task, &wins, &scrs, &ports);
sel = MyEasyRequest(SysWnd, (UBYTE *) NAME " " VERSION " - Task Control",
(UBYTE *) "Kill!|^C|^D|^E|^F|Prio|Continue",
(UBYTE *) "Name : %-20.20s (%s) Prio: %-4ld\n"
"Address : 0x%08lx Flags : 0x%08lx\n"
"State : %8s IDNest : %-8ld\n"
"TDNest : %-8ld SigAlloc : 0x%08lx\n"
"SigWait : 0x%08lx SigRecvd : 0x%08lx\n"
"SigExcept : 0x%08lx Stack : %-5ld\n\n"
"Associated Objects\n"
"Ports : %4ld - Windows : %4ld\n"
"Screens : %4ld",
obj->fullname,
(display_task.tc_Node.ln_Type == NT_TASK) ? "Task" : "Process",
display_task.tc_Node.ln_Pri,
task, display_task.tc_Flags, status[display_task.tc_State],
display_task.tc_IDNestCnt, display_task.tc_TDNestCnt,
display_task.tc_SigAlloc, display_task.tc_SigWait, display_task.tc_SigRecvd,
display_task.tc_SigExcept,
((ULONG) display_task.tc_SPUpper - (ULONG) display_task.tc_SPLower),
ports, wins, scrs);
return sel;
}
/*
* savecpyid() kopiert den ID-String einer Library in ein
* Zeichenfeld. Am Ende des Strings erscheinen häufig zwei
* Sonderzeichen, die hier entfernt werden
*/
static void
savecpyid(char *IDStr,struct Library *lib)
{
char *id;
id = (char *)lib->lib_IdString;
if(id && *id)
{
strncpy(IDStr,id,40);
if(!isprint((int)IDStr[strlen(IDStr)-1])) IDStr[strlen(IDStr)-1] = STRINGEND;
if(!isprint((int)IDStr[strlen(IDStr)-2])) IDStr[strlen(IDStr)-2] = STRINGEND;
}
else strcpy(IDStr, field[NO_LIB_ID]);
return;
}
/*
* makelibflags() erzeugt entsprechend der Library-Flags
* einen "lesbaren" String
*/
static char *
makelibflags(struct Library *lib,char *flags)
{
if(lib->lib_Flags == 0) strcpy(flags, field[NO_FLAGS]);
else
sprintf(flags,"%10s %10s %10s %10s",
(lib->lib_Flags & LIBF_SUMMING) ? "CheckSum" : field[BLANK_FIELD],
(lib->lib_Flags & LIBF_CHANGED) ? "Changed" : field[BLANK_FIELD],
(lib->lib_Flags & LIBF_SUMUSED) ? "ResetByErr" : field[BLANK_FIELD],
(lib->lib_Flags & LIBF_DELEXP) ? "DelExpunge" : field[BLANK_FIELD]);
return flags;
}
/*
* DisplayLibraryInfo() zeigt alle Infos über eine Library
* an
*/
int
DisplayLibraryInfo(struct objectid *obj)
{
int sel;
struct Library *lib = (struct Library *) obj->address;
char IDStr[41];
char flags[45];
DPOS;
savecpyid(IDStr,lib);
sel = MyEasyRequest(SysWnd, (UBYTE *) NAME " " VERSION " - Library Control",
(UBYTE *) "Remove Library|Continue",
(UBYTE *) "Type : Library\n"
"Name : %s\n"
"ID-String : %-30.30s\n"
"Address : 0x%08lx\n"
"Flags : %s\n"
"Jump-Table-Size: %4ld Bytes Data-Size : %ld Bytes\n"
"CheckSum : 0x%08lx",
obj->fullname, IDStr, obj->address,
makelibflags(lib,flags),
lib->lib_NegSize,
lib->lib_PosSize,
lib->lib_Sum);
return sel;
}
/*
* DisplaySoftDevInfo() zeigt alle Infos über ein
* *.device an
*/
void
DisplaySoftDevInfo(struct objectid *obj)
{
struct Library *lib = (struct Library *) obj->address;
char IDStr[40];
char flags[45];
DPOS;
savecpyid(IDStr,lib);
MyEasyRequest(SysWnd,
(UBYTE *) NAME " " VERSION " - Software Device Info",
(UBYTE *) "Continue",
(UBYTE *) "Type : Software Device\n"
"Name : %s\n"
"ID-String : %-30.30s\n"
"Address : 0x%08lx\n"
"Flags : %s\n"
"Jump-Table-Size: %4ld Bytes Data-Size : %ld Bytes\n"
"CheckSum : 0x%08lx",
obj->fullname, IDStr, obj->address,
makelibflags(lib,flags),
lib->lib_NegSize,
lib->lib_PosSize,
lib->lib_Sum);
return;
}
/*
* DisplayResourceInfo() zeigt alle Infos über eine .resource
* an
*/
void
DisplayResourceInfo(struct objectid *obj)
{
struct Library *lib = (struct Library *) obj->address;
char flags[45];
DPOS;
MyEasyRequest(SysWnd,
(UBYTE *) NAME " " VERSION " - RessourceInfo",
(UBYTE *) "Continue",
(UBYTE *) "Type : Ressource\n"
"Name : %s\n"
"Address : 0x%08lx\n"
"Flags : %s\n"
"Jump-Table-Size: %4ld Bytes Data-Size : %ld Bytes\n"
"CheckSum : 0x%08lx",
obj->fullname, obj->address,
makelibflags(lib,flags),
lib->lib_NegSize,
lib->lib_PosSize,
lib->lib_Sum);
return;
}
/*
* DisplayPortInfo() zeigt Infos über einen Port an
*/
int
DisplayPortInfo(struct objectid *obj)
{
int sel;
struct MsgPort *port;
char sigtask[MAXFULLNAME];
struct Task *task;
char *flags[]=
{
"Signal", "SoftInt", "Ignore"
};
DPOS;
Disable();
port = (struct MsgPort *) obj->address;
if (port->mp_SigTask)
{
task = (struct Task *) (port->mp_SigTask);
savestrcpy(sigtask, &task->tc_Node, MAXFULLNAME, NT_TASK);
}
else strcpy(sigtask, field[NO_TASK]);
Enable();
sel = MyEasyRequest(SysWnd, (UBYTE *) NAME " " VERSION " - Port Control",
(UBYTE *) "Remove Port|Continue",
(UBYTE *) "Type : %s\n"
"Address : 0x%08lx\n"
"Name : %-20.20s\n"
"Signal-Task : %-20.20s\n"
"Flags : %s",
"Port", obj->address, obj->fullname, sigtask,
flags[port->mp_Flags]);
return sel;
}
/*
* DisplayFontInfo() zeigt alle Infos über einen Font an.
* Dieser kann dann wahlweise entfernt oder angezeigt
* werden
*/
int
DisplayFontInfo(struct objectid *obj)
{
int sel;
DPOS;
sel = MyEasyRequest(SysWnd, (UBYTE *) NAME " " VERSION " - Font Control",
(UBYTE *) "Remove Font|Show Font|Continue",
(UBYTE *) "Type : %s\n"
"Address : 0x%08lx\n"
"Name : %s",
"Font", obj->address, obj->fullname);
return sel;
}
/*
* DisplayWindowInfo() zeigt Infos über ein Fenster an
*/
int
DisplayWindowInfo(struct objectid *obj)
{
int sel;
struct Window disp_win;
ULONG lock;
DPOS;
lock = LockIBase(NULL);
CopyMem((struct Window *)(obj->address),&disp_win,sizeof(struct Window));
UnlockIBase(lock);
sel = MyEasyRequest(SysWnd, (UBYTE *) NAME " " VERSION " - Window Control",
(UBYTE *) "Close Window|Continue",
(UBYTE *)
"Type : Window Address : 0x%08lx\n"
"Name : %-30.30s\n"
"Next : 0x%08lx\n"
"LeftEdge : %-4ld TopEdge : %-4ld\n"
"Width : %-4ld Height : %-4ld\n"
"MinWidth : %-4ld MinHeight: %-4ld\n"
"MaxWidth : %-4ld MaxHeight: %-4ld\n"
"Flags : 0x%08lx Menu: %s\n"
"Requester: %s ReqCount: %ld DMReq: %s\n"
"IDCMP : 0x%08lx Detail: %-2ld Block: %2ld",
obj->address, obj->fullname,
disp_win.NextWindow,
disp_win.LeftEdge,disp_win.TopEdge,
disp_win.Width,disp_win.Height,
disp_win.MinWidth,disp_win.MinHeight,
disp_win.MaxWidth,disp_win.MaxHeight,
disp_win.Flags,(disp_win.MenuStrip ? "Yes" : "No"),
(disp_win.FirstRequest ? "Yes" : "No"),disp_win.ReqCount,
(disp_win.DMRequest ? "Yes" : "No"),disp_win.IDCMPFlags,
disp_win.DetailPen,disp_win.BlockPen );
return sel;
}
/*
* DisplayScreenInfo() zeigt Infos über ein Screen an
*/
int
DisplayScreenInfo(struct objectid *obj)
{
int sel;
struct Screen disp_scr;
ULONG lock;
DPOS;
lock = LockIBase(NULL);
CopyMem((struct Screen *)(obj->address),&disp_scr,sizeof(struct Screen));
UnlockIBase(lock);
sel = MyEasyRequest(SysWnd, (UBYTE *) NAME " " VERSION " - Screen Control",
(UBYTE *) "Close Screen|Continue",
(UBYTE *) "Type : Screen Address : 0x%08lx\n"
"Name : %.20s\n"
"Next : 0x%08lx\n"
"LeftEdge : %-4ld TopEdge : %-4ld\n"
"Width : %-4ld Height : %-4ld\n"
"BarHeight: %-4ld BarVBord : %-4ld\n"
"BarHBord : %-4ld MenuVBord: %-4ld\n"
"MenuHBord: %-4ld WBorTop : %-4ld\n"
"WBorLeft : %-4ld WBorRight: %-4ld\n"
"WBorBott : %-4ld DetailPen: %-4ld\n"
"BlockPen : %-4ld FlashCol : %-4ld\n"
"Flags : 0x%08lx",
obj->address, obj->fullname,
disp_scr.NextScreen,
disp_scr.LeftEdge,disp_scr.TopEdge,
disp_scr.Width,disp_scr.Height,
disp_scr.BarHeight,disp_scr.BarVBorder,
disp_scr.BarHBorder,disp_scr.MenuVBorder,
disp_scr.MenuHBorder,disp_scr.WBorTop,
disp_scr.WBorLeft,disp_scr.WBorRight,
disp_scr.WBorBottom,disp_scr.DetailPen,
disp_scr.BlockPen,disp_scr.SaveColor0,
disp_scr.Flags);
return sel;
}
int
DisplayLockInfo(struct objectid *obj)
{
int sel;
int ftype = filetype(obj->fullname);
sel = MyEasyRequest(SysWnd, (UBYTE *) NAME " " VERSION " - FileLock Control",
(UBYTE *) (ftype ? "Unlock|Continue" : "Continue"),
(UBYTE *) "Type : Lock\n"
"File : %s\n"
"Address : 0x%08lx\n"
"File type : %s",
obj->fullname, obj->address, mess[ftype]);
return (ftype ? sel : 0);
}