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
|
// Utility functions for tests
#include <stdio.h>
#include <string.h>
// If we are on MSVC, disable some stupid MSVC warnings
#ifdef _MSC_VER
#pragma warning( disable: 4996 )
#endif
#undef LOG_WARN
#define LOG_WARN(...) fprintf(stderr, __VA_ARGS__)
#undef LOG_ERROR
#define LOG_ERROR LOG_WARN
static char *
_findbin(const char *cmd)
{
char *buf;
if (cmd[0] == '/') {
buf = strdup(cmd);
}
else {
buf = (char *)malloc(1024);
getcwd(buf, 1024);
strcat(buf, "/");
strcat(buf, cmd);
}
return buf;
}
static char *
_abspath(const char *bin, const char *path)
{
char *buf = (char *)malloc(1024);
char *last_slash = strrchr(bin, '/') + 1;
char *s = (char *)&bin[0];
char *d = &buf[0];
while (s != last_slash)
*d++ = *s++;
strcat(buf, path);
return buf;
}
#if (defined(__APPLE__) && defined(__MACH__))
#define LINK_NONE 0
#define LINK_ALIAS 1
#define LINK_SYMLINK 2
int isAlias(const char *incoming_path);
int CheckMacAlias(const char *incoming_path, char *out_path);
#endif
|