home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / DC-POS24.LZX / pOS / pOS_RKRM.lzx / pOS_RKRM / pIFFParse / iffwrite.c < prev   
Encoding:
C/C++ Source or Header  |  1997-03-18  |  4.1 KB  |  154 lines

  1. #ifndef __INC_IFFWRITE_C
  2. #define __INC_IFFWRITE_C
  3. /*******************************************************************
  4.  $CRT 18 Dec 1996 : hp
  5.  
  6.  $AUT Holger Burkarth
  7.  $DAT >>iffwrite.c<<   29 Jan 1997    13:53:34 - (C) ProDAD
  8. *******************************************************************/
  9.  
  10. //##ex mcpp:cppc -gs -o pos:pos/ex/iffwrite p:pLib/StartCode.o p:/pOS_RKRM/pIFFParse/iffwrite.c p:pLib/StdIO.o -l pOSStub -l pOS -l CPPList
  11.  
  12. /***********************************************************
  13.   pOS programing example - Copyright (C) 1995-97 proDAD
  14.  
  15.   This code was written as an easy to understand example,
  16.   how to program pOS features. It is provided 'as-is',
  17.   without any express or implied warranty.
  18.  
  19.   Permission is hereby granted to use, copy and modify
  20.   this source code for any purpose, without fee, subject
  21.   to the following conditions:
  22.  
  23.     (1) This notice may not be removed or altered from any
  24.         source distribution.
  25.  
  26.     (2) Altered source versions must be plainly marked as
  27.         such, and must not be misrepresented as being
  28.         the original source code.
  29.  
  30.     (3) If only executable code is distributed, then the
  31.         accompanying documentation have to state that
  32.         "this software is based in part on examples of
  33.         the pOS developer packet".
  34.  
  35.     (4) Permission for use of this code is granted only
  36.         if the user accepts full responsibility for any
  37.         undesirable consequences. proDAD accept NO LIABILITY
  38.         for damages of any kind.
  39.  
  40.   ©proDAD
  41. ***********************************************************/
  42.  
  43. #include <p:pExec/Types.h>
  44. #include <p:pExec/Library.h>
  45. #include <p:pDOS/ArgTags.h>
  46. #include <p:pDOS/DosArgs.h>
  47. #include <p:pIFFParse/IFFParse.h>
  48. #include <p:pIFFParse/IFFParseTags.h>
  49. #include <p:proto/pExec2.h>
  50. #include <p:proto/pDOS2.h>
  51. #include <p:proto/pIFFParse2.h>
  52.  
  53. #ifdef _____ME_____
  54.   #include "grund/inc_string.h"
  55.   #include "grund/inc_stdio.h"
  56. #else
  57.  #ifdef __cplusplus
  58.  extern "C"  {
  59.  #endif
  60.   #include <string.h>
  61.   #include <stdio.h>
  62.  #ifdef __cplusplus
  63.  }
  64.  #endif
  65. #endif
  66.  
  67.  
  68. #define ID_ADRS MAKE_ID('A','D','R','S')
  69. #define ID_NAME MAKE_ID('N','A','M','E')
  70. #define ID_CITY MAKE_ID('C','I','T','Y')
  71.  
  72.  
  73. /*\
  74. *** !!!! Example - No Error Checking !!!!
  75. \*/
  76.  
  77. struct pOS_Library *gb_IFFParseBase;
  78.  
  79.  
  80. const CHAR *HelpText=
  81. ""
  82. ;
  83.  
  84. const CHAR *PrgHeader=
  85. "Demo for easy writing an IFF file";
  86.  
  87. const CHAR *PrgVerText=
  88. "$VER: 1.0 ("__DATE2__") (Copyright 1996-97 by proDAD) (Created by Holger Papajewski)";
  89.  
  90.  
  91.  
  92. #ifdef __cplusplus
  93. extern "C"
  94. #endif
  95.  
  96. void main()
  97. {
  98.   SLONG err=0;
  99.   ULONG Ops[1] = {(ULONG)"test.iff"};
  100.   pOS_DosArgs *Args;
  101.  
  102.   Args = pOS_ReadDosArgs( "NAME",Ops,sizeof(Ops)/sizeof(ULONG),
  103.     ARGTAG_PrgHeaderText, (ULONG)PrgHeader,    /* kurze Programm-Beschreibung */
  104.     ARGTAG_HelpText,      (ULONG)HelpText,     /* Help-Texte */
  105.     ARGTAG_PrgVerText,    (ULONG)PrgVerText,   /* VER-String */
  106.     TAG_DONE);
  107.  
  108.   if(Args) {
  109.     if(gb_IFFParseBase=pOS_OpenLibrary("piffparse.library",0L)) {
  110.  
  111.       pOS_IFFHandle *iff;
  112.  
  113.       iff=pOS_OpenIFF(IFFTAG_DosName,Ops[0],
  114.         IFFTAG_AccessMode,IFFACCMD_Write,TAG_DONE);
  115.  
  116.       if( iff ) {
  117.         pOS_PushChunk(iff,ID_ADRS,ID_CAT,IFF_SizeUnkown);
  118.           pOS_PushChunk(iff,ID_ADRS,ID_FORM,IFF_SizeUnkown);
  119.             pOS_PushChunk(iff,ID_ADRS,ID_NAME,IFF_SizeUnkown);
  120.             pOS_WriteChunkBytes(iff,"Hans ",5);
  121.             pOS_WriteChunkBytes(iff,"Mustermann",11);
  122.             pOS_PopChunk(iff);
  123.  
  124.             pOS_PushChunk(iff,ID_ADRS,ID_CITY,11);
  125.             pOS_WriteChunkBytes(iff,"Mustercity",11);
  126.             pOS_PopChunk(iff);
  127.           pOS_PopChunk(iff);
  128.  
  129.  
  130.           pOS_PushChunk(iff,ID_ADRS,ID_FORM,IFF_SizeUnkown);
  131.             pOS_PushChunk(iff,ID_ADRS,ID_NAME,7);
  132.             pOS_WriteChunkBytes(iff,"proDAD",7);
  133.             pOS_PopChunk(iff);
  134.  
  135.             pOS_PushChunk(iff,ID_ADRS,ID_CITY,IFF_SizeUnkown);
  136.             pOS_WriteChunkBytes(iff,"Immendingen",12);
  137.             pOS_PopChunk(iff);
  138.           pOS_PopChunk(iff);
  139.         pOS_PopChunk(iff);
  140.  
  141.         pOS_CloseIFF(iff);
  142.       }
  143.       else printf("Open IFF File |%s| Failed.\n",Ops[0]);
  144.  
  145.       pOS_CloseLibrary(gb_IFFParseBase);
  146.     }
  147.     else printf("Cannot Open IFFParse.library\n");
  148.  
  149.     pOS_DeleteDosArgs(Args);
  150.   }
  151. }
  152.  
  153. #endif
  154.