home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / DC-POS24.LZX / pOS / pOS_RKRM.lzx / pOS_RKRM / pTrackdisk / TDInfo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-18  |  5.6 KB  |  205 lines

  1.  
  2. /*******************************************************************
  3.  $CRT 23 Dec 1996 : hb
  4.  
  5.  $AUT Holger Burkarth
  6.  $DAT >>TDInfo.c<<   29 Jan 1997    13:36:09 - (C) ProDAD
  7. *******************************************************************/
  8.  
  9. //##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
  10.  
  11. /***********************************************************
  12.   pOS programing example - Copyright (C) 1995-97 proDAD
  13.  
  14.   This code was written as an easy to understand example,
  15.   how to program pOS features. It is provided 'as-is',
  16.   without any express or implied warranty.
  17.  
  18.   Permission is hereby granted to use, copy and modify
  19.   this source code for any purpose, without fee, subject
  20.   to the following conditions:
  21.  
  22.     (1) This notice may not be removed or altered from any
  23.         source distribution.
  24.  
  25.     (2) Altered source versions must be plainly marked as
  26.         such, and must not be misrepresented as being
  27.         the original source code.
  28.  
  29.     (3) If only executable code is distributed, then the
  30.         accompanying documentation have to state that
  31.         "this software is based in part on examples of
  32.         the pOS developer packet".
  33.  
  34.     (4) Permission for use of this code is granted only
  35.         if the user accepts full responsibility for any
  36.         undesirable consequences. proDAD accept NO LIABILITY
  37.         for damages of any kind.
  38.  
  39.   ©proDAD
  40. ***********************************************************/
  41.  
  42. /*\
  43. *** Example:
  44. ***
  45. \*/
  46.  
  47.  
  48. #define __COMPUTER_AMIGA 1
  49. #define NOMYDEBUG
  50.  
  51. #include "p:pExec/Types.h"
  52. #include "p:pExec/MsgPort.h"
  53. #include "p:pDOS/ArgTags.h"
  54. #include "p:pDOS/DosSig.h"
  55. #include "p:pDOS/DosErrors.h"
  56. #include "p:Device/Trackdisk.h"
  57.  
  58. #include "p:proto/pLibExt.h"
  59. #include "p:proto/pExec2.h"
  60. #include "p:proto/pDOS2.h"
  61.  
  62. #ifdef _____ME_____
  63.   #include "grund/inc_string.h"
  64.   #include "grund/inc_stdio.h"
  65. #else
  66.  #ifdef __cplusplus
  67.  extern "C" {
  68.  #endif
  69.   #include <string.h>
  70.   #include <stdio.h>
  71.  #ifdef __cplusplus
  72.  }
  73.  #endif
  74. #endif
  75.  
  76.  
  77. const CHAR *HelpText=
  78. ""
  79. ;
  80.  
  81. const CHAR *PrgHeader=
  82. "";
  83.  
  84. const CHAR *PrgVerText=
  85. "$VER: 1.0 ("__DATE2__") (Copyright 1996-97 by proDAD) (Created by Holger Burkarth)";
  86.  
  87.  
  88. /*----------------------------------
  89. -----------------------------------*/
  90. #ifdef __cplusplus
  91. extern "C"
  92. #endif
  93.  
  94. VOID main()
  95. {
  96.   struct pOS_DosArgs* Args;
  97.   UWORD Err=0;
  98.   ULONG Ops[2]={0,(ULONG)"pTrackdisk.device"};
  99.  
  100.   Args=pOS_ReadDosArgs(
  101. //
  102. "UNIT/N,DEVICE",
  103. Ops,sizeof(Ops)/sizeof(ULONG),
  104.  
  105.     ARGTAG_PrgHeaderText, (ULONG)PrgHeader,    /* kurze Programm-Beschreibung */
  106.     ARGTAG_HelpText,      (ULONG)HelpText,     /* Help-Texte */
  107.     ARGTAG_PrgVerText,    (ULONG)PrgVerText,   /* VER-String */
  108.     TAG_END);
  109.  
  110.   if(Args) {
  111.     pOS_MsgPort Port;
  112.     pOS_TrackdiskIO *IO;
  113.  
  114.     if(pOS_ConstructMsgPort(&Port)) {
  115.       if(IO=(pOS_TrackdiskIO*)pOS_CreateIORequest(&Port,sizeof(pOS_TrackdiskIO))) {
  116.         pOS_OpenDevice((CHAR*)Ops[1],Ops[0] ? *((ULONG*)Ops[0]):0,
  117.                        (pOS_IORequest*)IO,0,0);
  118.         if(IO->tdio_Error==0) {
  119.           pOS_DriveGeometry Geom;
  120.           memset(&Geom,0,sizeof(pOS_DriveGeometry));
  121.  
  122.           IO->tdio_Command=TDCMD_GetGeometry;
  123.           IO->tdio_Data    =&Geom;
  124.           IO->tdio_Length  =sizeof(pOS_DriveGeometry);
  125.           pOS_DoIO((pOS_IORequest*)IO);
  126.           if(IO->tdio_Error==0) {
  127.             printf(
  128. "dg_SectorSize   = %ld \n"
  129. "dg_TotalSectors = %ld\n"
  130. "dg_Cylinders    = %ld\n"
  131. "dg_CylSectors   = %ld\n"
  132. "dg_Heads        = %ld\n"
  133. "dg_TrackSectors = %ld\n"
  134. "dg_BufMemType   = 0x%lx\n"
  135. "dg_DeviceType   = %ld\n"
  136. "dg_Flags        = 0x%lx\n"
  137. ,Geom.dg_SectorSize
  138. ,Geom.dg_TotalSectors
  139. ,Geom.dg_Cylinders
  140. ,Geom.dg_CylSectors
  141. ,Geom.dg_Heads
  142. ,Geom.dg_TrackSectors
  143. ,Geom.dg_BufMemType
  144. ,Geom.dg_DeviceType
  145. ,Geom.dg_Flags);
  146.           }
  147.           else printf("TDCMD_GetGeometry failed, error=%ld\n",IO->tdio_Error);
  148.  
  149.  
  150.           IO->tdio_Command=TDCMD_ChangeNum;
  151.           pOS_DoIO((pOS_IORequest*)IO);
  152.           if(IO->tdio_Error==0) {
  153.             printf("Disk-Change Counter = %ld\n",IO->tdio_Actual);
  154.           }
  155.           else printf("TDCMD_ChangeNum failed, error=%ld\n",IO->tdio_Error);
  156.  
  157.  
  158.           IO->tdio_Command=TDCMD_ChangeState;
  159.           pOS_DoIO((pOS_IORequest*)IO);
  160.           if(IO->tdio_Error==0) {
  161.             printf("Disk in Drive = %ld\n",IO->tdio_Actual);
  162.           }
  163.           else printf("TDCMD_ChangeState failed, error=%ld\n",IO->tdio_Error);
  164.  
  165.  
  166.           IO->tdio_Command=TDCMD_ProtStatus;
  167.           pOS_DoIO((pOS_IORequest*)IO);
  168.           if(IO->tdio_Error==0) {
  169.             printf("Disk protected = %ld\n",IO->tdio_Actual);
  170.           }
  171.           else printf("TDCMD_ProtStatus failed, error=%ld\n",IO->tdio_Error);
  172.  
  173.  
  174.           IO->tdio_Command=TDCMD_GetDriveType;
  175.           pOS_DoIO((pOS_IORequest*)IO);
  176.           if(IO->tdio_Error==0) {
  177.             printf("Disk type = %ld\n",IO->tdio_Actual);
  178.           }
  179.           else printf("TDCMD_GetDriveType failed, error=%ld\n",IO->tdio_Error);
  180.  
  181.  
  182.           IO->tdio_Command=TDCMD_GetNumTracks;
  183.           pOS_DoIO((pOS_IORequest*)IO);
  184.           if(IO->tdio_Error==0) {
  185.             printf("Num tracks = %ld\n",IO->tdio_Actual);
  186.           }
  187.           else printf("TDCMD_GetNumTracks failed, error=%ld\n",IO->tdio_Error);
  188.  
  189.           pOS_CloseDevice((pOS_IORequest*)IO);
  190.         }
  191.         else printf("pOS_OpenDevice <%s> failed, error=%ld\n",Ops[1],IO->tdio_Error);
  192.         pOS_DeleteIORequest((pOS_IORequest*)IO);
  193.       }
  194.       else printf("pOS_CreateIORequest failed\n");
  195.       pOS_DestructMsgPort(&Port);
  196.     }
  197.     else printf("pOS_ConstructMsgPort failed\n");
  198.  
  199.     pOS_DeleteDosArgs(Args);  /* Args freigeben */
  200.   }
  201.   else Err=DOSFAIL_FAIL;  /* vollkommen fehlgeschlagen */
  202.  
  203.   pOS_SetShellFail(Err);
  204. }
  205.