home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / DC-POS24.LZX / pOS / pOS_RKRM.lzx / pOS_RKRM / pSL / FileReq.c next >
Encoding:
C/C++ Source or Header  |  1997-03-18  |  5.3 KB  |  177 lines

  1.  
  2. /*******************************************************************
  3.  $CRT 29 Oct 1996 : hb
  4.  
  5.  $AUT Holger Burkarth
  6.  $DAT >>FileReq.c<<   29 Jan 1997    13:31:40 - (C) ProDAD
  7. *******************************************************************/
  8.  
  9. //##ex mcpp:cppc -gs -o pos:pos/Ex/FileReq p:pLib/StartCode.o p:/pOS_RKRM/pSL/FileReq.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:psl/FileReq.h"
  56. #include "p:psl/pSLTags.h"
  57. #include "p:pDtType/DosObj.h"
  58. #include "p:proto/pExec2.h"
  59. #include "p:proto/pDOS2.h"
  60. #include "p:proto/pPSL2.h"
  61.  
  62.  
  63. #ifdef _____ME_____
  64.   #include "grund/inc_string.h"
  65.   #include "grund/inc_stdio.h"
  66. #else
  67.  #ifdef __cplusplus
  68.  extern "C" {
  69.  #endif
  70.   #include <string.h>
  71.   #include <stdio.h>
  72.  #ifdef __cplusplus
  73.  }
  74.  #endif
  75. #endif
  76.  
  77.  
  78. const CHAR *HelpText=
  79. ""
  80. ;
  81.  
  82. const CHAR *PrgHeader=
  83. "";
  84.  
  85. const CHAR *PrgVerText=
  86. "$VER: 1.0 ("__DATE2__") (Copyright 1996-97 by proDAD) (Created by Holger Burkarth)";
  87.  
  88.  
  89. struct pOS_pSLBase     *gb_PSLBase;
  90.  
  91.  
  92. /*----------------------------------
  93. -----------------------------------*/
  94. extern "C" VOID main()
  95. {
  96.   struct pOS_DosArgs* Args;
  97.   UWORD Err=0;
  98.   ULONG Ops[19]={0,0,0,0,0,1,1,1,1,1, 0,0,0,-1,-1,0,0,0,1};
  99.  
  100.   gb_PSLBase=(struct pOS_pSLBase*)pOS_OpenLibrary("psl.library",0);
  101.  
  102.   if(gb_PSLBase) {
  103.     Args=pOS_ReadDosArgs(
  104. // 0       1        2         3        4          5             6
  105. "PATH/K, FILE/K, TITLE/K, PATTERN/K, PATGAD/S, NOINFOS/S, DOUBLEKLICK/S "
  106. // 7        8          9           10           11        12         13
  107. "DIRS/S, FILES/S, MATCHFILES/S, MATCHDIRS/S, POSTEXT/K, NEGTEXT/K, LEFT/N/K "
  108. //  14       15             16          17          18
  109. "TOP/N/K, ONLYDIRS/S, MULTISELECT/S, SAVEMODE/S, OWCHECK/S",
  110. Ops,sizeof(Ops)/sizeof(ULONG),
  111.  
  112.       ARGTAG_PrgHeaderText, (ULONG)PrgHeader,    /* kurze Programm-Beschreibung */
  113.       ARGTAG_HelpText,      (ULONG)HelpText,     /* Help-Texte */
  114.       ARGTAG_PrgVerText,    (ULONG)PrgVerText,   /* VER-String */
  115.       TAG_END);
  116.  
  117.     if(Args) {
  118.       struct pOS_PslFileRequester *Req;
  119.  
  120.       Req=pOS_AllocFileRequest(
  121.            TAG_END);
  122.  
  123.       if(Req) {
  124.         SLONG Res;
  125.  
  126.         Res=pOS_PslFileRequest(Req,
  127.             PSLFRTAG_PathPart,    (ULONG)Ops[0],
  128.             PSLFRTAG_FilePart,    (ULONG)Ops[1],
  129.             PSLFRTAG_Title,       (ULONG)Ops[2],
  130.             PSLFRTAG_Pattern,     (ULONG)Ops[3],
  131.             PSLFRTAG_PatternGad,  (ULONG)Ops[4],
  132.             PSLFRTAG_FilterInfos, (ULONG)Ops[5],
  133.             PSLFRTAG_DoubleKlick, (ULONG)Ops[6],
  134.             PSLFRTAG_ShowDirs,    (ULONG)Ops[7],
  135.             PSLFRTAG_ShowFiles,   (ULONG)Ops[8],
  136.             PSLFRTAG_MatchFiles,  (ULONG)Ops[9],
  137.             PSLFRTAG_MatchDirs,   (ULONG)Ops[10],
  138.             PSLFRTAG_PositiveText,(ULONG)Ops[11],
  139.             PSLFRTAG_NegativeText,(ULONG)Ops[12],
  140.             PSLFRTAG_LeftEdge,    *((ULONG*)Ops[13]),
  141.             PSLFRTAG_TopEdge,     *((ULONG*)Ops[14]),
  142.             PSLFRTAG_OnlyDirs,     (ULONG)Ops[15],
  143.             PSLFRTAG_MultiSelect,  (ULONG)Ops[16],
  144.             PSLFRTAG_SaveMode,     (ULONG)Ops[17],
  145.             PSLFRTAG_OWCheck,      (ULONG)Ops[18],
  146.             TAG_END);
  147.  
  148.         if(Req->pfr_DDNum>0) {
  149.           if(Ops[16] !=0 ) { // Multi
  150.             UWORD i;
  151.             dosname_t Buffer[pOS_DosPathName_MAX];
  152.             for(i=0; i<Req->pfr_DDNum; ++i) {
  153.               pOS_NameFromObjectLock(Req->pfr_DDList[i].dtdos_Lock,Buffer,sizeof(Buffer));
  154.               pOS_AddPart(Buffer,Req->pfr_DDList[i].dtdos_Buffer,sizeof(Buffer));
  155.               printf("\"%s\" ",Buffer);
  156.             }
  157.             printf("\n");
  158.           }
  159.           else printf("%s%s\n",Req->pfr_Path,Req->pfr_File);
  160.         }
  161.         else Err=DOSFAIL_WARN;
  162.  
  163.         pOS_FreePslRequest(Req);
  164.       }
  165.       else printf("pOS_AllocFileRequest() - failed\n");
  166.       pOS_DeleteDosArgs(Args);  /* Args freigeben */
  167.     }
  168.     else Err=DOSFAIL_FAIL;  /* vollkommen fehlgeschlagen */
  169.   }
  170.   else {
  171.     Err=DOSFAIL_FAIL;  /* vollkommen fehlgeschlagen */
  172.     printf("Cannot open psl.library\n");
  173.   }
  174.   pOS_SetShellFail(Err);
  175.   if(gb_PSLBase) pOS_CloseLibrary((struct pOS_Library*)gb_PSLBase);
  176. }
  177.