Created
March 17, 2015 09:41
-
-
Save jsfaint/922047b49b619d701272 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <stdio.h> | |
//char root_path[] = "image.wrp"; | |
char root_path[] = "image.wrp_2.33"; | |
//char root_path[] = "/etc/tftp/image.wrp"; | |
//char root_path[] = "/etc/tftp/image.wrp_2_33"; | |
static char trimrootpath(char* filename, char* version) | |
{ | |
char* begin = NULL; | |
char* end = NULL; | |
int ii; | |
begin = strrchr(root_path, '/'); | |
if (begin == NULL) | |
end = strchr(root_path, '_'); | |
else | |
end = strchr(begin, '_'); | |
if (end == NULL) | |
{ | |
if (begin == NULL) | |
{ | |
strncpy(filename, root_path, strlen(root_path)); | |
} | |
else | |
{ | |
strncpy(filename, begin+1, strlen(begin)); | |
} | |
} | |
else | |
{ | |
begin[end - begin] = 0x00; | |
if (begin == NULL) | |
{ | |
strncpy(filename, root_path, strlen(root_path)); | |
} | |
else | |
{ | |
strncpy(filename, begin+1, strlen(begin)); | |
} | |
} | |
return TRUE; | |
} | |
int main(int argc, char** arg) | |
{ | |
char filename[128+1]; | |
char version[128+1]; | |
char kernel_version[] = "v2.31"; | |
memset(filename, 0, sizeof(filename)); | |
memset(version, 0, sizeof(version)); | |
trimrootpath(filename, version); | |
printf("%s\n", version); | |
printf("%s\n", filename); | |
if(strcmp(kernel_version+1, version) < 0) | |
printf("kernel version < version\n"); | |
else if(strcmp(kernel_version, version) == 0) | |
printf("kernel version equal to version"); | |
else | |
printf("kernel version > version"); | |
printf("%s\n", root_path); | |
system("pause"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment