added argc check and help message
This commit is contained in:
parent
a380465707
commit
86a1552530
|
@ -27,13 +27,50 @@ int getfilec(FILE *file, char arr[]){
|
|||
return i;
|
||||
}
|
||||
|
||||
int main(){
|
||||
int powerof(int base, int exponent){
|
||||
int i, result;
|
||||
if (exponent==0){
|
||||
return result=1;
|
||||
}
|
||||
result=base;
|
||||
for(i=0; i<exponent-1; i++){
|
||||
result*=base;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int stringtoint(char number[], int length){
|
||||
int j, result;
|
||||
result=0;
|
||||
j=0;
|
||||
while(length-1>=0){
|
||||
result+=((int)number[length-1]-'0')*(powerof(10,j));
|
||||
j++;
|
||||
length--;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv){
|
||||
if (argc == 1 || comparestrings(argv[1], "-h") == 0
|
||||
|| comparestrings(argv[1], "--help") == 0){
|
||||
printf("usage: homemade_speedstep <max temp> <min temp>\n");
|
||||
printf(" homemade_speedstep [-h | --help]\n");
|
||||
printf(" -h | --help prints out this help message\n");
|
||||
return 0;
|
||||
}
|
||||
if (argc!=3){
|
||||
printf("error: wrong ammount of arguments given\n");
|
||||
printf(" see homemade_speedstep --help\n");
|
||||
return 1;
|
||||
}
|
||||
char gov[20];
|
||||
FILE *govfile = fopen(CURGOV, "r");
|
||||
getfilec(govfile, gov);
|
||||
if (comparestrings(gov, "userspace\n") != 0){
|
||||
printf("error: userspace governor not set\n");
|
||||
return 1;
|
||||
fclose(govfile);
|
||||
return 2;
|
||||
}
|
||||
FILE *freqsfile = fopen(FREQS, "r");
|
||||
FILE *curmaxfile = fopen(MAXSPDPATH, "r");
|
||||
|
|
Loading…
Reference in New Issue