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

  1.  
  2. /*******************************************************************
  3.  $CRT 26 Oct 1996 : hb
  4.  
  5.  $AUT Holger Burkarth
  6.  $DAT >>TstPath.c<<   29 Nov 1996    18:06:30 - (C) ProDAD
  7. *******************************************************************/
  8.  
  9. //##ex mcpp:cppc -gs -o pos:pos/Ex/TstPath p:pLib/StartCode.o p:/pOS_RKRM/pDos/TstPath.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:pDOS/ArgTags.h"
  53. #include "p:pDOS/DosSig.h"
  54. #include "p:pDOS/DosErrors.h"
  55. #include "p:pDOS/Process.h"
  56. #include "p:pDos/Files.h"
  57. #include "p:pDos/Lock.h"
  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 by proDAD) (Created by Holger Burkarth)";
  86.  
  87.  
  88.  
  89. /*----------------------------------
  90. -----------------------------------*/
  91. #ifdef __cplusplus
  92. extern "C"
  93. #endif
  94.  
  95. VOID main()
  96. {
  97.   struct pOS_DosArgs* Args;
  98.   ULONG Ops[2]={0};
  99.  
  100.   Args=pOS_ReadDosArgs(
  101. // 0     1
  102. "NAME, ADD/K",
  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.     dosname_t *Str,Name[pOS_DosPathName_MAX];
  112.     struct pOS_FileLock *Lk;
  113.  
  114.     strcpy(Name,(CHAR*)Ops[0]);
  115.     if(Ops[1]) {
  116.       pOS_AddPart(Name,(dosname_t*)Ops[1],pOS_DosPathName_MAX);
  117.       printf("Added Path <%s>\n",Name);
  118.     }
  119.  
  120.     printf("FilePart <%s>\n",pOS_FilePart(Name));
  121.     Str=pOS_PathPart(Name);
  122.     if(Str) {
  123.       *Str=0;
  124.       printf("ParthPart <%s>\n",Name);
  125.     }
  126.  
  127.  
  128.     if(Lk=pOS_LockObject(NULL,Name,FILELKACC_Shared)) {
  129.       printf("FileLock=0x%lx, Name=<%s> fl_Flags==0x%lx\n",
  130.               Lk,Ops[0],Lk->fl_Flags);
  131.  
  132.       if(pOS_NameFromObjectLock(Lk,Name,pOS_DosPathName_MAX)) {
  133.         printf("Full Name <%s>\n",Name);
  134.       }
  135.       else pOS_PrintDosErr(NULL,(CHAR*)Ops[0],0);
  136.       pOS_UnlockObject(Lk);
  137.     }
  138.     else pOS_PrintDosErr(NULL,(CHAR*)Ops[0],0);
  139.  
  140.     pOS_DeleteDosArgs(Args);
  141.   }
  142. }
  143.  
  144.  
  145.