vita-toolchain

git clone https://git.neptards.moe/neptards/vita-toolchain.git
Log | Files | Refs | README | LICENSE

elf-create-argp.c (918B)


      1 #include "elf-create-argp.h"
      2 
      3 #include <stdio.h>
      4 #include <stdlib.h>
      5 #include <unistd.h>
      6 
      7 int parse_arguments(int argc, char *argv[], elf_create_args *arguments)
      8 {
      9 	int c;
     10 
     11 	arguments->log_level = 0;
     12 	arguments->check_stub_count = 1;
     13 
     14 	while ((c = getopt(argc, argv, "vne:")) != -1)
     15 	{
     16 		switch (c)
     17 		{
     18 		case 'v':
     19 			arguments->log_level++;
     20 			break;
     21 		case 'e':
     22 			arguments->exports = optarg;
     23 			break;
     24 		case 'n':
     25 			arguments->check_stub_count = 0;
     26 			break;
     27 		case '?':
     28 			fprintf(stderr, "unknown option -%c\n", optopt);
     29 			return -1;
     30 		default:
     31 			abort();
     32 		}
     33 	}
     34 
     35 	if (argc - optind < 2)
     36 	{
     37 		printf("too few arguments\n");
     38 		return -1;
     39 	}
     40 	
     41 	arguments->input = argv[optind];
     42 	arguments->output = argv[optind+1];
     43 	
     44 	if (argc - optind > 2)
     45 	{
     46 		arguments->extra_imports = &argv[optind+2];
     47 		arguments->extra_imports_count = argc-(optind+2);
     48 	}
     49 	
     50 	return 0;
     51 }