Browse code

core: main - catch common mistakes for the arguments

- print error and exit on 'kamailio start|stop|restart'

Daniel-Constantin Mierla authored on 15/06/2021 06:49:24
Showing 1 changed files
... ...
@@ -2024,6 +2024,25 @@ int main(int argc, char** argv)
2024 2024
 		{0, 0, 0, 0 }
2025 2025
 	};
2026 2026
 
2027
+	if (argc > 1) {
2028
+		/* checks for common wrong arguments */
2029
+		if(strcasecmp(argv[1], "start")==0) {
2030
+			fprintf(stderr, "error: 'start' is not a supported argument\n");
2031
+			fprintf(stderr, "error: stopping " NAME " ...\n\n");
2032
+			exit(-1);
2033
+		}
2034
+		if(strcasecmp(argv[1], "stop")==0) {
2035
+			fprintf(stderr, "error: 'stop' is not a supported argument\n");
2036
+			fprintf(stderr, "error: stopping " NAME " ...\n\n");
2037
+			exit(-1);
2038
+		}
2039
+		if(strcasecmp(argv[1], "restart")==0) {
2040
+			fprintf(stderr, "error: 'restart' is not a supported argument\n");
2041
+			fprintf(stderr, "error: stopping " NAME " ...\n\n");
2042
+			exit(-1);
2043
+		}
2044
+	}
2045
+
2027 2046
 	/*init*/
2028 2047
 	time(&up_since);
2029 2048
 	creator_pid = getpid();