1 /*
2  *
3  *   Copyright (C) 2012-2018 by C.H. Huang
4  *   plushuang.tw@gmail.com
5  *
6  *  This library is free software; you can redistribute it and/or
7  *  modify it under the terms of the GNU Lesser General Public
8  *  License as published by the Free Software Foundation; either
9  *  version 2.1 of the License, or (at your option) any later version.
10  *
11  *  This library is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  *  Lesser General Public License for more details.
15  *
16  *  You should have received a copy of the GNU Lesser General Public
17  *  License along with this library; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  *  ---
21  *
22  *  In addition, as a special exception, the copyright holders give
23  *  permission to link the code of portions of this program with the
24  *  OpenSSL library under certain conditions as described in each
25  *  individual source file, and distribute linked combinations
26  *  including the two.
27  *  You must obey the GNU Lesser General Public License in all respects
28  *  for all of the code used other than OpenSSL.  If you modify
29  *  file(s) with this exception, you may extend this exception to your
30  *  version of the file(s), but you are not obligated to do so.  If you
31  *  do not wish to do so, delete this exception statement from your
32  *  version.  If you delete this exception statement from all source
33  *  files in the program, then also delete it here.
34  *
35  */
36 
37 #ifndef UG_UTIL_H
38 #define UG_UTIL_H
39 
40 #include <time.h>
41 #include <stdint.h>
42 #include <UgList.h>
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 // ----------------------------------------------------------------------------
49 // Time
50 
51 uint64_t   ug_get_time_count (void);
52 
53 // ----------------------------------------------------------------------------
54 // Unicode
55 
56 int        ug_utf8_get_invalid (const char* input, char* ch);
57 
58 uint16_t*  ug_utf8_to_utf16 (const char* string, int stringLength,
59                              int* utf16len);
60 
61 char*      ug_utf16_to_utf8 (const uint16_t* string, int stringLength,
62                              int* utf8len);
63 
64 uint32_t*  ug_utf8_to_ucs4 (const char* string, int stringLength,
65                             int* ucs4len);
66 
67 char*      ug_ucs4_to_utf8 (const uint32_t* string, int stringLength,
68                             int* utf8len);
69 
70 // ----------------------------------------------------------------------------
71 // Base64
72 
73 char*  ug_base64_encode (const unsigned char* data,
74                          int  input_length,
75                          int* output_length);
76 
77 unsigned char* ug_base64_decode (const char* data,
78                                  int  input_length,
79                                  int* output_length);
80 
81 // ----------------------------------------------------------------------------
82 // filename & path functions
83 
84 char*  ug_build_filename (const char* first_element, ...);
85 
86 // ----------------------------------------------------------------------------
87 // Power Management
88 
89 // Suspend does not turn off your computer. It puts the computer and all peripherals on a low power consumption mode.
90 // Hibernate saves the state of your computer to the hard disk and completely powers off.
91 
92 void  ug_reboot (void);
93 void  ug_shutdown (void);
94 void  ug_suspend (void);
95 void  ug_hibernate (void);
96 
97 // ----------------------------------------------------------------------------
98 // Others
99 
100 char* ug_sys_release (void);
101 
102 #ifdef __cplusplus
103 }
104 #endif
105 
106 #endif // End of UG_UTIL_H
107 
108