// This is a personal academic project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include "include/sockets.h" void setSockAddress(int argc, char *argv[], struct sockaddr_in * address) { address->sin_family = AF_INET; if (argc == 1) { address->sin_addr.s_addr = inet_addr(ADDRESS); address->sin_port = htons(PORT); } int opt; while ((opt = getopt(argc, argv, "a:p:")) != -1) { switch (opt) { case 'a': if (optarg[0] == '-') printError("Usage: server [-a address] [-p port]\n"); address->sin_addr.s_addr = inet_addr(optarg); break; case 'p': if (optarg[0] == '-') printError("Usage: server [-a address] [-p port]\n"); address->sin_port = htons(atoi(optarg)); break; default: printError("Usage: server [-a address] [-p port]\n"); } } }