Skip to content

Commit

Permalink
Initial commit of wlanapi library 0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
maurice2k committed Mar 29, 2009
0 parents commit d86627a
Show file tree
Hide file tree
Showing 12 changed files with 2,962 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
COMPILER := g++
EXECUTABLE := example_list_aps
LIBS := dbus-glib-1
INCLUDES := /usr/include/dbus-1.0 /usr/lib/dbus-1.0/include /usr/include/glib-2.0 /usr/lib/glib-2.0/include
CFLAGS := -O3

SOURCE := example_list_aps.cpp library/wlanapi.cpp library/wlanapi_exception.cpp

all : $(EXECUTABLE)

build : $(EXECUTABLE)

clean :
rm -f $(EXECUTABLE)

$(EXECUTABLE) :
$(COMPILER) $(CFLAGS) $(SOURCE) -o $(EXECUTABLE) $(addprefix -l,$(LIBS)) $(addprefix -I,$(INCLUDES))
strip $(EXECUTABLE)
17 changes: 17 additions & 0 deletions Makefile.win32
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
COMPILER := g++
EXECUTABLE := example_list_aps.exe
LIBS :=
CFLAGS := -O3

SOURCE := example_list_aps.cpp library/wlanapi.cpp library/wlanapi_exception.cpp

all : $(EXECUTABLE)

build : $(EXECUTABLE)

clean :
rm -f $(EXECUTABLE)

$(EXECUTABLE) :
$(COMPILER) $(CFLAGS) $(SOURCE) -o $(EXECUTABLE) $(addprefix -l,$(LIBS))
strip $(EXECUTABLE)
61 changes: 61 additions & 0 deletions example_list_aps.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* wlanapi library 0.4
*
* Copyright (C) 2008, 2009 Moritz Mertinkat <[email protected]>
* All rights reserved.
*
* wlanapi library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* wlanapi library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.*
*
* You should have received a copy of the GNU General Public License
* along with wlanapi library. If not, see <http://www.gnu.org/licenses/>.
*/

#include <vector>
#include <string>
#include <stdexcept>

#include "library/wlanapi.h"

using namespace std;

int main() {

wlanapi *wi = new wlanapi();

try {

const ADAPTER_LIST &adapter_list = wi->get_adapter_list();
const AP_LIST &ap_list = wi->get_ap_list(NULL);

for (AP_LIST::const_iterator it = ap_list.begin(); it < ap_list.end(); ++it) {

printf("ap name: %s\n", it->name);
printf("ap mac address: %02x-%02x-%02x-%02x-%02x-%02x\n", it->mac_address.u[0],
it->mac_address.u[1],
it->mac_address.u[2],
it->mac_address.u[3],
it->mac_address.u[4],
it->mac_address.u[5]);
printf("ap rssi: %i\n", it->rssi);
printf("\n");

}

} catch (std::exception &e) {
printf("[X] %s\n", e.what());
}

printf("Press enter to exit.");
scanf("...");

delete wi;

}
42 changes: 42 additions & 0 deletions library/debug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* wlanapi library 0.4
*
* Copyright (C) 2008, 2009 Moritz Mertinkat <[email protected]>
* All rights reserved.
*
* wlanapi library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* wlanapi library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.*
*
* You should have received a copy of the GNU General Public License
* along with wlanapi library. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __DEBUG_H_
#define __DEBUG_H_

#include <string.h>

#ifdef DEBUG
#define DEBUG_PRINT(...) printf(__VA_ARGS__);
#define DEBUG_WPRINT(...) wprintf(__VA_ARGS__);
#define DEBUG_ENTER(class_name) if (strlen(#class_name) > 0) printf("[>] %s::%s()\n", #class_name, __FUNCTION__); else printf("[>] %s()\n", __FUNCTION__);
#define DEBUG_LEAVE(class_name) if (strlen(#class_name) > 0) printf("[<] %s::%s()\n\n", #class_name, __FUNCTION__); else printf("[<] %s()\n\n", __FUNCTION__);
#define DEBUG_ENTER_PRETTY() printf("[>] %s\n", __PRETTY_FUNCTION__);
#define DEBUG_LEAVE_PRETTY() printf("[<] %s\n\n", __PRETTY_FUNCTION__);
#else
#define DEBUG_PRINT(...)
#define DEBUG_WPRINT(...)
#define DEBUG_ENTER(class_name)
#define DEBUG_LEAVE(class_name)
#define DEBUG_ENTER_PRETTY()
#define DEBUG_LEAVE_PRETTY()
#endif

#endif
Loading

0 comments on commit d86627a

Please sign in to comment.