/*
- * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
#include "ipc/Kids.h"
#include "ipc/Strand.h"
#include "ipcache.h"
-#include "Mem.h"
-#include "MemPool.h"
#include "mime.h"
#include "neighbors.h"
#include "parser/Tokenizer.h"
#endif
#include <cerrno>
+#if HAVE_GETOPT_H
+#include <getopt.h>
+#endif
#if HAVE_PATHS_H
#include <paths.h>
#endif
static int opt_signal_service = FALSE;
static char *opt_syslog_facility = NULL;
-static int icpPortNumOverride = 1; /* Want to detect "-u 0" */
+static int icpPortNumOverride = 1; /* Want to detect "-u 0" */
static int configured_once = 0;
#if MALLOC_DBG
static int malloc_debug_level = 0;
{
public:
- int checkEvents(int timeout) {
+ int checkEvents(int) {
Store::Root().callback();
return EVENT_IDLE;
};
};
int
-SignalEngine::checkEvents(int timeout)
+SignalEngine::checkEvents(int)
{
PROF_start(SignalEngine_checkEvents);
usage(void)
{
fprintf(stderr,
- "Usage: %s [-cdhvzCFNRVYX] [-n name] [-s | -l facility] [-f config-file] [-[au] port] [-k signal]"
+ "Usage: %s [-cdzCFNRVYX] [-n name] [-s | -l facility] [-f config-file] [-[au] port] [-k signal]"
#if USE_WIN32_SERVICE
"[-ir] [-O CommandLine]"
#endif
+ "\n"
+ " -h | --help Print help message.\n"
+ " -v | --version Print version details.\n"
"\n"
" -a port Specify HTTP port number (default: %d).\n"
" -d level Write debugging to stderr also.\n"
" -f file Use given config-file instead of\n"
" %s\n"
- " -h Print help message.\n"
#if USE_WIN32_SERVICE
" -i Installs as a Windows Service (see -n option).\n"
#endif
" -s | -l facility\n"
" Enable logging to syslog.\n"
" -u port Specify ICP port number (default: %d), disable with 0.\n"
- " -v Print version.\n"
" -z Create missing swap directories and then exit.\n"
" -C Do not catch fatal signals.\n"
" -D OBSOLETE. Scheduled for removal.\n"
/**
* Parse the parameters received via command line interface.
*
- \param argc Number of options received on command line
- \param argv List of parameters received on command line
+ * \param argc Number of options received on command line
+ * \param argv List of parameters received on command line
*/
static void
mainParseOptions(int argc, char *argv[])
{
- extern char *optarg;
- int c;
+ int optIndex = 0;
+ // short options
+ const char *shortOpStr =
#if USE_WIN32_SERVICE
- while ((c = getopt(argc, argv, "CDFNO:RSVYXa:d:f:hik:m::n:rsl:u:vz?")) != -1)
-#else
- while ((c = getopt(argc, argv, "CDFNRSYXa:d:f:hk:m::n:sl:u:vz?")) != -1)
+ "O:Vir"
#endif
- {
+ "CDFNRSYXa:d:f:hk:m::n:sl:u:vz?";
+
+ // long options
+ static struct option squidOptions[] = {
+ {"help", no_argument, 0, 'h'},
+ {"version", no_argument, 0, 'v'},
+ {0, 0, 0, 0}
+ };
+
+ int c;
+ while ((c = getopt_long(argc, argv, shortOpStr, squidOptions, &optIndex)) != -1) {
switch (c) {
case 'd':
/** \par d
- * Set global option Debug::log_stderr to the number given follwoign the option */
+ * Set global option Debug::log_stderr to the number given following the option */
Debug::log_stderr = atoi(optarg);
break;
else if (!strncmp(optarg, "check", strlen(optarg)))
/** \li On check send 0 / SIGNULL. */
- opt_send_signal = 0; /* SIGNULL */
+ opt_send_signal = 0; /* SIGNULL */
else if (!strncmp(optarg, "parse", strlen(optarg)))
/** \li On parse set global flag to re-parse the config file only. */
opt_parse_cfg_only = 1;
exit(0);
- /* NOTREACHED */
+ /* NOTREACHED */
case 'z':
/** \par z
debugs(1, 3, "finishing reconfiguring");
errorClean();
- enter_suid(); /* root to read config file */
+ enter_suid(); /* root to read config file */
// we may have disabled the need for PURGE
if (Config2.onoff.enable_purge)
Mem::Report();
setEffectiveUser();
_db_init(Debug::cache_log, Debug::debugOptions);
- ipcache_restart(); /* clear stuck entries */
- fqdncache_restart(); /* sigh, fqdncache too */
+ ipcache_restart(); /* clear stuck entries */
+ fqdncache_restart(); /* sigh, fqdncache too */
parseEtcHosts();
- errorInitialize(); /* reload error pages */
+ errorInitialize(); /* reload error pages */
accessLogInit();
#if USE_LOADABLE_MODULES
eventDelete(start_announce, NULL);
}
- writePidFile(); /* write PID file */
+ writePidFile(); /* write PID file */
reconfiguring = 0;
}
#endif
externalAclShutdown();
- _db_rotate_log(); /* cache.log */
+ _db_rotate_log(); /* cache.log */
storeDirWriteCleanLogs(1);
- storeLogRotate(); /* store.log */
- accessLogRotate(); /* access.log */
+ storeLogRotate(); /* store.log */
+ accessLogRotate(); /* access.log */
#if ICAP_CLIENT
icapLogRotate(); /*icap.log*/
#endif
setEffectiveUser(void)
{
keepCapabilities();
- leave_suid(); /* Run as non privilegied user */
+ leave_suid(); /* Run as non privilegied user */
#if _SQUID_OS2_
return;
#endif
if (!configured_once)
- disk_init(); /* disk_init must go before ipcache_init() */
+ disk_init(); /* disk_init must go before ipcache_init() */
ipcache_init();
#endif
externalAclInit();
- httpHeaderInitModule(); /* must go before any header processing (e.g. the one in errorInitialize) */
+ httpHeaderInitModule(); /* must go before any header processing (e.g. the one in errorInitialize) */
- httpReplyInitModule(); /* must go before accepting replies */
+ httpReplyInitModule(); /* must go before accepting replies */
errorInitialize();
no_suid();
if (!configured_once)
- writePidFile(); /* write PID file */
+ writePidFile(); /* write PID file */
#if defined(_SQUID_LINUX_THREADS_)
Mem::Init();
- storeFsInit(); /* required for config parsing */
+ storeFsInit(); /* required for config parsing */
/* TODO: call the FS::Clean() in shutdown to do Fs cleanups */
Fs::Init();
Store::Root().sync(); /* Flush pending object writes/unlinks */
- unlinkdClose(); /* after sync/flush. NOP if !USE_UNLINKD */
+ unlinkdClose(); /* after sync/flush. NOP if !USE_UNLINKD */
storeDirWriteCleanLogs(0);
PrintRusage();
dumpMallocStats();
- Store::Root().sync(); /* Flush log writes */
+ Store::Root().sync(); /* Flush log writes */
storeLogClose();
accessLogClose();
- Store::Root().sync(); /* Flush log close */
+ Store::Root().sync(); /* Flush log close */
StoreFileSystem::FreeAllFs();
DiskIOModule::FreeAllModules();
#if LEAK_CHECK_MODE && 0 /* doesn't work at the moment */