/*
Date: 2014/07/10
Purpose: test code for verify_grn_flag()
*/
#include<stdio.h>
#include<string.h>
#define GRN_KEYS_CNT 3
char *grn_keys[GRN_KEYS_CNT] = {
"Model:", "Serial Number:", "Size [GB] (1 GB = 10^9 Bytes):"
};
int main(void)
{
char cmd[64] = {0};
FILE *fp = NULL;
char file[64] = {0};
char string[512] = {0};
int result = 0;
int i = 0;
char *p = NULL;
sprintf(file, "mytmp");
//sprintf(cmd, "cat /proc/cpuinfo > mytmp");
//result = system(cmd);
//printf("%s", cmd);
fp = fopen(file, "r");
if(fp == NULL){
printf("%s is not exist", file);
return 0;
}
while(fgets(cmd, sizeof(cmd), fp) != NULL)
{
for(i = 0; i < GRN_KEYS_CNT; i++)
{
if(strncmp(cmd, grn_keys[i], strlen(grn_keys[i]))){
continue;
}
printf("%d\t**i=%d\tcmd=%s\t**grn_keys[%d] = %s\t\n", __LINE__, i, cmd, i, grn_keys[i]);
if((p = strchr(cmd, '\n')))
*p = 0;
printf("%d\tp = %s\tcmd=%s\n", __LINE__, p, cmd);
p = cmd + strlen(grn_keys[i]);
while(*p == ' ' || *p == '\t'){
p++;
printf("%d\tp = %s\tcmd=%s\n", __LINE__, p, cmd);
}
printf("%d\tp = %s\n", __LINE__, p);
}
//printf("%d\tp = %s\tq=%s\n", __LINE__, p, q);
}
return 0;
}
test code for make green marker
最新推荐文章于 2023-10-27 22:33:05 发布