How to maintain sessions with C++ code? - c++

There is a cgi code written in C++. Currently there is no session management done in the web pages. There is a need to provide sessions in the web pages so that the user can login, maintain session and then logoff. While this is a fairly simple task in java with HttpSession, I have no clue how to do this with C++ code.

C++ is not like Java in the breadth of the functionality of the bundled libraries, so you need to extend the language with some extra libraries for not so common tasks (such as C++ CGI development). You can either build the library yourself to support functionality not present in the standard library, or use one developed by a third party.
In this case I'd use the NCBI C++ Toolkit. It provides a nice CGI module with session support

Another alternative may be the "FastCGI / CGI C++ Library" that is aimed for Boost integration at someday: http://cgi.sourceforge.net/
It claims itself to provide "Configurable support for strongly-typed sessions (optional)."

Related

Library for developing XMPP server in c++ or delphi?

I have to develop a simple XMPP server that will be included in a commercial project. I guess there is no server available that can be purchased with a royalty-free-license and that enables me to do the configuration and user management and the authentication from my own code.
The languages I can use are Delphi and C++.
I've already looked at the libraries listed at xmpp.org, but most of them seem to be client-only libraries or (as e.g. QXmpp) require QT which I have no experience of and consideres it to be a pure GUI framework.
Can anybody suggest a library I should take a closer look at? Does it make sense to familiarize myself with QT for this purpose (writing xmpp server;no GUI)?
Or is it better to just catch a stream parser (suggestions?) and code it myself?
Thanks!
Edit: The only library I could find for Delphi, IP*Works is a pure client library. I'm evaluation QXmpp now.
For the Delphi part of my question: I didn't find a library I think that is suitable for building a server.
For the C++ part, I think this post Non GPL C/C++ XMPP client library for embedded Linux (though it is for embedded and client) is answering my questions:
Because Qt provides XML parser and signal/slot framework. XMPP requires XML parser, and signal/slot framework makes your life easier. If you try implementing entire XMPP with all extensions in OOP fashion, you'll need something similar to Qt.
and
Advice: when it comes to C++, there aren't many good xmpp libraries available.
So I think, QXmpp seems to be a good solution.
For other people searchig for this topic:
IMHO the documentation (especially for the server part) is a bit poor. The server example distributed with the qxmpp library is (of course) very basic: It is transporting chat messages. Distributing presence information, roster, subscription handling has to be implemented by you via extensions (inheriting QXmppServerExtension overwriting at least virtual function handleStanza). Don't parse the presence or iq stanzas in your own code. For the more common stanzas the libarary has classes implemented QXmppPresence, QXmppRosterIq etc.) that also can be used in your extension.

WCF-like Native C++ Library

I am looking for a library for native C++ (library source code has to be gcc compatible and portable across Linux and Windows) that does what WCF does in its very basic form - i.e. OperationContracts and DataContracts in a client-server environment, with data exchanges in binary format (binary serialization).
Ideally I'd like to use a library to achieve this. So if there's a library already available that compiles OperationContracts and DataContracts into rich C++ classes with metadata for reflection which can be consumed in our code and with client-server TCP communications built-in (i.e. a rudimentary implementation of WCF's functionality without the need to be compatible with WCF at all), please point me to it.
If not, implementing them myself (unlikely due to time constraints), I could use boost::serialization for DataContracts but how would I implement OperationContracts?
It's not necessarily compatible with gcc--so it's somewhat tangential to the precise question asked here--but I'd like to include a reference to the Windows Web Services API, Microsoft's native-code counterpart to WCF (for Windows systems).
From this secondary article:
WWS is designed from the ground up to be a completely native-code implementation of SOAP, including support for many of the WS-* protocols. WWS is, strictly speaking, exposed through a C API, making interoperability with other languages and runtimes very straightforward, but it is the C++ developer who will likely benefit the most.
I have found one that fits the purpose called "RCF" (Remote Call Framework) by Delta V Software. It's open source (GPLv2 or US$195 closed source). So far in my testing, it's working very well. According to the site, companies like HP, Ericsson and Siemens are users of the library.
Apache Thrift is another option you might consider,
http://en.wikipedia.org/wiki/Apache_Thrift

Wanted: Compiler Tool for Users of Software System

I am not sure if the title of this question gets to the point. I have written a large software system in C C++ for Windows, and want to give the users of this system the option to add compiled code to it. The user should be able to do basic stuff, and exchange data with my program.
Currently the implemented way is via DLLs. But for this, a grown up compiler is needed, and it is not as easy as I wished. Is there a tiny C compiler that can create Windows DLLs?
Another idea is the Java native interface. But this requires a complete Java system to run in the background, and it is not easy to run code in it.
Do you have any other ideas?
Any interpreted language? (TCL and Lua were designed as extension languages, but you can nearly as easily interface with any other).
How about python integration?
You could create an python interface that interfaces with your application. Python is rather easy to learn and should integrate easily with c/c++. The python documentation has an own chapter on that.
You could also use a tool like swig to generate the interface.
The advantage of this is that they wouldn't have to compile anything. They could just supply python files that could be loaded into your application and run within the software. This is a well known use for python, and something its simple syntax promotes.
As the other says you will be best of by providing an embedded language.
I would chip in for javascript and use the google v8 engine
By using javascript you get a language nearly everbody can use and program in.
There is other javascript engines you can embed like SpiderMonkey.
See this answer for what to choose.
An interpreted language is not good enough. I need speed. The software itself is an interpreted language. So I added support for the tiny C compiler. It is only C, and I do check mingw, which probably would not be as tiny as this. Thanks for all your hints.
Added after several months:
I have now two tools, actually: TinyC and Python. The speed difference between those is noticable (factor 5-10), but that usually does not matter too much. Python is much easier for the user, though I managed to integrate both into the Euler GUI quite nicely.
One of the ways is to add scripting. You application can host scripting environment and expose its services there. Users would be able to execute JScript/VBScript scripts and interact with your application. The advantage is that with reasonable effort you can get the power of well known and well documented scripting languages into your application (I suppose there is even debugger for scripting there). You will be required to shape your app services as COM interfaces and scripts will be able to access them automatically using method names you assigned on C++ side.
C++, Win32 and Scripting: Quick way to add Scripting support to your applications
MSDN Entry Point - IActiveScript interface

How to Compose OSGi Based project with C++ based project?

I am extending a project that it has been initiated with C++ language. Now I am developing a new part of the project. and it will be based on OSGi (Java).
Now I want to know is there any stable method to compose the old project with new part? Is there any steps that can convert C++ objects to OSGi bundles (or with similar structure and metadata)? Or is there any way to have communication between them?
Although it isn't C++, but plain C, you might check out Apache Celix. Apache Celix is an implementation of the OSGi specification in C, without a dependency to any Java implementation or such. Currently Celix is still in the incubation phase.
Regarding communication between C and Java, one of the items on the (short term) todo list of Celix is an implementation of the OSGi Remote Services. We intend to use hessian as implementation since it already exists in many other languages, is relatively simple, binary and compact. This provides a solution for distributed systems as well as C - Java communication.
I don't think there is any alternative to JNI, the Java-Native Interface.
You could take a look at the BUNDLE_NATIVECODE header and the related descriptions in the core specification (section 3.10). Still, you'll have to whip up a lot of interfaces using JNI then.
FYI - For C <-> Java communication the Paremus' OSGi Remote Service implementation (see Nimble) supports an Avro distribution provider.

Social networking APIs and C/C++

Folks,
Note sure if this is the best place to ask this one, but I doubt there'd be a better place. I see that github, stackoverflow, facebook, twitter, linkedin etc. have been providing developer API to slice and dice user information. Couple of questions on the general nature of these API:
1) Are these open-source?
2) Is there any general feedback on which specific programming language works best with these kind of 'social' APIs? In particular, any comments on whether C/C++ are suited for such work?
3) Is there any recommended C/C++ open source package for 'mashups' across social networks?
An API is a specification, not code, to "open-source" doesn't really apply though each might have licensing restrictions on how you use their API that might affect how suitable they were to your code being open-source.
The language will be dictated (or suggested) primarily based on what you're doing with the data, not how/where you obtain the data. You might find the networking part a bit simpler with something like Python or Perl, and do only the heavy computation (if any) in C++.
I doubt there's one that's universally recommended. The usual suspects (e.g., Boost::ASIO, ACE, POCO) will probably work reasonably well for this as they do with other networking.
Most of the social networking sites provides RESTful API that means that you need to send/receive HTTP requests/response from your application with the supported serialization format (XML/JSON/etc). Pretty much thats all you need to do. Any good Networking library and serialization/de-serialization library would let you call the APIs provided by the social networking sites. Ruby/Python/Java/Google Go/Scala has good support for these libraries/techniques. As for C++ Boost and Poco Provides rich set of networking/serialization libraries. Here is a facebook client library in C++. For twitter you have QTweetLib , QTwitLib and twttcurl. The social apis are kind of web services provided by these sites. I am not sure if opensource really applies to them.