/* * kissdx - KiSS PC-Link Daemon eXtended (based on kissd) * * Copyright (C) 2005 Stelian Pop * Portions Copyright (C) 2006 Vidar Tysse * Portions Copyright (C) 2007 Olivier Kahn * * Heavily based on kiss4lin, * Copyright (C) 2004 Jacob Kolding * * 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; either version 2, or (at your option) * any later version. * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include #include #include // Definition of u_short // Options object is used to store "Command Line Options" in order to populate correctly config object // The final configuration of kissdx is stored in >> config.h|config object << // Every action and/or decision inside kissdx should be decided upon config object values typedef struct option_set_s { char *config_file; // -c --config int daemonize; // -d --daemon char help; // -h --help (flag: 0 is false - 1 is true) // administration command requirement section : char *mediacenter; // -m full hostname or ip adress of mediacenter to administrate short adminserver_port; // -p port of mediacenter to start an admin tcp connection char admincommand[512]; // kissdx as a client : command to be sent to kissdx admin handle (STOP, RELOADCONFIG, STATUS, ...) // kissdx as a server : store admin command received before acting char adminparam[512]; // kissdx as a client : parameter of an admin command (-s lvi /album1) short loglevel; // -v --verbose log 1=Err 2=Warn 3=Proto 4=Info 5=Debug char custoption1[512]; // -x customOptionValue1 char custoption2[512]; // -y customOptionValue1 char custoption3[512]; // -z customOptionValue1 } option_set_t; extern option_set_t options; extern short adminserver_port_CLO; // Default: adminserver_port is not detected from command line options extern short loglevel_CLO; // Default: loglevel is not detected from command line options #define options_admincommand_len 512 #define KISSDX_VERSION "v0.14.0.b2" #define KISSDX_VERSION_DATE __DATE__ extern char launchedArgument[]; extern char launchedTimeDate[]; enum mediastore_t {mst_unknown=0, mst_audio, mst_video, mst_picture}; extern int standard_filemode; extern int standard_dir_filemode; extern int is_socket_timed_out; extern time_t last_time_list_hidden_entries_on; extern int is_image_scaling_enabled; //------------------------------------------------------------------ void clean_pathname(char *path); char * extended_logfile_format(const char *format); // ===================================================================================== #define log(format, args...) \ do { \ if (options.daemonize) \ syslog(LOG_WARNING, extended_logfile_format(format), args); \ else \ fprintf(stderr, extended_logfile_format(format "\n"), args); \ } while(0) // ===================================================================================== #define log0(txt) \ do { \ if (options.daemonize) \ syslog(LOG_WARNING, extended_logfile_format(txt)); \ else \ fprintf(stderr, extended_logfile_format(txt "\n")); \ } while(0) // ===================================================================================== #define logv(format, args...) \ do { \ if (config.loglevel == LOGDEBUG) { \ if (options.daemonize) \ syslog(LOG_INFO, extended_logfile_format(format), args); \ else \ fprintf(stderr, extended_logfile_format(format "\n"), args); \ } \ } while(0) // ===================================================================================== #define logv0(txt) \ do { \ if (config.loglevel == LOGDEBUG) { \ if (options.daemonize) \ syslog(LOG_INFO, extended_logfile_format(txt)); \ else \ fprintf(stderr, extended_logfile_format(txt "\n")); \ } \ } while(0) // ===================================================================================== // temporary support both verbose and loglevel (backward compatibility) // in final step: verbose mode = loglevel.Debug #define loglevel(minlevel,format, args...) \ do { \ if (config.loglevel>=minlevel) { \ if (options.daemonize) \ syslog(LOG_INFO, extended_logfile_format(format), args); \ else \ fprintf(stderr, extended_logfile_format(format "\n"), args); \ } \ } while(0) // ===================================================================================== #define loglevel0(minlevel,txt) \ do { \ if (config.loglevel>=minlevel) { \ if (options.daemonize) \ syslog(LOG_INFO, extended_logfile_format(txt)); \ else \ fprintf(stderr, extended_logfile_format(txt "\n")); \ } \ } while(0) // ===================================================================================== #define min(a, b) (((a) < (b)) ? (a) : (b)) #define max(a, b) (((a) > (b)) ? (a) : (b)) #define LOCAL_COMMAND_SIZE 512 extern char commandserver_path[]; #define PORT_PCLINK 8000 // Port number defined in KiSS player internaly (not updatable) #define PORT_KML 8888 // Port number defined in KiSS player internaly (not updatable) #define PORT_ADMCMD 8003 // Port number for Administration utility command only (not the server setting) // --- end ---