File: common.h

package info (click to toggle)
libmediascan 0~20220401.git.34fc2d-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,208 kB
  • sloc: ansic: 17,054; sh: 4,228; objc: 261; perl: 225; makefile: 101
file content (61 lines) | stat: -rw-r--r-- 1,047 bytes parent folder | download | duplicates (2)
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