Example #1
0
File: main.c Project: akshaykb/Zeta
void initiate()
{
    //Prompt Start

    printf("\n:> ");
    fgets(input,sizeof(input),stdin);

    //----------------------------------------------------------------------------------------
    //EXIT COMMAND
    if((stricmp(input,"exit\n")==0)) //To exit command interpreter
    {
        main_exit();
    }
    //----------------------------------------------------------------------------------------

    //----------------------------------------------------------------------------------------
    //CLEAR SCREEN COMMAND
    else if(stricmp(input,"clr\n")==0) //To clear screen
    {
    	system("cls");
        initiate();
    }
    //----------------------------------------------------------------------------------------


    //----------------------------------------------------------------------------------------
    //TIME COMMANDS
    else if((stricmp(input,"time\n")==0)) //To show time (default format-24hr HH/MM/SS.MS)
    {
    	sys_time_def();
    	initiate();
    }

    else if((stricmp(input,"time-24\n")==0)) //To show time in 24hrformat (HH:MM)
    {
    	sys_time_24hr();
    	initiate();
    }

    else if((stricmp(input,"time-12\n")==0)) //To show time in 12hr format (HH:MM AM/PM)
    {
        sys_time_12hr();
        initiate();
    }

    else if((stricmp(input,"time-e\n")==0)) //To show time and provide 'editing' option
    {
        system("time");
        initiate();
    }
    //----------------------------------------------------------------------------------------

    //----------------------------------------------------------------------------------------
    //DATE COMMANDS
    else if((stricmp(input,"date\n")==0)) //To show date (default format:MM/DD/YYYY)
    {
    	sys_date_def();
    	initiate();
    }

    else if((stricmp(input,"date-e\n")==0)) //To show date and provide 'editing' option
    {
        system("date");
        initiate();
    }
    //----------------------------------------------------------------------------------------

    //----------------------------------------------------------------------------------------
    //DAY COMMANDS
    else if((stricmp(input,"day\n")==0)) //To show day/date of month
    {
    	sys_day();
    	initiate();
    }

    else if((stricmp(input,"day-i\n")==0)) //To show complete day info
    {
    	sys_day_info();
    	initiate();
    }
    //----------------------------------------------------------------------------------------

    //----------------------------------------------------------------------------------------
    // STRING MANIPULATION COMMANDS
    else if((stricmp(input,"strln\n")==0)) // Returns length of String
    {
        strln();
        initiate();
    }

    else if((stricmp(input,"strwht\n")==0)) // Returns no. of whitespaces in the String
    {
        strwht();
        initiate();
    }

    else if((stricmp(input,"strslice\n")==0)) // Returns a SubString from the given String using mentioned indices
    {
        strslice();
        initiate();
    }

    else if((stricmp(input,"strcap\n")==0)) // Capitalises the entered String
    {
        strcap();
        initiate();
    }

    else if((stricmp(input,"strtolow\n")==0)) // Converts uppercase String to lowercase
    {
        strtolow();
        initiate();
    }
    //----------------------------------------------------------------------------------------

	else
	{
        printf("\aCommand not found.\n");
        initiate();
	}

}
Example #2
0
void initiate()
{
    //Prompt Start

    printf("\n:> ");
    scanf("%s",&input);

    //----------------------------------------------------------------------------------------
    //EXIT COMMAND
    if ((stricmp(input,"exit")==0)) //To exit command interpreter
    {
        main_exit();
    }
    //----------------------------------------------------------------------------------------

    //----------------------------------------------------------------------------------------
    //CLEAR SCREEN COMMAND
    else if(stricmp(input,"clr")==0) //To clear screen
    {
        system("cls");
        initiate();
    }
    //----------------------------------------------------------------------------------------


    //----------------------------------------------------------------------------------------
    //TIME COMMANDS
    else if ((stricmp(input,"time")==0)) //To show time (default format-24hr HH/MM/SS.MS)
    {
        sys_time_def();
        initiate();
    }

    else if ((stricmp(input,"time-24")==0)) //To show time in 24hrformat (HH:MM)
    {
        sys_time_24hr();
        initiate();
    }

    else if ((stricmp(input,"time-12")==0)) //To show time in 12hr format (HH:MM AM/PM)
    {
        sys_time_12hr();
        initiate();
    }

    else if ((stricmp(input,"time-e")==0)) //To show time and provide 'editing' option
    {
        system("time");
        initiate();
    }
    //----------------------------------------------------------------------------------------

    //----------------------------------------------------------------------------------------
    //DATE COMMANDS
    else if ((stricmp(input,"date")==0)) //To show date (default format:MM/DD/YYYY)
    {
        sys_date_def();
        initiate();
    }

    else if ((stricmp(input,"date-e")==0)) //To show date and provide 'editing' option
    {
        system("date");
        initiate();
    }
    //----------------------------------------------------------------------------------------

    //----------------------------------------------------------------------------------------
    //DAY COMMANDS
    else if ((stricmp(input,"day")==0)) //To show day/date of month
    {
        sys_day();
        initiate();
    }

    else if ((stricmp(input,"day-i")==0)) //To show complete day info
    {
        sys_day_info();
        initiate();
    }
    //----------------------------------------------------------------------------------------

    //----------------------------------------------------------------------------------------
    // STRING MANIPULATION COMMANDS
    else if ((stricmp(input,"strln")==0)) // To return length of string
    {
        strln();
        initiate();
    }
    //----------------------------------------------------------------------------------------

    else
    {
        printf("\aCommand not found. \n");
        initiate();
    }


}