import getopt


def findConfigFileNameInArgv(argv, configFileDir=''):
    """ Resolves configuration file. Resolution goes as follows:
    if the command switch '-c' is given it's argument is taken as
    the config file. Otherwise the function falls back to
    'server.cfg' in the current directory. """

    configFileName = configFileDir+'server.cfg'

    optionsList, notUsedArguments = getopt.getopt(argv[1:], 'c:')

    for i in optionsList:
        option, value = i
        if option == '-c' and value != '':
            configFileName = value
            break

    return configFileName