platform.h
author Ryan C. Gordon <icculus@icculus.org>
Mon, 05 Jan 2004 18:54:18 +0000
changeset 0 31eee864ed5d
child 8 013c7889f09e
permissions -rw-r--r--
Initial revision
icculus@0
     1
icculus@0
     2
#ifndef _INCL_PLATFORM_H_
icculus@0
     3
#define _INCL_PLATFORM_H_
icculus@0
     4
icculus@0
     5
#ifdef __cplusplus
icculus@0
     6
extern "C" {
icculus@0
     7
#endif
icculus@0
     8
icculus@0
     9
#if PLATFORM_WIN32
icculus@0
    10
#  include <io.h>
icculus@0
    11
#  define PATH_SEP "\\"
icculus@0
    12
#  if (defined _MSC_VER)
icculus@0
    13
#    define inline __inline
icculus@0
    14
#    define snprintf _snprintf
icculus@0
    15
#    define mkdir(x, y) _mkdir(x)
icculus@0
    16
#    define chdir(x) _chdir(x)
icculus@0
    17
#  endif
icculus@0
    18
#  define MAX_PATH 1024
icculus@0
    19
#elif PLATFORM_UNIX
icculus@0
    20
#  include <unistd.h>
icculus@0
    21
#  include <sys/stat.h>
icculus@0
    22
#  include <sys/types.h>
icculus@0
    23
#  include <sys/param.h>
icculus@0
    24
#  include <fcntl.h>
icculus@0
    25
#  define PATH_SEP "/"
icculus@0
    26
#  define MAX_PATH MAXPATHLEN
icculus@0
    27
#else
icculus@0
    28
#  #error please define your platform.
icculus@0
    29
#endif
icculus@0
    30
icculus@0
    31
typedef struct MOJOPATCH_FILELIST
icculus@0
    32
{
icculus@0
    33
    char *fname;
icculus@0
    34
    struct MOJOPATCH_FILELIST *next;
icculus@0
    35
} file_list;
icculus@0
    36
icculus@0
    37
/* Your mainline calls this. */
icculus@0
    38
int mojopatch_main(int argc, char **argv);
icculus@0
    39
icculus@0
    40
/* You call this for fatal error messages. */
icculus@0
    41
void _fatal(const char *fmt, ...);
icculus@0
    42
icculus@0
    43
/* Call this for logging (not debug info). */
icculus@0
    44
void _log(const char *fmt, ...);
icculus@0
    45
icculus@0
    46
/* Call this for logging (debug info). */
icculus@0
    47
void _dlog(const char *fmt, ...);
icculus@0
    48
icculus@0
    49
/* platform-specific stuff you implement. */
icculus@0
    50
int file_exists(const char *fname);
icculus@0
    51
int file_is_directory(const char *fname);
icculus@0
    52
int file_is_symlink(const char *fname);
icculus@0
    53
file_list *make_filelist(const char *base);  /* must use malloc(). */
icculus@0
    54
int get_file_size(const char *fname, long *fsize);
icculus@0
    55
char *get_current_dir(void);
icculus@0
    56
char *get_realpath(const char *path);
icculus@0
    57
int spawn_xdelta(const char *cmdline);
icculus@0
    58
int chdir_by_identifier(const char *id, const char *version);
icculus@0
    59
int update_version(const char *ver);
icculus@0
    60
int calc_tmp_filenames(char **tmp1, char **tmp2);
icculus@0
    61
int show_and_install_readme(const char *fname, const char *text);
icculus@0
    62
icculus@0
    63
#ifdef __cplusplus
icculus@0
    64
}
icculus@0
    65
#endif
icculus@0
    66
icculus@0
    67
#endif /* include-once blocker. */
icculus@0
    68
icculus@0
    69
/* end of platform.h ... */
icculus@0
    70