summaryrefslogtreecommitdiff
path: root/xcache/xc_compatibility.c
blob: 07ad6f5e71e11c2f2af544a90fc3cea59944ca05 (plain)
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
#include "xc_compatibility.h"

#ifndef ZEND_ENGINE_2_3
#include "ext/standard/php_string.h"
size_t xc_dirname(char *path, size_t len) /* {{{ */
{
#ifdef ZEND_ENGINE_2
	return php_dirname(path, len);
#else
	php_dirname(path, len);
	return strlen(path);
#endif
}
/* }}} */

long xc_atol(const char *str, int str_len) /* {{{ */
{
	long retval;

	if (!str_len) {
		str_len = strlen(str);
	}

	retval = strtol(str, NULL, 0);
	if (str_len > 0) {
		switch (str[str_len - 1]) {
		case 'g':
		case 'G':
			retval *= 1024;
			/* break intentionally missing */
		case 'm':
		case 'M':
			retval *= 1024;
			/* break intentionally missing */
		case 'k':
		case 'K':
			retval *= 1024;
			break;
		}
	}

	return retval;
}
/* }}} */
#endif