home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Misc / InstallerNG / developer / savagelib / include / clib / savage_protos.h
Encoding:
C/C++ Source or Header  |  1999-09-28  |  9.6 KB  |  145 lines

  1.  
  2. #ifndef CLIB_SAVAGE_H
  3. #define CLIB_SAVAGE_H
  4.  
  5. #include <exec/types.h>
  6. #include <exec/lists.h>
  7. #include <exec/nodes.h>
  8. #include <exec/resident.h>
  9. #include <exec/ports.h>
  10. #include <exec/tasks.h>
  11. #include <intuition/intuition.h>
  12. #include <intuition/screens.h>
  13. #include <dos/dos.h>
  14. #include <graphics/text.h>
  15. #include <graphics/gfx.h>
  16. #include <savage/sysinfo.h>
  17. #include <savage/guicontext.h>
  18. #include <savage/visible.h>
  19. #include <utility/tagitem.h>
  20.  
  21. /********************************************************************
  22.  ** file related functions
  23.  ********************************************************************/
  24.  
  25. APTR sav_ReadFile(char *file);  // read a file using exec.AllocVec
  26. APTR sav_ReadFile2(char *file);  // read a file using savagelibs.sav_AllocVec
  27. BOOL sav_FileExists(char *file);  // check if a file does exist or not
  28. BOOL sav_DirExists(char *file);  // check if a directory does exist or not
  29. struct FileInfoBlock *sav_FileGetFIB(char *file);  // get a files FIB
  30. void sav_FileFreeFIB(struct FileInfoBlock *fib);  // free a FIB allocated with sav_FileGetFIB
  31. long sav_FileSize(char *file);  // get the size of a file
  32. long sav_FileType(char *file);  // get the file type (see <savage/filetype.h>)
  33. long sav_FileSum(char *file);  // get a checksum for a file
  34. char *sav_FileVersion(char *file);  // find the version string of a file
  35. BOOL sav_FileWriteProtected(char *file);  // check for write protection
  36. long sav_FileUnProtect(char *file);  // clear the write protection of a file
  37. struct Resident *sav_GetFileRomtag(char *file);  // find a RomTag structure of a file
  38. void sav_FreeFileRomtag(void);  // free the RomTag structure allocated with sav_GetFileRomtag
  39. void sav_Print(char *string);  // print the string to stdout
  40. void sav_PrintLF(void);  // print a LF to stdout
  41. BPTR sav_CD(char *dir);  // change the current directory to dir
  42. long sav_PathLen(char *path);  // get the length of a path
  43. BPTR sav_MakeDir(char *dir);  // check for a dir and create it, if it still does not exist
  44. BOOL sav_FontFile(char *file);  // check for ".font" suffix
  45. BOOL sav_InfoFile(char *file);  // check for ".info" suffix
  46. BOOL sav_DirWalk(char *dir, BOOL (*)(struct FileInfoBlock *, APTR), APTR usrdata);  // call entryfun(fib, usrdata) with every entry of dir
  47. struct FileLock *sav_GetCurrentDir(void);  // returns the processes current directory
  48. void sav_ReduceDir(char *path);  // reduce the path with one (the last) path component
  49. long sav_GetProtection(char *file);  // returns the protection of a file
  50.  
  51. /********************************************************************
  52.  ** gui functions
  53.  ********************************************************************/
  54.  
  55. struct GUIContext *sav_GetGUIContext(char *screenname);  // returns the GUIContext for the given screen (see <savage/guicontext.h>)
  56. void sav_FreeGUIContext(struct GUIContext *guic);  // free the GUIContext allocated with sav_GetGUIContext
  57. void sav_WindowInnerDim(struct Window *window, struct Rectangle *rect);  // store windows inner dimensions into rect
  58. void sav_CloseSharedWindow(struct Window *window);  // close a window with a shared UserPort
  59. void sav_VisibleRect(struct Screen *screen, struct Visible *vis);  // store the visible part of an oversized screen to vis
  60. void sav_ClearWindow(struct Window *window);  // clear windows content
  61. APTR sav_LockWindow(struct Window *window);  // lock a window
  62. void sav_UnlockWindow(APTR winlock);  // unlock a window which was locked with sav_LockWindow
  63. void sav_CloseScreen(struct Screen *scr);  // closes the screen scr, if that fails, it calls Delay(50) and tries again and again and again...
  64.  
  65. /********************************************************************
  66.  ** memory supporting functions
  67.  ********************************************************************/
  68.  
  69. APTR sav_AllocVec(ULONG size, ULONG memflags);  // alloc memory and save the pointer to tasks tc_MemEntry field
  70. void sav_FreeVec(APTR addr);  // free memory allocated with sav_AllocVec
  71. void sav_FreeMemList(void);  // dispose the entries of tasks tc_MemEntry field which are allocated using sav_AllocVec
  72. void sav_ClearMem(APTR addr, long size);  // fill the given memory block with zeros
  73. APTR sav_CloneMem(APTR addr, long size);  // clones the given memory; uses exec.AllocVec for allocating the memory
  74. APTR sav_CloneMem2(APTR addr, long size);  // clones the given memory; uses sav_AllocVec for allocating the memory
  75.  
  76. /********************************************************************
  77.  ** list and related functions
  78.  ********************************************************************/
  79.  
  80. void sav_InitListHeader(struct List *list);  // initializes the list header
  81. struct Node *sav_GetHead(struct List *list);  // returns the first node or NULL if empty
  82. struct Node *sav_GetTail(struct List *list);  // returns the last node or NULL if empty
  83. long sav_ListLen(struct List *list);  // returns the length of a list (i.e. the number of nodes)
  84. long sav_TailLen(struct Node *node);  // returns the number of nodes
  85. long sav_NodeNum(struct List *list, struct Node *node);  // returns the number of the node
  86. struct Node *sav_FindNodeNum(struct List *list, long n);  // returns the n-th node of the list or NULL
  87. BOOL sav_ForAllNodes(struct List *list, BOOL (*)(struct Node *, APTR), APTR usrdata);  // calls nodefun(node, userdata) for every node of the list
  88. void sav_NodeToHead(struct List *list, struct Node *node);  // moves a node to the top of the list
  89. void sav_NodeToTail(struct List *list, struct Node *node);  // moves a node to the tail of a list
  90. int sav_InsertNodeABC(struct List *list, struct Node *node);  // respectively to nodes name, the node will be alphabetically inserted
  91. struct Node *sav_MakeNode(long size, char *name);  // creates a node of size "size" and (optionally) duplicates the name and uses it as ln_Name
  92. void sav_FreeNode(struct Node *node);  // frees a node created with sav_MakeNode
  93. void sav_FreeList(struct List *list);  // disposes all nodes (see sav_MakeNode) of a list
  94. void sav_AppendList(struct List *list1, struct List *list2);  // appends list2 to the end of list1
  95. struct Node *sav_FindNameNoCase(struct List *list, char *name);  // searches the list for a node, where node's name equals the given one (ignore cases!)
  96. long sav_NumFindNameNoCase(struct List *list, char *name);  // searches the list for a node, where node's name equals the given one (ignore cases!) and returns the number of this node or -1
  97.  
  98. /********************************************************************
  99.  ** functions for system
  100.  ********************************************************************/
  101.  
  102. void sav_GetSysInfo(struct SysInfo *si);  // fill the SysInfo structure (see <savage/sysinfo.h>)
  103. long sav_TotalStackSize(void);  // get the total size of the tasks stack
  104. long sav_StackLeft(void);  // get the free stack size
  105. BOOL sav_SetCustomStack(long size);  // set a custom stack
  106. void sav_StackSwap(struct StackSwapStruct *sws);  // !!!!!!!!!!! fix a bug in amiga.lib StackSwap
  107. void sav_DisposeCustomStack(void);  // remove/free a custom stack set with sav_SetCustomStack
  108. int sav_GetSeed(void);  // get a seed vor a pseudo-random generator
  109. struct Library *sav_FindLibrary(char *name);  // search the list of current opened libraries for a specific one
  110. struct Device *sav_FindDevice(char *name);  // search the list of current opened devices for a specific one
  111. long sav_ConvertVerString(char *verstr);  // extract a version number of a standard $VER string
  112. long sav_GetReg(long reg);  // get the value of a specific cpu register (see <savage/getreg.h>)
  113. APTR *sav_GetCurrentSP(void);  // returns the current value of the register A7 (stack pointer)
  114. BOOL sav_ExistsDosEntry(char *name, long type);  // search the system for a assign/device/volume
  115. struct Window *sav_QuietProcess(void);  // supress system requesters like "please insert volume..."
  116. void sav_KPrint(char *string);  // print the string using KPrintF
  117. BOOL sav_OpenCloseLibrary(char *libname);  // check for a library (open/close the lib)
  118. APTR sav_ReadSP(void);  // returns the current A7
  119. void sav_WriteSP(APTR addr);  // moves addr to A7
  120. long sav_PutMsg(char *portname, struct Message *msg);  // searches the port and sends it a msg
  121.  
  122. /********************************************************************
  123.  ** stupid (weird functions!)
  124.  ********************************************************************/
  125.  
  126. long sav_BitChange(long val, long num);
  127.  
  128. /********************************************************************
  129.  ** additional functions
  130.  ********************************************************************/
  131.  
  132. long sav_EasyRequest(struct Window *window, char *title, char *body, char *gads, APTR args);  // see intuition.EasyRequestArgs
  133. void sav_InitTAttr(struct TextAttr *tattr, struct TextFont *font);  // init a TextAttr structure with values of font
  134. ULONG sav_TextLength(char *string, struct TextFont *font);  // get the size (pixels) of the string
  135. APTR sav_StringF(char *fmtstring, APTR args);  // format a string with the given args (use exec.AllocVec() for the resulting string)
  136. APTR sav_StringF2(char *fmtstring, APTR args);  // format a string with the given args (use savagelib.sav_AllocVec() for the resulting string)
  137. long sav_RangeNumber(long num, long lowerrange, long upperrange);  // if num is smaller/greater than lowerrange/upperrange the cut it to size and return num
  138. long sav_MatchPatternNoCase(char *patter, char *string);  // matches string and the pattern; return 1 for match, 0 for no match, -1 for an error
  139. char *sav_DupString(char *str);  // makes a copy of a string; uses exec.AllocVec for allocating the memory
  140. char *sav_DupString2(char *str);  // makes a copy of a string, uses sav_AllocVec for allocating the memory
  141. char *sav_BStr2CStr(BPTR str);  // takes the BPTR and copys the BSTR to a new AllocVec()`ed memory-area
  142.  
  143. #endif
  144.  
  145.