Skip to content

Latest commit

 

History

History
95 lines (79 loc) · 2.2 KB

platform.h

File metadata and controls

95 lines (79 loc) · 2.2 KB
 
Mar 28, 2008
Mar 28, 2008
1
2
3
4
5
6
7
/**
* MojoPatch; a tool for updating data in the field.
*
* Please see the file LICENSE.txt in the source's root directory.
*
* This file written by Ryan C. Gordon.
*/
Jan 5, 2004
Jan 5, 2004
8
9
10
11
12
13
14
15
#ifndef _INCL_PLATFORM_H_
#define _INCL_PLATFORM_H_
#ifdef __cplusplus
extern "C" {
#endif
Jan 27, 2006
Jan 27, 2006
16
17
#ifdef __POWERPC__
#define PLATFORM_BIGENDIAN 1
Jan 31, 2006
Jan 31, 2006
18
19
#else
#define PLATFORM_BIGENDIAN 0
Jan 27, 2006
Jan 27, 2006
20
21
#endif
May 28, 2004
May 28, 2004
22
23
24
#define PATCHERROR 0
#define PATCHSUCCESS 1
Jan 5, 2004
Jan 5, 2004
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#if PLATFORM_WIN32
# include <io.h>
# define PATH_SEP "\\"
# if (defined _MSC_VER)
# define inline __inline
# define snprintf _snprintf
# define mkdir(x, y) _mkdir(x)
# define chdir(x) _chdir(x)
# endif
# define MAX_PATH 1024
#elif PLATFORM_UNIX
# include <unistd.h>
# include <sys/stat.h>
# include <sys/types.h>
# include <sys/param.h>
# include <fcntl.h>
# define PATH_SEP "/"
# define MAX_PATH MAXPATHLEN
#else
# #error please define your platform.
#endif
typedef struct MOJOPATCH_FILELIST
{
char *fname;
struct MOJOPATCH_FILELIST *next;
} file_list;
May 18, 2005
May 18, 2005
53
54
55
56
57
58
59
60
typedef enum
{
SPAWN_FILENOTFOUND,
SPAWN_FAILED,
SPAWN_RETURNGOOD,
SPAWN_RETURNBAD
} SpawnResult;
Jan 5, 2004
Jan 5, 2004
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* Your mainline calls this. */
int mojopatch_main(int argc, char **argv);
/* You call this for fatal error messages. */
void _fatal(const char *fmt, ...);
/* Call this for logging (not debug info). */
void _log(const char *fmt, ...);
/* Call this for logging (debug info). */
void _dlog(const char *fmt, ...);
/* platform-specific stuff you implement. */
int file_exists(const char *fname);
int file_is_directory(const char *fname);
int file_is_symlink(const char *fname);
file_list *make_filelist(const char *base); /* must use malloc(). */
Jan 27, 2006
Jan 27, 2006
78
int get_file_size(const char *fname, unsigned int *fsize);
May 18, 2005
May 18, 2005
79
char *get_current_dir(char *buf, size_t bufsize);
Jan 5, 2004
Jan 5, 2004
80
81
82
char *get_realpath(const char *path);
int update_version(const char *ver);
int calc_tmp_filenames(char **tmp1, char **tmp2);
Apr 22, 2005
Apr 22, 2005
83
int locate_product_by_identifier(const char *str, char *buf, size_t bufsize);
May 18, 2005
May 18, 2005
84
int get_product_version(const char *ident, char *buf, size_t bufsize);
May 18, 2005
May 18, 2005
85
86
SpawnResult spawn_xdelta(const char *cmdline);
SpawnResult spawn_script(const char *scriptname, const char *dstdir);
Jan 5, 2004
Jan 5, 2004
87
88
89
90
91
92
93
94
#ifdef __cplusplus
}
#endif
#endif /* include-once blocker. */
/* end of platform.h ... */