aboutsummaryrefslogtreecommitdiff
path: root/include/spm.h
blob: 7ea295988329a2b97bd6547c9dcb74639d0cb88f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
 * @file spm.h
 */
#ifndef SPM_SPM_H
#define SPM_SPM_H

// Define some platform detection shortcuts
#define OS_DARWIN 0
#define OS_WINDOWS 0
#define OS_LINUX 0
#define OS_SUPPORTED 0

#if defined(__APPLE__) && defined(__MACH__)
#   undef OS_DARWIN
#   define OS_DARWIN 1
#   undef OS_SUPPORTED
#   define OS_SUPPORTED 1

//  TODO: Windows is not supported at all yet, so OS_SUPPORTED is untouched
#elif defined(_WIN32)
#   undef OS_WINDOWS
#   define OS_WINDOWS 1

#elif defined(__linux) || defined(__linux__)
#   undef OS_LINUX
#   define OS_LINUX 1
#   undef OS_SUPPORTED
#   define OS_SUPPORTED 1
#endif

#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include <sys/stat.h>
#include <openssl/md5.h>
#include <openssl/sha.h>

#if !OS_WINDOWS
#include <fts.h>
#include <glob.h>
#include <unistd.h>
#include <sys/utsname.h>
#include <utime.h>
#endif

#include "conf.h"
extern spm_vars SPM_GLOBAL;
#include "compat.h"
#include "error_handler.h"
#include "package.h"
#include "str.h"
#include "strlist.h"
#include "shlib.h"
#include "config.h"
#include "internal_cmd.h"
#include "environment.h"
#include "metadata.h"
#include "manifest.h"
#include "fs.h"
#include "version_spec.h"
#include "checksum.h"
#include "resolve.h"
#include "shell.h"
#include "relocation.h"
#include "archive.h"
#include "find.h"
#include "rpath.h"
#include "mime.h"
#include "mirrors.h"
#include "user_input.h"
#include "install.h"
#include "purge.h"

#define SYSERROR stderr, "%s:%s:%d: %s\n", basename(__FILE__), __FUNCTION__, __LINE__, strerror(errno)

#define DIRSEP_WIN32 '\\'
#define DIRSEPS_WIN32 "\\"
#define PATHSEP_WIN32 ';'
#define PATHSEPS_WIN32 ";"
#define DIRSEP_UNIX '/'
#define DIRSEPS_UNIX "/"
#define PATHSEP_UNIX ';'
#define PATHSEPS_UNIX ";"
#if OS_WINDOWS
#define DIRSEP  DIRSEP_WIN32
#define DIRSEPS  DIRSEPS_WIN32
#define NOT_DIRSEP DIRSEP_UNIX
#define NOT_DIRSEPS DIRSEPS_UNIX

#define PATHSEP PATHSEP_WIN32
#define PATHSEPS PATHSEPS_WIN32
#define NOT_PATHSEP PATHSEP_UNIX
#define NOT_PATHSEPS PATHSEPS_UNIX
#else
#define DIRSEP DIRSEP_UNIX
#define DIRSEPS DIRSEPS_UNIX
#define NOT_DIRSEP DIRSEP_WIN32
#define NOT_DIRSEPS DIRSEPS_WIN32

#define PATHSEP PATHSEP_UNIX
#define PATHSEPS PATHSEPS_UNIX
#define NOT_PATHSEP PATHSEP_WIN32
#define NOT_PATHSEPS PATHSEPS_WIN32
#endif

#define SPM_META_DEPENDS ".SPM_DEPENDS"
#define SPM_META_PREFIX_BIN ".SPM_PREFIX_BIN"
#define SPM_META_PREFIX_TEXT ".SPM_PREFIX_TEXT"
#define SPM_META_DESCRIPTOR ".SPM_DESCRIPTOR"
#define SPM_META_FILELIST ".SPM_FILELIST"
#define SPM_META_PREFIX_PLACEHOLDER \
"_0________________________________________________\
_1________________________________________________"

// GLOBALS

#if OS_DARWIN
extern char **environ;
#define __environ environ
#endif

#endif //SPM_SPM_H