All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
util.h
Go to the documentation of this file.
1 /*
2  * util.h - APme: Aion Automatic Abyss Point Tracker
3  *
4  * Copyright (C) 2012 Mitja Horvat <pinkfluid@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or (at
9  * your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19  */
20 
27 #ifndef UTIL_H_INCLUDED
28 #define UTIL_H_INCLUDED
29 
30 #include <stdio.h>
31 #include <stdint.h>
32 
39 #ifdef SYS_WINDOWS
40 
41 #include <windows.h>
42 #define UTIL_MAX_PATH MAX_PATH
43 #else
44 
45 #include <limits.h>
46 #define UTIL_MAX_PATH PATH_MAX
47 #endif
48 
49 extern bool clipboard_set_text(char *text);
50 extern bool clipboard_get_text(char *text, size_t text_sz);
51 extern bool sys_is_admin(bool *isadmin);
52 extern bool sys_runas_admin(char *path);
53 extern bool sys_self_exe(char *path, size_t pathsz);
54 extern bool sys_self_elevate(void);
55 extern bool sys_perm_grant(char *path);
56 extern FILE* sys_fopen_force(char *path, char *mode);
57 extern bool sys_appdata_path(char *path, size_t pathsz);
58 extern uint64_t sys_monotime(void);
59 
60 extern char* util_strsep(char **pinputstr, const char *delim);
61 extern size_t util_strlncat(char *dst, const char *src, size_t dst_size, size_t nchars);
62 extern size_t util_strlcpy(char *dst, const char *src, size_t dst_size);
63 extern size_t util_strlcat(char *dst, const char *src, size_t dst_size);
64 extern void util_strrep(char *out, size_t outsz, char *in, char *findstr, char *replacestr);
65 extern void util_chomp(char *str);
66 
67 /* Registry stuff */
68 extern bool reg_read_key(char *key, char *val, void *buf, size_t buflen);
69 
70 /* Codepage stuff */
71 void util_cp1252_to_utf8(char *utf8, ssize_t utf8_sz, char *cp1252);
72 
76 #endif // UTIL_H_INCLUDED