Integrating CINT to .NET application


I’m planning to build an simulated robotics e-lab environment where students can submit their source code through the web page and see the simulated action through MJPEG stream. The simulator i use is Microsoft Robotics Studio. I don’t want to take risk and let system compile .NET C# code when there’s no quarantee that anybody doesn’t insert vulnerable or crashing code. Therefore i would like to use interpretator, like CINT, which can be controlled and limited. Unfortunately CINT is quite large project and i haven’t found information how to implement such system.

Does anybody have suggestions or idea how could it be done? My idea was linking libcint.dll to my application, but as Robotics Studio runs in managed environment libcint should be wrapped into .NET library, which, at least for me, is something new. I found libcint header file from CINT source code but the experiments weren’t successful.

Please comment it.

I picture the system like that:
There’s a Windows machine with constantly running Robotics Studio application (service), which is almost like general EXE. It listens on some TCP port for C source code and interpetates it on arrival. There are functions for driving, moving manipulator and getting sensor values. Then there’s a Linux web server which serves the e-lab homepage. If the user submits the code to web server, it forwards the code to Robotics Studio application TCP port. The feedback video is sent directly from Windows machine to the user.


you could start by wrapping only the needed functions. Start e.g. by G__calc. I have no experience with creating C# wrappers, though.

Cheers, Axel.

I have some experience with this. I’ve wrapped most of ROOT in .NET wrappers. It is very painful to implement (see But this isn’t what you want. CINT is just like raw C# - CINT can open files, delete things, etc. - it has access to everything that is allowed by the user your web server backend is running on.

What you really want to do is run in a sandboxed environment. I’d strongly suggest checking that out. If C# is ok for you, there are a wealth of security controls for it. Some of them can disallow OS access (which it sounds like what you want to do). But these are pretty serious - remember that .NET is post-MS’s decision to get serious about security. So, for example, if your students want to call one of the framework’s api’s it will have to be correctly marked as “secure” - otherwise the .NET linker will fail to complete the link!

I’d say check out msdn and the various news groups to find out this information.

Thanks for advise. I actually tried the rootdotnet but i couldn’t understand a thing. Now i know for sure not to try :slight_smile:

I thought about taking a look into the heart on MS compiler system but i have doubts about this. Even if i get the system working, it still means long compiling and loading times of simulated environment. And this way i can’t run several simultaneous simulations, or at least it’s going to be (very) complicated.

By the way, there’s a new C interpretator for Blackfin/UNIX GCC compiler - PicoC. As the name implies, it’s lightweight.
I managed to compile it as a DLL in Windows with MingW and link it to the .NET library. The tests with printf(“Hello”) worked but more complicated tests crashed. I’m still working on it.

Yet, the PicoC is very beta and it supports only basic syntax. If possible i still like to use CINT. I only need library with 3 functions (which i already implemented to PicoC):

addfunction(function declaration, callback pointer to actual function);
setputcfunction(callback pointer to outputting function);

The first one allows to add function which can be called from interpretated code (script). The second one is for getting interpretor and script output. The third one is obvious.

Okay, maybe 3 is not enough as there should be some way to terminate the script. Something like executeNextToken would do the job, as host application can constantly call this in seperate thread and end it whenever needed.

Good, glad you found something.

As far as long build times. I’ve written code in the past that included building C# and then ran it 1000’s of times. It was quite efficient. It really depends on how long your simulation will run. It takes less than one second to do most builds - for a 30 line program it was of order 100 ms, and for 100 it was about 110 or so. Once built, it was just like compiled code. If you have 1000’s of lines of code and want to run it only for a short time then you are in a different boat.

BTW - the C# and VB compilers are actually just subroutines now. If you are living in the .NET system there is a HUGE amount of meta-data availible. Your life is much much better than if you are living on the C++ world (ROOT, for example, attempts to fix this with their meta-data system).

The other thing you might consider is if you have a fairly limited set of commands to execute - perhaps you don’t need the full power of a general purpose programming language. Instead you might explore domain specific language (DSL). There are tools around that help you bang out one of those.

Good luck!