1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#include<iostream>
#include<fstream>
#include<string.h>
#include<stdio.h>
using namespace std;
int main() {
string line;
const char* ifname = "wlan0";
ifstream input ("/proc/net/wireless");
if(!input.is_open())
{
cout << "Couldn't open the file " << endl;
}
while(getline(input, line)){
char *bp = strdup(line.c_str());
while(*bp && isspace(*bp))
bp++;
if(strncmp(bp,ifname,strlen(ifname))==0 && bp[strlen(ifname)]==':')
{
bp = strchr(bp, ':');
bp++;
bp = strtok(bp, " ");
cout << bp ;
bp = strtok(NULL, " ");
if(strchr(bp,'.') != NULL)
cout << bp ;
bp = strtok(NULL, " ");
if(strchr(bp,'.') != NULL)
cout << bp;
bp = strtok(NULL, " ");
if(strchr(bp,'.') != NULL)
cout << bp;
bp = strtok(NULL, " ");
cout << bp;
bp = strtok(NULL, " ");
cout << bp;
bp = strtok(NULL, " ");
cout << bp;
// std::cout <<"End of line"<<std::endl;
// delete bp;
}
return 0;
}
}
|