Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing a C++ CFX tag for Linux

Status
Not open for further replies.

da644

Programmer
May 21, 2001
159
GB
Hi All.

I need to write a C++ CFX tag for Linux and I've not done one before, so I thought I would start with a simply "Hello World" application.

Here the code in the my C++ file...

// Include Standard Librarys (not if they are needed at this point)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "cfx.h" // CFX Custom Tag API

// Constants
#define TAG_ERROR_HEADER "Error occurred in Test tag"

extern "C"
void ProcessTagRequest( CCFXRequest* pRequest )
{
try
{
pRequest->Write( "Hello World" );
}

// Catch Cold Fusion exceptions & re-raise them
catch( CCFXException* e )
{
pRequest->ReThrowException( e ) ;
}

// Catch ALL other exceptions and throw them as
// Cold Fusion exceptions (DO NOT REMOVE! --
// this prevents the server from crashing in
// case of an unexpected exception)
catch( ... )
{
pRequest->ThrowException(
TAG_ERROR_HEADER,
"Unexpected error occurred while processing tag." ) ;
}
}

I then compiled this using the following Makefile:

INCLUDE = -I /opt/coldfusionmx/cfx/include
CXX = g++
LD = g++

SRC = request.cc
OBJ = request.o

test.so: $(OBJ)
$(LD) -shared -o test.so $(OBJ)

request.o: request.cc
$(CXX) $(INCLUDE) -c request.cc

clean:
rm -f test.so $(OBJ)

This all compiled ok and create a test.so file. I registered this via CF Admin as CFX_test and then create a create a script to call CFX_test:

<CFX_test>

I then called this script via the browser and all I get is a blank page. I had asssumed I would see "Hello World" in the browser, but nothing. There are no error messages either when compiling, registering or running the script. Can anyone help point me in the right direction as I guess I'm doing something completely wrong somewhere along the way.

Best Regards

Andrew.
 
I understand nothing of C++ and this answer was actually hard to find but maybe it will help..


Code:
CHAR buffOutput[1024] ;
wsprintf( buffOutput, "The destination is: %s",
        pRequest->GetAttribute("DESTINATION") ) ;
pRequest->Write( buffOutput ) ;

I notice that they load into a buffer whereas you do not.. That might change things for you.

I did find some humor in "so I thought I would start with a simply "Hello World" application."... That's the most massive "Hello World" script I've ever seen :)..

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Hi.

No, that makes no difference. I have even tried the example CFX tag that MM supply and I can't even get that to work. What joy!!!!

Andrew.
 
you'll probably have better luck asking the C++ forum

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top