/************************************************************
**
** Application: SyncDiscs
**
** Title:       h.arcs
**
*************************************************************/

/*
*
* Copyright (c) 2015, David Pilling and Chris Johnson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*   * Redistributions of source code must retain the above copyright
*     notice, this list of conditions and the following disclaimer.
*   * Redistributions in binary form must reproduce the above
*     copyright notice, this list of conditions and the following
*     disclaimer in the documentation and/or other materials provided
*     with the distribution.
*   * Neither the name of the copyright holder nor the names of their
*     contributors may be used to endorse or promote products derived
*     from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/


#pragma include_only_once

#ifndef __ARCS__H
#define __ARCS__H



#define NAMELEN 256


#define DNFILE  -1
#define DFLAT   -2


typedef struct heads
{
 int                name;    /* file name */

 int                modified:1;
 int                writecache:1;
 int                get:1;
 int                put:1;
 int                update:1;

 int                length;

 int                dirn;  /* -2==unopened dir, -1==file, else dir entries */

 int                load;
 int                exec;
 int                acc;

} heads;





typedef struct archive
{
 char       *  path;

 int           inuse:1;
 int           modified:1;
 int           ro:1;
 int           writecache:1;

 heads      *  hdr;
 int           nofiles;        /* no of files entries           */
 int           fmain;          /* no of files in root directory */

} archive;






/*************************************************************/
/* exported variables */


extern int  *  posn;
extern int  *  lno;
extern int  *  fpos;
extern char ** obje;

extern int  *  posn2;
extern int  *  lno2;
extern int  *  fpos2;


/*************************************************************/
/* exported functions */

extern os_error * levelstackcheck(int level);
extern int        parentof(archive * arc,int child);
extern int        noindir(int acn,int posn);
extern os_error * setnofiles(int acn,int n);
extern os_error * insentry(int acn,int fn,int ind,int size);
extern void       rementry(archive * arc,int fn,int size);

extern os_error * filepath(char * arcpath,int acn,int ins);
extern os_error * filepath1(char * arcpath,int acn,int ins);


extern archive * arc;
extern int       maxarc;



extern os_error * getarchandle(int * arcn);
extern os_error * scrapentry(int acn,int n,int size);
extern os_error * losearc(int acn);
extern os_error * closedir(int acn,int n,int * size);


extern os_error * arcsinit(void);




#endif



/*************  End of h.arcs  ***********************/







