📄 getopts.c
字号:
/* This file is part of AirFart. AirFart is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. AirFart is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with AirFart; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/#include <stdio.h>#include <stdlib.h>#include <string.h>#include "getopts.h"extern bool use_gui;void getopts( int argc, char** argv ){ for (int counter = 1; counter < argc; counter++) { if (!strcmp(argv[counter], "--help") || !strcmp(argv[counter], "-h")) { show_help(); exit(0); } else if (!strcmp(argv[counter], "--debug") || !strcmp(argv[counter], "-d")) { printf("Debug ON!\n"); } else if (!strcmp(argv[counter], "--nogui")) { /* Don't display the GUI */ use_gui = false; } else { printf("%s is an invalid option!\n", argv[counter]); } } }void show_help(){ printf("Usage: airfart [OPTION]\n"); printf("Monitor signal strengths of nearby wireless nodes.\n\n"); printf("\t%-15s%s\n", "-h, --help", "Display this message"); printf("\t%-15s%s\n", "-d, --debug", "Display debug information"); printf("\t%-15s%s\n", "--nogui", "Turn off GTK+ GUI. (It is on by default)");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -