/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#+
#+     Internet Radio Automation & Encoding Toolkit
#+
#+     Copyright (C) 2018 - 2025 by Kevin C. O'Kane
#+
#+     Kevin C. O'Kane
#+     kc.okane@gmail.com
#+     https://www.cs.uni.edu/~okane
#+     https://threadsafebooks.com/
#+
#+ This program 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.
#+
#+ This program 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 this program; if not, write to the Free Software
#+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#+
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

// Sept 29, 2025

#include "includes.h"
#include "defines.h"
#include "common-externs.h"
//#include "global-vars.h"


void	cli_args(int argc, char *argv[]) {

//----------------------------------------------------------------------
//      Process command line arguments
//----------------------------------------------------------------------

	if (argc > 1 ) {

		for (int i = 1; i < argc; i++) {

			if (strcmp(argv[i], "--help") == 0) {
				printf("Options:\n");
				printf("        --music-home-directory dir\n");
				printf("        --program-list dir\n");
				printf("        --album-list dir\n");
				printf("        --microphone-default number\n");
				printf("        --background-color color\n");
				printf("        --timer-res milliseconds\n");
				printf("        --max-agc number\n");
				printf("        --rand-cover-time\n");
				printf("        --web-page URL\n");
				printf("        --help\n");
				exit(EXIT_SUCCESS);
				}

			if (i+1 >= argc) {
				printf("*** CLI argument count error.\n");
				return;
				}

			if (strcmp(argv[i], "--web-page") == 0) {
				if (strlen(argv[i+1]) > 4090)
					printf("*** Web Page string too long - ignored.\n");
				else strcpy(Web_Page, argv[i+1]);
				i++;
				}
			else if (strcmp(argv[i], "--music-home-directory") == 0) {
				strcpy(Music_Home_Directory, argv[i+1]);
				i++;
				}
			else if (strcmp(argv[i], "--program-max") == 0) {
				// max nbr program entries
				sscanf(argv[i+1], "%d", &PROGRAM_MAX);
				i++;
				}
			else if (strcmp(argv[i], "--background-color") == 0) {
				strncpy(BackgroundColorString, argv[i+1], 64);
				i++;
				}
			else if (strcmp(argv[i], "--code-home") == 0) {
				strcpy(Code_Home, argv[i+1]);
				i++;
				}
			else if (strcmp(argv[i], "--program-list") == 0) {
				strcpy(Program_List, argv[i+1]);
				i++;
				}
			else if (strcmp(argv[i], "--album-list") == 0) {
				strcpy(Album_List, argv[i+1]);
				i++;
				}
			else if (strcmp(argv[i], "--timer-res") == 0) {
				timer_res = atoi(argv[i+1]);
				i++;
				}
			else if (strcmp(argv[i], "--max-agc") == 0) {
				Topgain = atoi(argv[i+1]);
				i++;
				}
			else if (strcmp(argv[i], "--microphone-default") == 0) {
				mic_max = atoi(argv[i+1]);
				gtk_spin_button_set_value (GTK_SPIN_BUTTON(micThreshold1), mic_max);
				i++;
				}
			else if (strcmp(argv[i], "--rand-cover-time") == 0) {
				ALBUM_COVER_UPDATE_TIME = atoi(argv[i+1]);
				i++;
				}
			else {
				printf("\nUnrecognized: %s\n", argv[i]);
				exit(EXIT_FAILURE);
				}
			}
		}

	}
