add __mg_get_extension and __mg_extract_integers

This commit is contained in:
Vincent Wei
2020-01-10 10:55:12 +08:00
parent c2b0de97d2
commit 57ff3c9267
+16 -1
View File
@@ -72,8 +72,9 @@ struct timezone {
#include <sys/types.h>
#endif
/* Function definitions */
#include <string.h> // for strrchr
/* Function definitions */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@@ -114,6 +115,20 @@ BOOL __mg_is_abs_path (const char* path);
int __mg_path_joint (char* dst, int dst_size, const char* abs_path,
const char* sub_path);
/* Since 4.2.0 */
static inline
const char* __mg_get_extension (const char* filename) {
const char* ext;
ext = strrchr (filename, '.');
if (ext)
return ext + 1;
return NULL;
}
// Extract integers in pattern like "100x100" or "100,100", and returns
// the number of integers extracted successfully.
int __mg_extract_integers (const char* s, int c, int* ab, int max_nr);
/* Since 4.2.0 */
#ifndef __NOUNIX__
int __mg_create_anonymous_file (off_t size, const char* debug_name,