home *** CD-ROM | disk | FTP | other *** search
- ; /** execute p:/pOS/pLib/pLibExt.c
- cc:c/storm/StormC_2_0_8 -o ram:pOS1.o -d _M1_ -c p:pLib/pLibExt.c -g20 -O9 -pc -i cc:include -i ci: -wEPRTcV -d NOMYDEBUG=1 -L
- cc:c/storm/StormC_2_0_8 -o ram:pOS2.o -d _M2_ -c p:pLib/pLibExt.c -g20 -O9 -pc -i cc:include -i ci: -wEPRTcV -d NOMYDEBUG=1 -L
- cc:c/storm/StormC_2_0_8 -o ram:pOS3.o -d _M3_ -c p:pLib/pLibExt.c -g20 -O9 -pc -i cc:include -i ci: -wEPRTcV -d NOMYDEBUG=1 -L
-
- quit
- ; **/
-
- #ifndef __INC_POS_PLIB_PLIBEXT_C
- #define __INC_POS_PLIB_PLIBEXT_C
- /*******************************************************************
- $CRT 16 Mar 1996 : hb
-
- $AUT Holger Burkarth
- $DAT >>pLibExt.c<< 01 Feb 1997 10:01:36 - (C) ProDAD
- *******************************************************************/
-
- /*******************************************************************
- pOS_FWritef pOS_GetDosObjectType
- pOS_GetDosLockType pOS_CheckBreakSignal
- pOS_GetNextString pOS_GetDosObjectSize
- pOS_GetDosFailFromStr pOS_VSPrintf
- pOS_SPrintf pOS_DosErrPrintf
- pOS_GetObjectData pOS_SetObjectData
- pOS_GetAbsObjectData pOS_SetAbsObjectData
- pOS_Debugf pOS_TimeDelay
- kprintf pOS_KPrintf
- *******************************************************************/
-
- #include "p:pExec/Types.h"
-
- #include "p:pDOS/DosErrors.h"
- #include "p:pDOS/FIB.h"
- #include "p:pDOS/Files.h"
- #include "p:pDOS/Lock.h"
- #include "p:pDOS/Process.h"
- #include "p:pDOS/Segment.h"
- #include "p:pDOS/DosSig.h"
- #include "p:pDOS/InfoData.h"
- #include "p:pDos/DosBase.h"
- #include "p:pExec/RawDoFmt.h"
- #include "p:pIntui/IClass.h"
- #include "p:proto/pExec2.h"
- #include "p:proto/pDOS2.h"
- #include "p:proto/pLibExt.h"
- #include "p:proto/pIntui2.h"
- #include "p:proto/pGfx2.h"
- #include "p:proto/pUtil2.h"
- #include "p:proto/pGadget2.h"
-
-
- #ifdef __cpluplus
- extern "C" {
- #endif
- #include <string.h>
- #include <ctype.h>
- #ifdef __cpluplus
- }
- #endif
-
-
- /** Dos **/
- #ifdef _M1_
-
- /*----------------------------------
- -----------------------------------*/
- dossize_t pOS_FWritef(struct pOS_FileHandle* fh,const CHAR* format,...)
- {
- return( pOS_VFWritef(fh,format,((ULONG*)&format)+1) );
- }
-
- /*----------------------------------
- -----------------------------------*/
- SLONG pOS_GetDosObjectType(const struct pOS_FileLock* currDir,
- const dosname_t* name)
- {
- SLONG Type=-1;
- struct pOS_FileInfoBlock* FIB;
-
- FIB=(struct pOS_FileInfoBlock*)pOS_AllocDosObject(DOSOBJ_FIB,NULL);
- if(FIB) {
- struct pOS_FileLock *Lock;
-
- Lock=pOS_LockObject(currDir,name,FILELKACC_Shared);
- if(Lock) {
- if(pOS_ExamineObject(Lock,FIB)) Type=FIB->fib_DirEntryType;
- else if(!pOS_IsFileSystem(Lock)) Type=FINFENTYP_Dir;
- pOS_UnlockObject(Lock);
- }
- else Type=0;
- pOS_FreeDosObject(DOSOBJ_FIB,FIB);
- }
- return(Type);
- }
-
-
- /*----------------------------------
- -----------------------------------*/
- SLONG pOS_GetDosLockType(const struct pOS_FileLock* lock)
- {
- SLONG Type=-1;
- struct pOS_FileInfoBlock* FIB;
-
- FIB=(struct pOS_FileInfoBlock*)pOS_AllocDosObject(DOSOBJ_FIB,NULL);
- if(FIB) {
- if(pOS_ExamineObject(lock,FIB)) Type=FIB->fib_DirEntryType;
- else if(!pOS_IsFileSystem(lock)) Type=FINFENTYP_Dir;
- pOS_FreeDosObject(DOSOBJ_FIB,FIB);
- }
- return(Type);
- }
-
-
- /*----------------------------------
- -----------------------------------*/
- dossize_t pOS_GetDosObjectSize(const struct pOS_FileLock* currDir,const dosname_t* name)
- {
- dossize_t Size=0;
- struct pOS_FileInfoBlock* FIB;
-
- FIB=(struct pOS_FileInfoBlock*)pOS_AllocDosObject(DOSOBJ_FIB,NULL);
- if(FIB) {
- struct pOS_FileLock *Lock;
-
- Lock=pOS_LockObject(currDir,name,FILELKACC_Shared);
- if(Lock) {
- if(pOS_ExamineObject(Lock,FIB)) Size=FIB->fib_Size;
- pOS_UnlockObject(Lock);
- }
- pOS_FreeDosObject(DOSOBJ_FIB,FIB);
- }
- return(Size);
- }
-
-
-
-
- /*----------------------------------
- -----------------------------------*/
- BOOL pOS_CheckBreakSignal()
- {
- if(pOS_SetSignal(0L,DOSSIGF_CTRL_C) & DOSSIGF_CTRL_C) {
- struct pOS_Process *Proc=(struct pOS_Process*)pOS_FindTask(NULL);
- if(Proc->pr_CES) pOS_WriteFile(Proc->pr_CES,"^C\n",3);
- return(TRUE);
- }
- return(FALSE);
- }
-
-
- /*----------------------------------
- -----------------------------------*/
- #ifdef __cplusplus
- extern "C"
- #endif
-
- static VOID pOSp_VSPrintf(struct pOS_RawDoFmtData *data)
- {
- *((UBYTE*)data->rdft_User[0])=data->rdft_Data;
- data->rdft_User[0]++;
- data->rdft_ResSize++;
- }
-
-
- /*----------------------------------
- -----------------------------------*/
- CHAR* pOS_VSPrintf(CHAR* string,const CHAR* format,const ULONG* argv)
- {
- struct pOS_RawDoFmtData Data;
-
- // ww_w("pOS_VSPrintf");
- // ww_rp(string);
- // ww_rp(format);
- // ww_endN(0);
-
- Data.rdft_Format=format;
- Data.rdft_InterFmt=NULL;
- Data.rdft_DoFmt=pOSp_VSPrintf;
- Data.rdft_Argv=argv;
- Data.rdft_User[0]=(ULONG)string;
-
- pOS_RawDoFmt(&Data);
- *((UBYTE*)Data.rdft_User[0])='\0';
- return((CHAR*)Data.rdft_User[0]);
- }
-
-
- /*----------------------------------
- -----------------------------------*/
- CHAR* pOS_SPrintf(CHAR* string,const CHAR* format,...)
- {
- return( pOS_VSPrintf(string,format,(ULONG*) ((&format)+1) ) );
- }
-
-
- /*----------------------------------
- -----------------------------------*/
- BOOL pOS_DosInfoDataName(const struct pOS_FileLock* currDir,
- const dosname_t* name,struct pOS_DosInfoData* data)
- {
- BOOL Flg=FALSE;
-
- struct pOS_FileLock *Lock;
-
- Lock=pOS_LockObject(currDir,name,FILELKACC_Shared);
- if(Lock) {
- Flg=pOS_GetDosInfoData(Lock,data);
- pOS_UnlockObject(Lock);
- }
-
- return(Flg);
- }
-
-
- /*----------------------------------
- -----------------------------------*/
- BOOL pOS_DosErrPrintf(struct pOS_FileHandle* cerr,const CHAR* format,...)
- {
- struct pOS_Process *const Proc=(struct pOS_Process*)pOS_FindTask(NULL);
-
- // ww_w("pOS_DosErrPrintf");
- // ww_rp(format);
- // ww_endN(FALSE);
-
- if(Proc->pr_Error2) {
- if(!cerr) cerr=Proc->pr_CES;
- if(!cerr) cerr=Proc->pr_COS;
- if(cerr) {
- const CHAR *Name=pOS_GetDosErrText((enum pOS_DosErrors)Proc->pr_Error2);
- pOS_VFWritef(cerr,format,((ULONG*)&format)+1);
- pOS_FWritef(cerr,"%s\n",Name);
- }
- }
- return(Proc->pr_Error2!=0);
- }
-
-
-
- #endif /** _M1_ **/
-
-
-
- /** Exec **/
- #ifdef _M2_
-
- /*----------------------------------
- -----------------------------------*/
- ULONG pOS_GetObjectData(APTR obj,ULONG tag)
- {
- struct pOS_IntuiMethod Mth;
- ULONG Dt;
-
- Mth.imth_Method=ICLMTH_Get;
- Mth.imth_U.imth_Get.imgt_ID=tag;
- Mth.imth_U.imth_Get.imgt_Variable=&Dt;
- pOS_DoIMethodA(obj,(struct pOS_Method*)&Mth);
- return(Dt);
- }
-
- /*----------------------------------
- -----------------------------------*/
- ULONG pOS_SetObjectData(APTR obj,ULONG tag,...)
- {
- struct pOS_IntuiMethod Mth;
-
- Mth.imth_Method=ICLMTH_Set;
- Mth.imth_U.imth_Set.imst_Info=NULL;
- Mth.imth_U.imth_Set.imst_Tags=(struct pOS_TagItem*)&tag;
- return( pOS_DoIMethodA(obj,(struct pOS_Method*)&Mth) );
- }
-
-
- /*----------------------------------
- -----------------------------------*/
- ULONG pOS_GetAbsObjectData(const struct pOS_Class* cl,APTR obj,ULONG tag)
- {
- struct pOS_IntuiMethod Mth;
- ULONG Dt;
-
- Mth.imth_Method=ICLMTH_Get;
- Mth.imth_U.imth_Get.imgt_ID=tag;
- Mth.imth_U.imth_Get.imgt_Variable=&Dt;
- pOS_DoAbsMethodA(cl,obj,(struct pOS_Method*)&Mth);
- return(Dt);
- }
-
- /*----------------------------------
- -----------------------------------*/
- ULONG pOS_SetAbsObjectData(const struct pOS_Class* cl,APTR obj,ULONG tag,...)
- {
- struct pOS_IntuiMethod Mth;
-
- Mth.imth_Method=ICLMTH_Set;
- Mth.imth_U.imth_Set.imst_Info=NULL;
- Mth.imth_U.imth_Set.imst_Tags=(struct pOS_TagItem*)&tag;
- return( pOS_DoAbsMethodA(cl,obj,(struct pOS_Method*)&Mth) );
- }
-
- /*----------------------------------
- -----------------------------------*/
- VOID pOS_TimeDelay(ULONG sec,ULONG mics)
- {
- pOS_WaitTimeSignal(0,mics + (sec?sec*1000000:0));
- }
-
-
- /*----------------------------------
- -----------------------------------*/
- VOID kprintf(const CHAR* format,...)
- {
- pOS_VKPrintf(format,(ULONG*) ((&format)+1) );
- }
-
- /*----------------------------------
- -----------------------------------*/
- VOID pOS_KPrintf(const CHAR* format,...)
- {
- pOS_VKPrintf(format,(ULONG*) ((&format)+1) );
- }
-
-
-
- #endif /** _M2_ **/
-
-
-
- /** Other **/
- #ifdef _M3_
-
- /*----------------------------------
- -----------------------------------*/
- ULONG pOS_GetDosFailFromStr(const CHAR* str)
- {
- ULONG Err;
-
- // ww_w("pOS_GetDosFailFromStr");
- // ww_rp(str);
- // ww_endN(-1);
-
- if (stricmp(str,"OK")==0) Err=DOSFAIL_OK;
- else if(stricmp(str,"WARN")==0) Err=DOSFAIL_WARN;
- else if(stricmp(str,"ABORT")==0) Err=DOSFAIL_ABORT;
- else if(stricmp(str,"ERROR")==0) Err=DOSFAIL_ERROR;
- else if(stricmp(str,"FAIL")==0) Err=DOSFAIL_FAIL;
- else Err=-1;
-
- return(Err);
- }
-
-
- /*----------------------------------
- -----------------------------------*/
- const CHAR* pOS_GetNextString(const CHAR* name,CHAR* puffer,size_t pufSize)
- {
- while(*name==' ' || *name=='\t') name++;
-
- if(*name=='\"') {
- for(++name; !(*name=='\"' || *name=='\0' || pufSize==0);
- *puffer++=*name++,--pufSize) ;
- if(*name) ++name;
- }
- else {
- for(; !(*name==' ' || *name=='\t' || *name=='\0' || *name=='\n' || pufSize==0);
- *puffer++=*name++,--pufSize) ;
- }
-
- while(*name==' ' || *name=='\t') name++;
-
- puffer[0]='\0';
- return(name);
- }
-
-
- #endif /** _M3_ **/
-
-
-
- #endif
-