Why SAX.writer(XML) and not CGI wrapper(HTML - {&OUT}) - openedge

I want to understand the difference between SAX.writer and CGI wrapper. I can't find any get started information, any suggested content OR video link it can be very appreciated thanks.

The SAX writer is a set of language statements/elements that allow the creation of well-formed XML documents. This XML is output to the location specified by the SET-OUTPUT-DESTINATION method. Output destinations include streams (which might include a Classic WebSpeed stream (WEB-STREAM).
CGI wrapper is more of an approach, with a bunch of (internal) procedures that let you create a fully-formed HTTP response (and read from an incoming HTTP request). This approach should not be used for new web services, even though it still works. In newer version of OpenEdge the PASOE server provides what are known as WebHandlers, which replace the CGI wrapper approach.
The {&OUT} 'syntax' is really just a preprocessor that does something like PUT UNFORMATTED STREAM WEB-STREAM - you can see this if you compile your programs with the PREPROCESS option, or use the equivalent command in PDSOE (a right-click option).

Related

Encrypt file and hide the code from "info body"

Is there any way protect tcl code by "info body" after the file encrypt and execute in tool?
Obfuscate the code with the compiler from the Tcl Dev Kit; when the output of that is loaded in, it creates procedures whose contents cannot be inspected (by virtue of setting a special flag that turns off inspection). It also turns off a number of other related tools, such as the bytecode disassembler. (Curiously, this actually comes with a small performance penalty relative to standard Tcl; the special bytecode loader library is actually slower than Tcl's built-in bytecode compiler.)
That said, if you are genuinely worried about someone looking at your code, the only way to go is to not give users the code at all, but rather to host it as a service that they then just use remotely (with the clients not being subject to the same degree of protections).
And if you're not that worried, merely packing the code into a starkit (or other single-file distribution mechanism; there's a few options) is enough to stop all but the most determined of users, even with no further steps to conceal things.

LDAP Proxy with inspection/modification of requests and responses

I need to build an LDAP proxy that I can program to inspect and modify the LDAP requests and responses - some of the LDAP requests/responses will simply be passed through, but for others I might want to send two different requests to the server and then combine the results (that's just one example - there will be other use cases).
I've looked at the proxying options documented for OpenLDAP's slapd, and I see that it has quite flexible configuration and 'overlays', but no capability to insert custom code.
So I think that's not a solution, unless slapd's source code is easy to modify, to insert my own modules plus hooks to/from the existing code (?)
An alternative would be to start with a friendly TCP/IP framework library (or even a complete TCP/IP proxy). Then I can link to an ASN.1 decoding/encoding library, and write the rest myself.
I'd prefer to avoid having to write (& learn) all the TCP/IP connection/message handling and event loop myself.
So I'm looking for the most complete starting point that does the hard work and gives me the flexibility to write what I need. Typical lazy/greedy approach :-)
Must be open source, ideally in C or C++, and I'll probably be targetting RHEL/CentOS 8 in a container.

gRPC Java File Download Example

I am looking for a way on how to implement file download functionality using gRPC but I can't find in the documentation how this is done.
What is an optimal way to do this? I wanted to have a gRPC server that holds files and a gRPC client to request something from gRPC.
I have looked at the examples in Java but could not figure out a way on how to do this. I just started reading about gRPC today.
You must define a specific message as data container and you must transfer it to the client in chunks using a stream.
Example of proto Message and RPC service:
message DataChunk {
bytes data = 1;
}
rpc DownloadProductImage(DownloadProductImageRequest) returns(stream DataChunk){}
In java you can use BufferedInputStream to stream the resource to the client.
protobuf / grpc
server side code
client side code
There are a few possible approaches.
If your file size is small enough, you can define a proto file with a single String field, and dump the entire text content into that field.
If your file size is too large to do this, you might want to chunk the file and use the streaming API to send the file chunk by chunk.
Below is a good guide for getting started with gRPC.
https://grpc.io/docs/tutorials/basic/java.html
I have taken the working example from db80 and have created a PR with a full example: https://github.com/grpc/grpc-java/pull/5126
Hopefully they will merge this then everyone can have a working example of this common use-case for GRPC.

How do you share a static constant global string between two separate applications in Qt?

I am writing a client and server as separate applications. There are some global strings that both should have access to in order to ensure proper communication between the two. What is the typical method to provide such strings to both applications?
I imagine one possible method would be to place the strings in a header file and distribute that file with both applications. Is there anything in Qt that I can use to obtain an OS-agnostic location to place this header file so both applications will know where to look for it?
I'm looking for a solution that benefits from existing Qt libraries, but any generic approach would work as well. I'm not even sure a "library" is necessary, but so far Qt has helped my applications be OS-agnostic and I don't want to break from that paradigm.
Update to add clarity: These global strings would be static and constant - meaning they wouldn't change during runtime, so shared memory isn't needed. I just don't want to have a header file in the client and a header file in the server and then have to always make sure that their contents were exactly the same.
EDIT: QSettings should do the trick, too, like #Amartel suggested.
It is persistent and is easily access. Just make sure that your programs perform readSettings and writeSettings when necessary, if you want to updated the settings on the fly. I like the INI format that it has.
http://qt-project.org/doc/qt-4.8/mainwindows-application.html
http://qt-project.org/doc/qt-4.8/qsettings.html#details
http://qt-project.org/doc/qt-4.8/tools-settingseditor.html
QSharedMemory could also work.
http://qt-project.org/doc/qt-4.8/qsharedmemory.html
Example:
http://qt-project.org/doc/qt-4.8/ipc-sharedmemory.html
You can also achieve this with a QLocalServer.
http://qt-project.org/doc/qt-4.8/qlocalserver.html
http://qt-project.org/doc/qt-4.8/qlocalsocket.html
Example:
http://qt-project.org/doc/qt-4.8/ipc-localfortuneclient.html
http://qt-project.org/doc/qt-4.8/ipc-localfortuneserver.html
Hope that helps.
Qt gives a lot of ways of sharing data between processes, but most of them require these processes to share a machine. Since you are implementing a client-server paradigm, I assume your applications would interact with each other, and could be located at different computers. In this case the most common way is to establish a TCP connection and transfer data through TCP socket. Connection settings could be placed in a configuration file (for example QSettings with parameter QSettings::IniFormat).

Modifying First and Last Name in Hotmail via script

I would like to write a script that logs into hotmail and changes the first and last name. I am thinking of perl for this, although I imagine that any language would do.
How do I find out what requests to make? I'm guessing that I can do the change requests manually, determine what http requests are being sent to/from the server, determine what pattern is being sent, and then attempt to generate a similar pattern (substituting in the changes I want) in my script.
I took a look at ethereal, but I get a message "the installer is corrupted". I'm going to look at "Advanced http packet sniffer" next - anyone have experience with this tool?
Yes you can use Perl (or any languages with modules that support HTTP(S) ). And you can use libraries already made by people. Eg WWW::Hotmail or Hotwayd. Search CPAN for more of those modules as well.

Resources