Sunday, December 25, 2011

How to convert LPWSTR to string in VC++

Author: ArkM
Source: http://www.daniweb.com/software-development/cpp/threads/155420



C++ Syntax (Toggle Plain Text)
  1. bool cvtLPW2stdstring(std::string& s, const LPWSTR pw,
  2. UINT codepage = CP_ACP)
  3. {
  4. bool res = false;
  5. char* p = 0;
  6. int bsz;
  7.  
  8. bsz = WideCharToMultiByte(codepage,
  9. 0,
  10. pw,-1,
  11. 0,0,
  12. 0,0);
  13. if (bsz > 0) {
  14. p = new char[bsz];
  15. int rc = WideCharToMultiByte(codepage,
  16. 0,
  17. pw,-1,
  18. p,bsz,
  19. 0,0);
  20. if (rc != 0) {
  21. p[bsz-1] = 0;
  22. s = p;
  23. res = true;
  24. }
  25. }
  26. delete [] p;
  27. return res;
  28. }
  29.  
  30. int main()
  31. {
  32. wchar_t msg[] = L"Hello, world!";
  33. std::string s("\?");
  34.  
  35. cvtLPW2stdstring(s,msg);
  36. std::cout << s << std::endl;
  37.  
  38. return 0;
  39. }


Tuesday, December 20, 2011

Private Web Browsing with SSH Tunneling and Putty By Corey on March 9th, 2010


Private Web Browsing with SSH Tunneling and Putty

Web browsing through SSH tunneling gives you the ability to browse the web privately by encrypting all web traffic out of your computer.  This gives you privacy to know that anyone eavesdropping on your connection using something like Wireshark. It also allows you to by-pass any internet content restrictions that may be in place where you are, such as a workplace or public connection.  I personally use this because I don’t like the idea of someone else listening in, and I don’t like being restricted.
What we will do is use a free program called Putty to connect to an SSH server that we have set up home. Then we will configure the machine that we are on to pass all web traffic through this encrypted connection and out through our home connection. Anyone listening in will only see one connection to your home IP, and the rest will be encrypted traffic.
Note: There is now an update to this post that also Passes all DNS Queries Through SOCKS in Firefox. Be sure to read that after you finish this tutorial for added privacy.

What You Will Need

  • An SSH server, or access to one.  (Note: Free shell providers don’t take kindly to people doing this through their servers, so check with them before you do this)  Setup of SSH server not covered here.
  • Putty client downloaded to the machine you will be working on.
  • Ability to connect outbound from your location.  Many work places limits or prevents outbound SSH connections.  You may need to run yours on a different port.

Step 1 – Configure Putty

After downloading Putty, launch it and in the left menu, go toConnection -> SSH -> Tunnels .  On the right side, enter any port above 1024 in the Source Port and select Dynamic from the radio buttons directly below it, then click Add.
It should now say D7070 in the box above.
Next, on the left side, go back to Session, and add a session profile for your home server by entering in the address underHost Nameensure that SSH is selected underneath.  Next, create a name for your profile, and enter it in Saved Sessionsbox and then click save.  Finally, click Open at the bottom and log into your SSH server.

Step 2 – Configure Web Browser

Firefox
If you’re using the Mozilla Firefox web browser, you can configure it by going to Tools -> Options menu and then clicking Advanced on top and then select the Network tab and then Settings under Connection section.
On the Connection Settings windows, enter in 127.0.0.1 in the SOCKS Host box, and your port you selected earlier, in this case 7070.  Ensure that SOCKSv5 is selected underneath.  That’s it, now press OK until you are back at your browser window.  You’re done.
Internet Explorer
If you are using Microsoft Internet Explorer then you can go to theTools -> Internet Options menu.  Click on the Connections tab and then LAN Settings down below. Now, on the Local Area Network (LAN) Settings page, but a check mark in the Use aproxy server for your LAN and in Bypass proxy server for local addresses and then click the Advanced button.
In the Proxy Settings page, enter 127.0.0.1 in the Socks box, and the port you selected in the box next to it, in our case 7070. Now, click OK until you are back at the web browser window.
Google Chrome
Unfortunately there is no native way of setting this up in Google Chrome.  However, someone has created an extension for it that you will have to add yourself called Proxy Switchy! which you will have to add yourself. I don’t currently have Google Chrome installed so I can’t provide step-by-step instructions.

Testing

The good thing about this setup is that you don’t have to configuration anything on the SSH Server side.  To test your tunnel, just go to http://www.whatismyip.com and it should display the IP address of your home server and not your current physical location.
That’s it, enjoy, and happy private browsing!

Sunday, December 4, 2011

Thursday, December 1, 2011

make blip 2.0 error: region `rom' overflowed by 6806 bytes

mkdir -p build/telosb
    compiling PppRouterC to a telosb binary
ncc -o build/telosb/main.exe  -Os -O -DRPL_ROUTING -DRPL_STORING_MODE -I/opt/tinyos/tos/lib/net/rpl -I/opt/tinyos/tos/lib/ppp -I/opt/tinyos/tos/lib/fragpool -DPPP_HDLC_RX_FRAME_LIMIT=1 -DPPP_HDLC_TX_FRAME_LIMIT=8 -DIN6_PREFIX=\"fec0::\" -DBLIP_DERIVE_SHORTADDRS -DCC2420_HW_ACKNOWLEDGEMENTS  -DCC2420_HW_ADDRESS_RECOGNITION -DPACKET_LINK -DTOSH_DATA_LENGTH=112 -I/opt/tinyos/tos/lib/net/ -I/opt/tinyos/tos/lib/printf/ -I/opt/tinyos/support/sdk/c/blip/ -I/opt/tinyos/tos/lib/net/blip/ -I/opt/tinyos/tos/lib/net/blip/interfaces/  -I/opt/tinyos/tos/lib/net/blip/nwprog/ -I/opt/tinyos/tos/lib/net/blip/shell/ -I/opt/tinyos/tos/lib/net/blip/serial/ -I/opt/tinyos/tos/lib/net/blip/platform/ -I/opt/tinyos/tos/lib/net/blip/icmp/ -I/opt/tinyos/tos/lib/net/blip/dhcp/ /opt/tinyos/support/sdk/c/blip/lib6lowpan/iovec.c /opt/tinyos/support/sdk/c/blip/lib6lowpan/in_cksum.c /opt/tinyos/support/sdk/c/blip/lib6lowpan/ip_malloc.c /opt/tinyos/support/sdk/c/blip/lib6lowpan/utility.c /opt/tinyos/tos/lib/net/blip/table.c -fnesc-separator=__ -Wall -Wshadow -Wnesc-all -target=telosb -fnesc-cfile=build/telosb/app.c -board= -DDEFINED_TOS_AM_GROUP=0x22 -DIDENT_APPNAME=\"PppRouterC\" -DIDENT_USERNAME=\"ubuntu\" -DIDENT_HOSTNAME=\"ubuntu\" -DIDENT_USERHASH=0xf67b89f7L -DIDENT_TIMESTAMP=0x4ed7f4e0L -DIDENT_UIDHASH=0x839cc16fL  PppRouterC.nc -lm 
/opt/tinyos/tos/platforms/telosa/PlatformHdlcUartC.nc:40:2: warning: #warning Enabling DMA on UART1RX
/opt/tinyos/tos/chips/cc2420/lpl/DummyLplC.nc:39:2: warning: #warning "*** LOW POWER COMMUNICATIONS DISABLED ***"
/opt/tinyos/tos/chips/cc2420/link/PacketLinkC.nc:38:2: warning: #warning "*** USING PACKET LINK LAYER"
/opt/tinyos/tos/lib/net/blip/shell/UDPShellP.nc:260: warning: call via function pointer
/opt/tinyos/tos/platforms/telosa/PlatformHdlcUartP.nc:181: warning: `HdlcUart.receivedByte' called asynchronously from `UsartInterrupts.rxDone'
/usr/bin/../lib/gcc/msp430/4.5.3/../../../../msp430/bin/ld: build/telosb/main.exe section `.text' will not fit in region `rom'
/usr/bin/../lib/gcc/msp430/4.5.3/../../../../msp430/bin/ld: section .vectors loaded at [0000ffe0,0000ffff] overlaps section .text loaded at [00004000,00011993]
/usr/bin/../lib/gcc/msp430/4.5.3/../../../../msp430/bin/ld: region `rom' overflowed by 6806 bytes
collect2: ld returned 1 exit status
make: *** [exe0] Error 1


Using latest tools from http://tinyprod.net/debian-dev/ 
However it did not compile with stanford version either, so I guess it is not question of toolchain.
Comment 1 by project member marku...@gmail.comToday (12 hours ago)


Fix is commenting
#OPTFLAGS += -O
in support/make/telosb.target.