1 // 2 // anyRemote 3 // a wi-fi or bluetooth remote for your PC. 4 // 5 // Copyright (C) 2006-2016 Mikhail Fedotov <anyremote@mail.ru> 6 // 7 // This program is free software; you can redistribute it and/or modify 8 // it under the terms of the GNU General Public License as published by 9 // the Free Software Foundation; either version 3 of the License, or 10 // (at your option) any later version. 11 // 12 // This program is distributed in the hope that it will be useful, 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 // GNU General Public License for more details. 16 // 17 // You should have received a copy of the GNU General Public License 18 // along with this program; if not, write to the Free Software 19 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 // 21 22 #ifndef _UTILS_H 23 #define _UTILS_H 24 25 #include "parse.h" 26 27 #define LOGFILE "/anyremote.log" 28 29 enum LogType { 30 L_CFG = 0, 31 L_INF, 32 L_DBG, 33 L_WARN, 34 L_ERR 35 }; 36 37 #define CFG2(...) sprintf(tmp,__VA_ARGS__);logger(L_CFG, tmp); 38 #define DEBUG2(...) sprintf(tmp,__VA_ARGS__);logger(L_DBG, tmp); 39 #define ERROR2(...) sprintf(tmp,__VA_ARGS__);logger(L_ERR, tmp); 40 #define INFO2(...) sprintf(tmp,__VA_ARGS__);logger(L_INF, tmp); 41 #define WARNING2(...) sprintf(tmp,__VA_ARGS__);logger(L_WARN, tmp); 42 43 #define M_ABORT 0 44 #define M_DISCONNECT 1 45 #define M_DEV_DISCONN 2 46 47 #define CNV_TO 1 48 #define CNV_FROM 0 49 50 void printHelp (void); 51 void printTime (void); 52 void printVars (void); 53 void initLog (void); 54 void releaseLog (void); 55 void logger (int head, const char *str); 56 57 void freeMMessage (void *mm); 58 59 int flushData (void); 60 void flushOldConf (void); 61 62 int getUidGid (char *username, uid_t *uid, gid_t *gid); 63 64 void addInternalVars (void); 65 66 void sendAbort (void); 67 void sendDisconnect (void); 68 69 int needConvert (void); 70 71 void errnoDebug(const char* tag, int err); 72 73 void stripCommandEnding(char *s); 74 75 #ifdef USE_ICONV 76 void encodingHook (void); 77 void closeConvertor (void); 78 char * convCharset (char *str, size_t size, int direction); 79 char * convCharsetSimple(char *str, int direction); 80 #endif 81 82 #endif 83