I develop a Win32 C++ cgi app for windows and linux and start from scratch.
I use CgiCC as lib and Visual Studio 2010 as IDE.
How can I debug that? When I instanziate my cgicc class the program holds and waits for CGI input I guess.
How can I set up an environment for my CGI input?
I set some environment variables like QUERY_STRING.
But I have no idea how to provide the values my cgi app would get while running on a webserver.
EDIT:
I am almost there.
I captured the traffic while browsing and wrote that content to a file.
Then I redirected stdin to that file: "< input.txt" as debug command line arguments in visual studio.
I set some environment variables under windows like CONTENT_LENGTH and CONTENT_TYPE.
after that I can read some content from my input like this:
cgicc::Cgicc cgi;
string u = cgi("user");
but i get an exception (reading from unallocated memory and exceptions like that) while doing this:
vector<FormFile, allocator<FormFile>> files = cgi.getFiles();
somehow not everthing if loaded correctly.
CGI apps receive their input via environment variables and standard input, so you can easily replicate the environment that a web server sets up for the CGI task.
As far as environment variables, here is a list of the environment variables that are part of the CGI protocol. I recommend that you set all of them, either by hand or better yet, by capturing the environment given to a working cgi app by a production web server. Since environment variables are inherited by child processes, if you set these up in your environment inside a Windows command prompt and then invoke the Visual Studio IDE from that same window then these variables will be available when your CGI application starts inside the debugger and also when you run it without debugging.
Getting a standard input replacement can be a bit more complex in your case, since you are working with a file upload form. This site contains a template that should get you started with the multipart/form-data format. The official document for file uploads via forms is RFC 1867.
I hope this helps.
Solved it by myself:
Build cgicc with the same visual studio version that I compile my project with.
Build cgicc as a static library instead of a dynamic library.
Setting the preprocessor define CGICC_EXPORTS in my project which activated __declspec(dllexport).
Then it worked!
Related
We have an external app that allow use to build and deploy ssis projects using command tool
after a migration with vs 2019, process no longer work (probably because external app use old resource file)
previously, we use msbuild, with a xxx.proj using
UsingTask TaskName="DeploymentFileCompilerTask" AssemblyFile="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.SqlServer.IntegrationServices.Build.dll"
now, the same no longer work. I tried to use a newer version of Microsoft.SqlServer.IntegrationServices.Build.dll but it refer now to an vsintegration dll file.
So, I would like to use devenv.com tool instead.In local, it works.
the problem is that some projects have SecurityLevel to EncryptSensitiveWithPassword and when using
devenv.com "project.sln" /Build Development /Project "project\SsisCommon.dtproj" /ProjectConfig Development
in local, it prompt for the project password, and then after entered it, it generate ispac.
But the problem is that the external app not allow prompting, and then we got this kind of error
Unhandled Exception: System.InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
How I can pass the project password without prompting ?
thanks in advance
regards
I finally use the SSISBuild project - https://github.com/rtumaykin/ssis-build/ - (recompiling after updating encrypt / decrypt process) as related here: https://github.com/rtumaykin/ssis-build/issues/25
it works finally fine.
regards
I'm porting some Qt Windows/VC++ code to Linux/GCC. The application can add it's own shortcut to the Windows Autostart folder so the application starts after login.
I want to do the same in Linux. I'm using Kubuntu 15.10 but the solution should work for virtually all (or at least most) Linux variants out there. And it should work without super user rights (or it should request the rights automatically).
I searched the web and found two solutions:
Add a desktop entry file to $HOME/.config/autostart
Add a symbolic link to /etc/init.d/
Will they both work in all Linux distributions? What are the differences? Which is to be preferred?
Also I would like to know if I should do that by programmatically running a shell command or if there is some native API I could use in C/C++ (including easy error detection).
I have put project in GitHub for managing auto-start feature in different OS. It's written in Qt.
Please check it and let me know if you have any problem using it:
https://github.com/b00f/qautostart
You can add application in various ways.
Via linux init system. For newest linux OS systemd is a standard. In this case your need to create systemd unit for your application
Via desktop manager, such as gnome, kde and possible others. In this case you need also create specification for autostarting your app.
Via bash files
I think, prefered way via systemd unit, because now this is standard way for starting process at boot time and for special user, if need.
I have a C++ project that is called in Python (via boost-python) and I want to debug the C++ code from python process. How can I do that? In Windows with Visual Studio I can use the functionality attach to process. How to achieve the same in Eclipse?
Thanks
For me it works great just adding a debug configuration in C/C++ for the program /usr/bin/python (or whatever search path you have to the python interpreter) and then put the python program you want to run as the arguments. Put the breakpoints you want in the C-code and you should be all set for running the debug configuration and opening the debug perspective.
If it still does not work you may also check that you are using Legacy (or Standard) Process Launcher. For some reason the GDB process launcher does not seem to work here.
I am new to cgi and have an cgi C++ application to debug.
How can I set up the environment on my developer PC in order to debug in visual studio?
My app supports GET and POST method but I have no idea what to do to make it start up correctly.
The app is started through a link with some arguments like:
myApp.exe?mode=create&name=jack...
Any suggestions?
Thanks
juergen
If your parameters are usually sent as part of the URL, then they should be found in the QUERY_STRING environment variable. You normally get this by calling get_env("QUERY_STRING").
Before running, try setting the environment variable QUERY_STRING to contain mode=create&name=jack
I have a Visual C console application (created in VC++2008EE) and I need to add GUI to it.
One idea was to invoke the console app as a subprocess and communicate with it using stdin and stdout. I tried to do that with Python subprocess module - but it deadlocks (probably because my console app is running continuously). As I understood from http://www.python.org/dev/peps/pep-3145/ it is not possible now to integrate continiously running console application with python subprocess module.
The other idea (more strait-forward probably) was to add a form to this console application project. But as I try to do it VS convers the project to one with "Common Language Runtime support" whatever it means, ads the form, a cpp file for form - and it's not compiling anymore saying:
Command line error D8016 : '/MTd' and '/clr' command-line options are incompatible
error BK1506 : cannot open file '.\Debug\Form_TEST.sbr': No such file or directory
No idea what it means. I have never dealed with C++, but I have used C and Python some time.
What would you recommend?
If you own the code for the console app, don't mess around trying to talk to it using input and output streams. Extract the logic of your console app into a library, and call that library from a GUI of your choice - either Windows.Forms from C#, Python GTK, ordinary GTK.
The reason that VS turns your application to CLR type is becuase it accidently thinks that you want to use winforms which are part of the .NET framework and the only way to use them is if your project is .NET as well.
You do have other options:
1. Add MFC GUI - native C++ GUI
2. better yet create a new .NET project (C#/VB.NET) with the desirect GUI and call your C/C++ dll using P-Invoke or COM interop