Commit 420ffef8 authored by Matthew Burket's avatar Matthew Burket

Work on main

parent f883da31
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include "connect.h"
/// Main method for the program
///
/// \param argc
/// \param argv
/// \return
int main (int argc, char **argv) {
int header_only = 0;
int timeDelta = 0;
char *cvalue = NULL;
int index;
int c;
struct addrinfo *addressInfo;
opterr = 0;
// getopts section based on
// https://www.gnu.org/software/libc/manual/html_node/Example-of-Getopt.html#Example-of-Getopt
while ((c = getopt(argc, argv, "hd:")) != -1)
switch (c) {
case 'h':
header_only = 1;
break;
case 'd':
timeDelta = 1;
cvalue = optarg;
break;
case '?':
if (optopt == 'd')
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
else if (isprint (optopt))
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
else
fprintf(stderr,
"Unknown option character `\\x%x'.\n",
optopt);
return 1;
default:
abort();
}
printf("header_only = %d, timeDelta = %d, cvalue = %s\n",
header_only, timeDelta, cvalue);
for (index = optind; index < argc; index++)
printf("Non-option argument %s\n", argv[index]);
init_connection(argv[optind], 80, &addressInfo);
int sockfd = establish_connect(addressInfo);
int main(char **argv, int argc) {
if (argc <= 1) {
fprintf(stderr, "[–h] [–d <time-interval>] <URL");
exit(EXIT_FAILURE);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment