FastCGI on Windows and Lighttpd - c

I'm looking to make my CGI forum software FastCGI compatible.
The forum software consists of a few dlls and .exe (.cgi) files written in C and x86 assembly language. I also have a SQlite3 database.
Lighttpd runs all these cgi scripts as child processes and I much say that the whole thing works pretty damn well.
But I want to experiment with FastCGI. However, the examples are poor, the documentation is poor, and it really looks like it's made for Linux in mind. Did someone get FastCGI working on Windows? If someone has a code example around, and the lighttpd configuration lines, I would be really grateful.

i've done some work with fastcgi on windows. bottom line is its not a lot of fun - you are 100% correct that there aren't a lot of sample and it the documentation is poor. but, the developer who i was helping on this was in contact with the guys who write iis and the fastcgi spec and was able to get his software to work. some changes are in the works to help. here is a link to some information:
http://blogs.iis.net/ksingla/archive/2009/04/20/fastcgi-isapi-1-5-beta-for-winxp-and-win2k3.aspx
i should add that the guy i was working with had so many problems with libfcgi.dll that he ended up rewriting it (see the reference to libfcgi2.dll in the article linked above.)
best regards,
don

Related

Onvif - trying to understand how it works

First of all, I have no experience in working with ONVIF at all. I got myself a scholarship at a company and was asked to work with it (to control some cameras and get photos from them), but they don't know how it works either, so no-one can help me much...
I was reading through the specifications available at the ONVIF webpage but I don't really get it. I know I have to use SOAP, C (I was asked to do the app in C), XML and web services. That much I understand but I don't know how am I supposed to use them. I'm not here so that you can do the work for me (that ain't fun) I just would like to know if someone here could guide me a little about what to start learning and in which order. If there's something I forgot to explain I'll add it as soon as I can.
So, you have to start with gSOAP.
Pelco has a guide to get started with gSOAP, it is for windows but it is valid for Linux as well. As you start learning gSOAP, check the last FAQ of gSOAP about the namespaces.
Finally, on the ONVIF website there's an Application Programmers Guide, which is old but still interesting. ONVIF has a forum for all people willing to learn the protocol. It does not require you to be member to access it, you can join it for free and check all the questions there.
A good approach is to study existing code from open source projects. A few of them can be found from an ONVIF challenge top 10 list. Also from the top 7 ONVIF open source projects. Especially it looks the following ones should be a good starting points:
An ONVIF Service Server - onvif_srvd which runs on a linux machine so that your RTSP cameras will be discoverable by other ONVIF tools or clients.
An ONVIF server for PI that turns a webcam into an IP Camera.
An ONVIF client with GUI built-in.

libudev advice needed

I am embarking on a programming project that will need to confirm device identity of removable media (e.g. usb thumb drives) before it will go on to do a bunch of other cool stuff.
Some friends of mine pointed me towards using the Serial Number, and preliminary testing using the udevadm command indicates that this should work. I did some additional checking and it appears that if I can get the software working with libudev then it should (minimally) compile on ubuntu, slackware and gentoo, which would be a really nice benefit.
So I used bing to find a tutorial and got the Signal 11 site (http://www.signal11.us/oss/udev/) it's a very well-written tutorial. It actually seems to have everything I need. I download the code. Fix a couple of platform-specific bugs and then compile. BOOM! Gcc compiles without errors. So far so good.
But when I try to run it, it kicks up a couple of bugs, and I realize that I need to read some more tutorials so that I can understand libudev well enough to fix the bugs, and to turn out working software. Problem is that there really ISN'T any other tutorials (that I can find) and the kernel.org site that is the (only known?) site of the library documentation is down after a recent server compromise.
I considered just issuing udevadm directives to system() and then parsing results, but that's a really hackish way to put software together, and I am planning on releasing this to the community when I'm finished writing.
So how best for me to learn libudev??
libudev is quite simple library. After reading library you've mentioned and using API documentation (site should be soon up) I was able to get what I wanted. udevadm is great help, after issuing # udevadm info --query=all --name=/path/to/dev you'll get all information that udev has about this device and what's more important, these are parameters used in property functions (e.g. udev_device_get_property_value(device, "ID_VENDOR")). So best way to learn libudev is to start using it with help of signal11 tutorial, API documentation and udevadm informations.
EDIT: libudev is currently part of systemd - documentation is available as manual pages - https://www.freedesktop.org/software/systemd/man/libudev.html#
For those looking in 2023...
As Maciej pointed out, libudev is now a part of systemd.
According to:
https://www.freedesktop.org/software/systemd/man/libudev.html#
...this library is supported, but should not be used in new projects.
Please see sd-device(3) for an equivalent replacement with a more
modern API.
Documentation for sd-device:
https://www.freedesktop.org/software/systemd/man/sd-device.html#

Erlang source code guide

I am interested in delving into Erlang's C source code and try to understand what is going on under the hood. Where can I find info on the design and structure of the code?
First of all, you might want to have a look to Joe Armstrong's thesis, introducing Erlang at a high level. It will be useful to get an idea of what was the idea behind the language. Then, you could focus on the Erlang Run Time System (erts). The erlang.erl module could be a good start. Then, I would focus on the applications who constitutes the so-called minimal release, kernel and stdlib. Within the stdlib, have a look on how behaviours are implemented. May I suggest the gen_server.erl module as a start?
A Guide To The Erlang Source
http://www.trapexit.org/A_Guide_To_The_Erlang_Source
The short answer is that there is no good guide. And the code is not very well documented.
I recommend finding someone in your neighbourhood that knows the code reasonably well, and buy them dinner in exchange for a little chat.
If you don't have the possibility to do that, then I recommend starting with the loader.
./erts/emulator/beam/beam_load.c
Some useful information can also be found by pretty printing the beam representation. I don't know whether there is any way to do so supplied by OTP, but the HiPE project has some cheats.
hipe:c(MODULE, [pp_beam]).
Should get you started.
(And I also recommend Joe's book.)
Pretty printer of beam can be done by 'erlc -S', which is equivalent with hipe:c(M, [pp_beam]) mentioned by Daniel.
I also use erts_debug:df(Module). to disassemble the loaded beam code, which are instructions actually been interpreted by the VM.
Sometimes I use a debugger. OTP delivers tools supporting gdb very well. See example usage at http://www.erlang.org/pipermail/erlang-questions/2008-September/037793.html
A little late to the party here. If you just download the source from GitHub the internal documentation is really good. You have to generate some of it using make.
Get the documentation built and most of the relevant source is under /erts (Erlang Run Time System)
Edit: BEAM Wisdoms is also a really good guide but it may or may not be what you're after.

Documentation for CMX ColdFire USB-Lite stack

This is my first embedded project, so bear with my ignorance. I've been asked to implement Remote NDIS over USB, using the ColdFire USB-Lite stack by CMX. I've been searching for a long time now, and can't find any clear documentation for this stack.
It comes with some woefully documented sample code and the only useful resource I've been able to find online is this Application Note (PDF) by Eric Gregori.
What I really want is an explanation of all the functions in the API. I can work out how to use them. Does this exist? Can someone point me to it?
EDIT: Nevermind.
After tracing the execution across 14 half-documented source files (from the example program) and scrutinizing a bunch of undocumented variables and buffers, and doing a diff between corresponding files in different projects, I think I finally get it. So I guess stackoverflow.com taught me patience... or something.
The link you referred to doesn't work for me, but the name of the file made me look at the Freescale pages, and if that's not the document you intended to link to, it might be the documentation you need.

Writing Windows Port Monitor Basics

I'm trying to find a basic example, tutorial, or blog post on how to write a printer port monitor. I downloaded the Windows DDK and dug through localmon, but it appears that this sample is much more complex than just the nuts and bolts basics and from my understanding it is a bit different than an OEM port monitor because of how it handles the registry key and port enumeration. Does anyone know of a blog post, tutorial, or even book that walks the reader through the basic code to get one up and going? I've found a few links talking about the conceptual stuff, but nothing that is hands on code.
I can recomend http://www.codeproject.com/KB/printing/wpa.aspx, which describes how to write a printer driver and also has good hints about what's necessary to build a port monitor.
But my opinion is that a good tutorial in this area is not available on the Internet (I would be glad to find somebody who can show me that I'm wrong). So, when I had to deal with this task I was forced to do it the hard way: I've read carefully the MSDN explanations starting from this point: http://msdn.microsoft.com/en-us/library/ff561109.aspx. In parallel with reading MSDN I also checked the code in DDK you mentioned and try to understand it. I'm sure this solution could also work for you.
I wrote mine from the specs, there aren't really that many API's to implement.
The one thing that regularaly trips people up is EnumPorts, the spooler allocates enough memory for ALL the ports, not just yours. So you need to make sure you fill any strings from the end of the spoolers buffer, don't put them straight after your structures.
It doesn't say so in the specs but you can safely put the UI and Server functions in the same DLL.
It's also possible to create a single port monitor that supports NT and the later Windows 2000 type port monitors.
The code in RedMon is much easier to read than the localmon example, it's worth looking at before you start. It's quite nice because you can compile it in VS, you don't need to use the DDK to build it.
I have been over that exact same territory for a serial printer. About the best example I found was this article in Dr Dobbs Journal. The good part is that both a serial port driver and the user-space control program are covered and the project can also be used as an example of how to set up Visual Studio to compile a driver. This is also something a little difficult to find information about. The article discusses an old NT style driver, which worked well for me on XP.
There are quite a few good articles on CodeProject about writing drivers and programs to interact with them. They include source code and most deal with the newer WDM and WDF style drivers.
OSROnline is another good source, especially for discussion of specific issues and common mistakes. They also have some great utilities you will need.
Some of the most clearly written and understandable driver code I came across was Mark Russinovich's sample code. Although Microsoft withdrew all of the source when they purchased Sysinternals, some of the best examples can still be found cached here and there.
Drivers are pretty interesting. Whatever else you do though, do it in a virtual machine. Really.

Resources