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