home *** CD-ROM | disk | FTP | other *** search
-
- /*******************************************************************
- $CRT 23 Dec 1996 : hb
-
- $AUT Holger Burkarth
- $DAT >>TDInfo.c<< 29 Jan 1997 13:36:09 - (C) ProDAD
- *******************************************************************/
-
- //##ex mcpp:cppc -gs -o pos:pos/Ex/TDInfo p:pLib/StartCode.o p:/pOS_RKRM/pTrackdisk/TDInfo.c p:pLib/StdIO.o -l pOSStub -l pOS
-
- /***********************************************************
- pOS programing example - Copyright (C) 1995-97 proDAD
-
- This code was written as an easy to understand example,
- how to program pOS features. It is provided 'as-is',
- without any express or implied warranty.
-
- Permission is hereby granted to use, copy and modify
- this source code for any purpose, without fee, subject
- to the following conditions:
-
- (1) This notice may not be removed or altered from any
- source distribution.
-
- (2) Altered source versions must be plainly marked as
- such, and must not be misrepresented as being
- the original source code.
-
- (3) If only executable code is distributed, then the
- accompanying documentation have to state that
- "this software is based in part on examples of
- the pOS developer packet".
-
- (4) Permission for use of this code is granted only
- if the user accepts full responsibility for any
- undesirable consequences. proDAD accept NO LIABILITY
- for damages of any kind.
-
- ©proDAD
- ***********************************************************/
-
- /*\
- *** Example:
- ***
- \*/
-
-
- #define __COMPUTER_AMIGA 1
- #define NOMYDEBUG
-
- #include "p:pExec/Types.h"
- #include "p:pExec/MsgPort.h"
- #include "p:pDOS/ArgTags.h"
- #include "p:pDOS/DosSig.h"
- #include "p:pDOS/DosErrors.h"
- #include "p:Device/Trackdisk.h"
-
- #include "p:proto/pLibExt.h"
- #include "p:proto/pExec2.h"
- #include "p:proto/pDOS2.h"
-
- #ifdef _____ME_____
- #include "grund/inc_string.h"
- #include "grund/inc_stdio.h"
- #else
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <string.h>
- #include <stdio.h>
- #ifdef __cplusplus
- }
- #endif
- #endif
-
-
- const CHAR *HelpText=
- ""
- ;
-
- const CHAR *PrgHeader=
- "";
-
- const CHAR *PrgVerText=
- "$VER: 1.0 ("__DATE2__") (Copyright 1996-97 by proDAD) (Created by Holger Burkarth)";
-
-
- /*----------------------------------
- -----------------------------------*/
- #ifdef __cplusplus
- extern "C"
- #endif
-
- VOID main()
- {
- struct pOS_DosArgs* Args;
- UWORD Err=0;
- ULONG Ops[2]={0,(ULONG)"pTrackdisk.device"};
-
- Args=pOS_ReadDosArgs(
- //
- "UNIT/N,DEVICE",
- Ops,sizeof(Ops)/sizeof(ULONG),
-
- ARGTAG_PrgHeaderText, (ULONG)PrgHeader, /* kurze Programm-Beschreibung */
- ARGTAG_HelpText, (ULONG)HelpText, /* Help-Texte */
- ARGTAG_PrgVerText, (ULONG)PrgVerText, /* VER-String */
- TAG_END);
-
- if(Args) {
- pOS_MsgPort Port;
- pOS_TrackdiskIO *IO;
-
- if(pOS_ConstructMsgPort(&Port)) {
- if(IO=(pOS_TrackdiskIO*)pOS_CreateIORequest(&Port,sizeof(pOS_TrackdiskIO))) {
- pOS_OpenDevice((CHAR*)Ops[1],Ops[0] ? *((ULONG*)Ops[0]):0,
- (pOS_IORequest*)IO,0,0);
- if(IO->tdio_Error==0) {
- pOS_DriveGeometry Geom;
- memset(&Geom,0,sizeof(pOS_DriveGeometry));
-
- IO->tdio_Command=TDCMD_GetGeometry;
- IO->tdio_Data =&Geom;
- IO->tdio_Length =sizeof(pOS_DriveGeometry);
- pOS_DoIO((pOS_IORequest*)IO);
- if(IO->tdio_Error==0) {
- printf(
- "dg_SectorSize = %ld \n"
- "dg_TotalSectors = %ld\n"
- "dg_Cylinders = %ld\n"
- "dg_CylSectors = %ld\n"
- "dg_Heads = %ld\n"
- "dg_TrackSectors = %ld\n"
- "dg_BufMemType = 0x%lx\n"
- "dg_DeviceType = %ld\n"
- "dg_Flags = 0x%lx\n"
- ,Geom.dg_SectorSize
- ,Geom.dg_TotalSectors
- ,Geom.dg_Cylinders
- ,Geom.dg_CylSectors
- ,Geom.dg_Heads
- ,Geom.dg_TrackSectors
- ,Geom.dg_BufMemType
- ,Geom.dg_DeviceType
- ,Geom.dg_Flags);
- }
- else printf("TDCMD_GetGeometry failed, error=%ld\n",IO->tdio_Error);
-
-
- IO->tdio_Command=TDCMD_ChangeNum;
- pOS_DoIO((pOS_IORequest*)IO);
- if(IO->tdio_Error==0) {
- printf("Disk-Change Counter = %ld\n",IO->tdio_Actual);
- }
- else printf("TDCMD_ChangeNum failed, error=%ld\n",IO->tdio_Error);
-
-
- IO->tdio_Command=TDCMD_ChangeState;
- pOS_DoIO((pOS_IORequest*)IO);
- if(IO->tdio_Error==0) {
- printf("Disk in Drive = %ld\n",IO->tdio_Actual);
- }
- else printf("TDCMD_ChangeState failed, error=%ld\n",IO->tdio_Error);
-
-
- IO->tdio_Command=TDCMD_ProtStatus;
- pOS_DoIO((pOS_IORequest*)IO);
- if(IO->tdio_Error==0) {
- printf("Disk protected = %ld\n",IO->tdio_Actual);
- }
- else printf("TDCMD_ProtStatus failed, error=%ld\n",IO->tdio_Error);
-
-
- IO->tdio_Command=TDCMD_GetDriveType;
- pOS_DoIO((pOS_IORequest*)IO);
- if(IO->tdio_Error==0) {
- printf("Disk type = %ld\n",IO->tdio_Actual);
- }
- else printf("TDCMD_GetDriveType failed, error=%ld\n",IO->tdio_Error);
-
-
- IO->tdio_Command=TDCMD_GetNumTracks;
- pOS_DoIO((pOS_IORequest*)IO);
- if(IO->tdio_Error==0) {
- printf("Num tracks = %ld\n",IO->tdio_Actual);
- }
- else printf("TDCMD_GetNumTracks failed, error=%ld\n",IO->tdio_Error);
-
- pOS_CloseDevice((pOS_IORequest*)IO);
- }
- else printf("pOS_OpenDevice <%s> failed, error=%ld\n",Ops[1],IO->tdio_Error);
- pOS_DeleteIORequest((pOS_IORequest*)IO);
- }
- else printf("pOS_CreateIORequest failed\n");
- pOS_DestructMsgPort(&Port);
- }
- else printf("pOS_ConstructMsgPort failed\n");
-
- pOS_DeleteDosArgs(Args); /* Args freigeben */
- }
- else Err=DOSFAIL_FAIL; /* vollkommen fehlgeschlagen */
-
- pOS_SetShellFail(Err);
- }
-