Archive for August, 2007

gSoap and MapPoint

Friday, August 17th, 2007

environment linux, Qt, c, gsoap, Microsoft MapPoint

problem I want an IRC bot which can calculate distances between users and display the local time of a user

solution Modifications to karmabot, which is written in Qt. The MapPoint WebService comes in handy. Although gSoap doesn't like MapPoint straight OOTB. Thus you need to remove "opaque=" from

gsoap-linux-2.7/plugin/httpda.c:243:      sprintf(soap->gt;tmpbuf, "Digest realm=\\"%s\\", username=\\"%s\\", nonce=\\"%s\\", uri=\\"%s\\", qop=\\"%s\\", nc=%s, cnonce=\\"%s\\", response=\\"%s\\", opaque=\\"%s\\"", soap->gt;authrealm, soap->gt;userid, data->gt;nonce, soap->gt;path, qop, ncount, cnonce, response, data->gt;opaque);
gsoap-linux-2.7/plugin/httpda.c:245:      sprintf(soap->gt;tmpbuf, "Digest realm=\\"%s\\", username=\\"%s\\", nonce=\\"%s\\", uri=\\"%s\\", response=\\"%s\\", opaque=\\"%s\\"", soap->gt;authrealm, soap->gt;userid, data->gt;nonce, soap->gt;path, response, data->gt;opaque);

thanks to this posting.
You need to use httpda.h for digest authentication. Add gsoap-linux-2.7/plugin/httpda.c and gsoap-linux-2.7/plugin/md5evp.c and link against openssl (-lssl). That should do the trick. Because it cost me some time, I'll paste code for a find request:

char* arr[] = { "PopulatedPlace" };
struct mpt__ArrayOfString EntityTypeNames = {1, arr };

struct mpt__FindSpecification spec = {
        "MapPoint.World",
        "Vienna, Austria",
        &EntityTypeNames,
        NULL };

struct _mpt__Find req = { &spec };
if(soap_call___ns2__Find(gSoap, NULL, NULL, &req, resp) != SOAP_OK)

IRC Bot with R

Tuesday, August 14th, 2007

environment IRC (internet relay chat), R

problem Evaluate R code in an IRC channel and post the output of R back into the channel

solution A modified KarmaBot version. Come to EFNet into the channel #statistics.

Syntax: "r: <R-Code>"

Sample: "r: 1:4"

Re-format #defines into C# enums

Sunday, August 12th, 2007

environment msdn documentation, gvim, C#

problem I want legacy C defines like this to be represented by a nice C# enum.

solution

  1. Copy the table from msdn containing the #define names, values and comments to gvim
  2. Use this regular expression
    %s#\\v(\\u)([A-Z_]+) (0x\\d+)L (.*)#^M///<summary>^M/// \\4^M///</summary>^M\\1\\L\\2 = \\3,#
  3. Paste into your C# file

Notes

  • \v sets vim to very magic mode - fear - so the () don't have to be escaped.
  • \u matches uppercase characters.
  • ^M is a new line - on Windows use "Strg+Q Enter" to get it.
  • \L\2 changes the contents of the succedding back reference to lower case.