aboutsummaryrefslogtreecommitdiff
path: root/include/utils.h
blob: 0c4e30810a762f236a78c2e787b8df9017eb99cc (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
#ifndef OMC_UTILS_H
#define OMC_UTILS_H
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
#include "system.h"

#if defined(__WIN32__)
#define PATH_ENV_VAR "path"
#define DIR_SEP "\\"
#define PATH_SEP ";"
#define LINE_SEP "\r\n"
#else
#define PATH_ENV_VAR "PATH"
#define DIR_SEP "/"
#define PATH_SEP ":"
#define LINE_SEP "\n"
#endif

typedef int (ReaderFn)(size_t line, char **);

int pushd(const char *path);
int popd(void);
char *expandpath(const char *_path);
int rmtree(char *_path);
char **file_readlines(const char *filename, size_t start, size_t limit, ReaderFn *readerFn);
char *path_basename(char *path);
char *find_program(const char *name);
int touch(const char *filename);
int git_clone(struct Process *proc, char *url, char *destdir, char *gitref);
char *git_describe(const char *path);

#define OMC_MSG_SUCCESS 0
#define OMC_MSG_NOP 1 << 0
#define OMC_MSG_ERROR 1 << 1
#define OMC_MSG_WARN 1 << 2
#define OMC_MSG_L1 1 << 3
#define OMC_MSG_L2 1 << 4
#define OMC_MSG_L3 1 << 5
void msg(unsigned type, char *fmt, ...);
void debug_shell();

#endif //OMC_UTILS_H