#include
#include
#include
#include
#include
static int check_wlan_chip(const char *tag, int secs)
{
#define DRIVER_LIVE_FILE "/proc/wlan_chip"
char *line;
int line_size;
FILE *proc;
int delay;
line_size = strlen(tag) + 1;
line = malloc(line_size);
secs *= 10;
//setvbuf(proc, NULL, _IONBF, 0);
for (delay = 0; delay < secs; delay++) {
if ((proc = fopen(DRIVER_LIVE_FILE, "r")) == NULL) {
fprintf(stderr, "Error : %s : %s\n", DRIVER_LIVE_FILE, strerror(errno));
free(line);
return 0;
}
while ((fgets(line, line_size, proc)) != NULL) {
if (strncmp(line, tag, line_size) == 0) {
fclose(proc);
free(line);
return 1;
}
printf(line);
}
fclose(proc);
//fseek(proc, 0, SEEK_SET);
//fflush(proc);
usleep(100*1000);
}
free(line);
return 0;
}
int main(void)
{
return check_wlan_chip("driver=live", 20);
}
阅读(494) | 评论(0) | 转发(0) |