OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Update.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 /* Update package support */
17 
18 #ifndef INC_C4GroupEx
19 #define INC_C4GroupEx
20 
21 #include "lib/C4InputValidation.h"
22 
23 const int C4UP_MaxUpGrpCnt = 50;
24 
26 {
27 public:
28  int32_t RequireVersion[4] = { 0, 0, 0, 0 };
29  char Name[C4MaxName + 1] = { 0 };
30  char DestPath[_MAX_PATH + 1] = { 0 };
31  int32_t GrpUpdate = 0;
32  int32_t UpGrpCnt = 0; // number of file versions that can be updated by this package
33  uint32_t GrpChks1[C4UP_MaxUpGrpCnt] = { 0 }, GrpChks2 = 0;
34 public:
35  void CompileFunc(StdCompiler *pComp);
36  bool Load(C4Group &hGroup);
37  bool Save(C4Group &hGroup);
38 };
39 
40 #define C4UPD_CHK_OK 0
41 #define C4UPD_CHK_NO_SOURCE 1
42 #define C4UPD_CHK_BAD_SOURCE 2
43 #define C4UPD_CHK_ALREADY_UPDATED 3
44 #define C4UPD_CHK_BAD_VERSION 4
45 
47 {
48 
49 public:
50  bool Load(C4Group *pGroup);
51  bool Execute(C4Group *pGroup);
52  static bool Optimize(C4Group *pGrpFrom, const char *strTarget);
53  int Check(C4Group *pGroup);
54  bool MakeUpdate(const char *strFile1, const char *strFile2, const char *strUpdateFile, const char *strName = nullptr);
55 
56 protected:
57  bool DoUpdate(C4Group *pGrpFrom, class C4GroupEx *pGrpTo, const char *strFileName);
58  bool DoGrpUpdate(C4Group *pUpdateData, class C4GroupEx *pGrpTo);
59  static bool Optimize(C4Group *pGrpFrom, class C4GroupEx *pGrpTo, const char *strFileName);
60 
61  bool MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGr, bool *fModified);
62 
63  bool OpenUnpackParents(C4GroupEx &rGroup, const char *strGroup, const char *strEnsureMaker);
64 
66  void WriteLog(const char *strMsg, ...) GNUC_FORMAT_ATTRIBUTE_O;
67 };
68 
69 bool C4Group_ApplyUpdate(C4Group &hGroup, unsigned long ParentProcessID);
70 
71 #endif
const int C4UP_MaxUpGrpCnt
Definition: C4Update.h:23
bool MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGr, bool *fModified)
Definition: C4Update.cpp:694
void CompileFunc(StdCompiler *pComp)
Definition: C4Update.cpp:230
bool DoGrpUpdate(C4Group *pUpdateData, class C4GroupEx *pGrpTo)
Definition: C4Update.cpp:527
bool OpenUnpackParents(C4GroupEx &rGroup, const char *strGroup, const char *strEnsureMaker)
char DestPath[_MAX_PATH+1]
Definition: C4Update.h:30
int Check(C4Group *pGroup)
Definition: C4Update.cpp:431
#define _MAX_PATH
uint32_t GrpChks2
Definition: C4Update.h:33
#define GNUC_FORMAT_ATTRIBUTE_O
int32_t RequireVersion[4]
Definition: C4Update.h:28
uint32_t GrpChks1[C4UP_MaxUpGrpCnt]
Definition: C4Update.h:33
bool Execute(C4Group *pGroup)
Definition: C4Update.cpp:303
const unsigned int C4MaxName
int32_t GrpUpdate
Definition: C4Update.h:31
CStdFile Log
Definition: C4Update.h:65
bool Load(C4Group &hGroup)
Definition: C4Update.cpp:241
char Name[C4MaxName+1]
Definition: C4Update.h:29
bool DoUpdate(C4Group *pGrpFrom, class C4GroupEx *pGrpTo, const char *strFileName)
Definition: C4Update.cpp:472
void WriteLog(const char *strMsg,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: C4Update.cpp:825
static bool Optimize(C4Group *pGrpFrom, const char *strTarget)
Definition: C4Update.cpp:398
bool Load(C4Group *pGroup)
Definition: C4Update.cpp:280
bool Save(C4Group &hGroup)
Definition: C4Update.cpp:260
bool MakeUpdate(const char *strFile1, const char *strFile2, const char *strUpdateFile, const char *strName=nullptr)
Definition: C4Update.cpp:600
bool C4Group_ApplyUpdate(C4Group &hGroup, unsigned long ParentProcessID)
Definition: C4Update.cpp:42
int32_t UpGrpCnt
Definition: C4Update.h:32