mtool_main.c (1361B)
1 /* Copyright (C) 2025 |Méso|Star> (contact@meso-star.com) 2 * 3 * This program is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, either version 3 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 16 #include "mtool.h" 17 #include "mtool_args.h" 18 19 #include <rsys/mem_allocator.h> 20 21 int 22 main(int argc, char** argv) 23 { 24 struct mtool_args args = MTOOL_ARGS_DEFAULT; 25 struct mtool cmd = MTOOL_NULL; 26 size_t sz = 0; 27 res_T res = RES_OK; 28 29 if((res = mtool_args_init(&args, argc, argv)) != RES_OK) goto error; 30 if(args.quit) goto exit; 31 32 if((res = mtool_init(&cmd, &args)) != RES_OK) goto error; 33 if((res = mtool_run(&cmd)) != RES_OK) goto error; 34 35 exit: 36 mtool_release(&cmd); 37 mtool_args_release(&args); 38 if((sz = mem_allocated_size()) != 0) { 39 fprintf(stderr, "Memory leaks: %lu Bytes\n", (unsigned long)sz); 40 } 41 return res; 42 error: 43 goto exit; 44 }