/* myMPD (c) 2018-2019 Juergen Mang This project's homepage is: https://github.com/jcorporation/mympd myMPD ist fork of: ympd (c) 2013-2014 Andrew Karpow This project's homepage is: http://www.ympd.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef __GLOBAL_H__ #define __GLOBAL_H__ #include #include #include //architecture #cmakedefine PKGARCH64 //myMPD version from cmake #define MYMPD_VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR} #define MYMPD_VERSION_MINOR ${CPACK_PACKAGE_VERSION_MINOR} #define MYMPD_VERSION_PATCH ${CPACK_PACKAGE_VERSION_PATCH} #define MYMPD_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}" //Webserver document root #define DOC_ROOT "${ASSETS_PATH}" //Max size of mpd_client response buffer #define MAX_SIZE 2048 * 400 #define MAX_ELEMENTS_PER_PAGE 400 //central logging definition #cmakedefine DEBUG #define LOG_INFO() if (config.loglevel >= 1) #define LOG_VERBOSE() if (config.loglevel >= 2) #define LOG_DEBUG() if (config.loglevel == 3) //check and return buffer size #define CHECK_RETURN_LEN() do { \ if (len > MAX_SIZE) \ printf("Buffer truncated: %d, %d\n", len, MAX_SIZE); \ return len; \ } while (0) //enumeration helpers #define GEN_ENUM(X) X, #define GEN_STR(X) #X, //signal handler sig_atomic_t s_signal_received; //myMPD configuration typedef struct { long mpdport; const char *mpdhost; const char *mpdpass; const char *webport; bool ssl; const char *sslport; const char *sslcert; const char *sslkey; const char *user; bool coverimage; const char *coverimagename; long coverimagesize; bool stickers; bool mixramp; const char *taglist; const char *searchtaglist; const char *browsetaglist; bool smartpls; const char *varlibdir; const char *etcdir; unsigned long max_elements_per_page; bool syscmds; bool localplayer; long streamport; const char *streamurl; unsigned long last_played_count; long loglevel; } t_config; t_config config; //global functions int randrange(int n); void sanitize_string(const char *data); int copy_string(char * const dest, char const * const src, size_t const dst_len, size_t const src_len); #endif