61 lines
1.2 KiB
C
61 lines
1.2 KiB
C
#ifndef STD_LIB_H
|
|
#define STD_LIB_H
|
|
#include<stdio.h>
|
|
#include<stdlib.h>
|
|
#include<string.h>
|
|
#include<stdbool.h>
|
|
#include<math.h>
|
|
#include<time.h>
|
|
#include<ctype.h>
|
|
#include <stddef.h>
|
|
#endif
|
|
|
|
int choices_selecter(char * Items[],int items,char * welcome_messages ){
|
|
int choice = 0;
|
|
do{
|
|
system("cls");
|
|
|
|
if (welcome_messages !=NULL){
|
|
printf("%s",welcome_messages);
|
|
}
|
|
printf("Select An Option:\n");
|
|
int i;
|
|
for (i=0; i<items;i++){
|
|
printf("%d. %s\n",i+1,Items[i]);
|
|
}
|
|
printf("%d. Exit\n",i+1);
|
|
printf(">");
|
|
fflush(stdin);
|
|
scanf("%d",&choice);
|
|
if(choice < 1 || choice > items+1){
|
|
printf("Invalid choice...press any key to retry....\n");
|
|
fflush(stdin);
|
|
getchar();
|
|
}
|
|
}while(choice < 1 || choice > items+1);
|
|
return choice;
|
|
|
|
}
|
|
//check if strcasestr is define in current environment
|
|
//if not, define it
|
|
#ifndef HAVE_STRCASESTR
|
|
char *strcasestr(const char *s, const char *find)
|
|
{
|
|
char c, sc;
|
|
size_t len;
|
|
|
|
if ((c = *find++) != 0) {
|
|
c = tolower((unsigned char)c);
|
|
len = strlen(find);
|
|
do {
|
|
do {
|
|
if ((sc = *s++) == 0)
|
|
return (NULL);
|
|
} while ((char)tolower((unsigned char)sc) != c);
|
|
} while (strncasecmp(s, find, len) != 0);
|
|
s--;
|
|
}
|
|
return ((char *)s);
|
|
}
|
|
#endif
|