/* * kissdx - KiSS PC-Link Daemon eXtended (based on kissd) * * Copyright (C) 2005 Stelian Pop * Portions Copyright (C) 2006 Vidar Tysse * * 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 typedef struct option_set_s { char *config_file; int list_hidden_entries; int daemonize; int kml_forwarder; int verbose; } option_set_t; extern option_set_t options; #define KISSD_VERSION "v0.13-10, 2007-01-20" 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; void handle_request(int sock); void handle_kmlrequest(int sock); void clean_pathname(char *path); int do_send(int sock, char *buffer, int size); 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 (options.verbose) { \ 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 (options.verbose) { \ 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[];