virtual const char* what(void) const throw() { return reason.c_str(); }
+ // Accessors
+ OM_uint32 getMajor() { return(major); }
+ OM_uint32 getMinor() { return(minor); }
private:
std::string reason;
+ OM_uint32 major, minor;
};
#endif // GSSEXCEPTION_H
#include "commands/GSSImportName.h"
#include "commands/GSSDisplayName.h"
#include "GSSRequest.h"
+#include "GSSException.h"
using std::bad_alloc;
void GSSRequest::execute()
{
- /* variables */
- /* Error checking */
- /* Setup */
- parseJSON();
- getCommand();
-
- /* Main processing */
- if (NULL != cmd)
- cmd->execute();
-
- /* Cleanup */
- /* Return */
+ try {
+ /* variables */
+ /* Error checking */
+ /* Setup */
+ parseJSON();
+ getCommand();
+
+ /* Main processing */
+ if (NULL != cmd)
+ cmd->execute();
+
+ /* Cleanup */
+ /* Return */
+ }
+ catch (GSSException e)
+ {
+ delete(cmd);
+ cmd = NULL;
+ JSONObject return_values;
+ return_values.set("major_status", e.getMajor());
+ return_values.set("minor_status", e.getMinor());
+// response.set("error_message", e.what());
+ }
}
/* Return */
return(gssResponse);
}
+
+
+
+char *gss_request(char *json_string)
+{
+ /* Variables */
+ char *retVal;
+ string output;
+ GSSRequest *req = new GSSRequest(string(json_string));
+
+ /* Error checking */
+ // An empty json_string could be an error, but GSSRequest does
+ // a good job of handling it.
+
+ /* Setup */
+ /* Main processing */
+ req->execute();
+ output = req->getResponse();
+ retVal = new char[ output.length() + 1 ];
+ output.copy(retVal, output.length(), 0);
+ retVal[output.length()] = 0;
+
+ return(retVal);
+}
+
+void deallocate_reply(char *reply)
+{
+ delete(reply);
+}
using std::string;
+/* An exportable function to be called by firefox
+ * to process a JSON string
+ */
+extern "C" {
+ char *gss_request(char *json_string);
+ void deallocate_reply(char *reply);
+}
+
class GSSRequest
{
public: