static ColorMap *
cmap_from_pyobject(PyObject *pyarray)
{
    int len, i;
    GradientColorMap *cmap;

    len = PySequence_Size(pyarray);
    if(len == 0)
    {
	PyErr_SetString(PyExc_ValueError,"Empty color array");
	return NULL;
    }

    cmap = new(std::nothrow)GradientColorMap();

    if(!cmap)
    {
	PyErr_SetString(PyExc_MemoryError,"Can't allocate colormap");
	return NULL;
    }
    if(! cmap->init(len))
    {
	PyErr_SetString(PyExc_MemoryError,"Can't allocate colormap array");
	delete cmap;
	return NULL;
    }

    for(i = 0; i < len; ++i)
    {
	double left, right, mid, left_col[4], right_col[4];
	int bmode, cmode;
	PyObject *pyitem = PySequence_GetItem(pyarray,i);
	if(!pyitem)
	{
	    return NULL; 
	}

	if(!get_double_field(pyitem, "left", &left) ||
	   !get_double_field(pyitem, "right", &right) ||
	   !get_double_field(pyitem, "mid", &mid) ||
	   !get_int_field(pyitem, "cmode", &cmode) ||
	   !get_int_field(pyitem, "bmode", &bmode) ||
	   !get_double_array(pyitem, "left_color", left_col, 4) ||
	   !get_double_array(pyitem, "right_color", right_col, 4))
	{
	    return NULL;
	}
	
	cmap->set(i, left, right, mid,
		  left_col,right_col,
		  (e_blendType)bmode, (e_colorType)cmode);

	Py_DECREF(pyitem);
    }
    return cmap;
}
Пример #2
0
bool blend_state_from_lua(lua_State *l, const char *state_name, CComPtr<ID3D11BlendState>& blend_state)
{
	// push state table on stack
	lua_getglobal(l, state_name);

#define CREATE_DESC(x) \
	lua_pushinteger(l, x);  \
	lua_gettable(l, -2); \
	D3D11_RENDER_TARGET_BLEND_DESC b ## x = { \
	get_int_field(l, "BlendEnable"), \
	(D3D11_BLEND)get_int_field(l, "SrcBlend"), \
	(D3D11_BLEND)get_int_field(l, "DestBlend"), \
	(D3D11_BLEND_OP)get_int_field(l, "BlendOp"), \
	(D3D11_BLEND)get_int_field(l, "SrcBlendAlpha"), \
	(D3D11_BLEND)get_int_field(l, "DestBlendAlpha"), \
	(D3D11_BLEND_OP)get_int_field(l, "BlendOpAlpha"), \
	get_int_field(l, "RenderTargetWriteMask") }; \
	lua_pop(l, 1);

	CREATE_DESC(0);
	CREATE_DESC(1);
	CREATE_DESC(2);
	CREATE_DESC(3);
	CREATE_DESC(4);
	CREATE_DESC(5);
	CREATE_DESC(6);
	CREATE_DESC(7);

  blend_state.Attach(rt::D3D11::BlendDescription().
    AlphaToCoverageEnable_(get_int_field(l, "AlphaToCoverageEnable")).
    IndependentBlendEnable_(get_int_field(l, "IndependentBlendEnable")).
    RenderTarget_(0, b0).
    RenderTarget_(1, b1).
    RenderTarget_(2, b2).
    RenderTarget_(3, b3).
    RenderTarget_(4, b4).
    RenderTarget_(5, b5).
    RenderTarget_(6, b6).
    RenderTarget_(7, b7).
    Create(Graphics::instance().device()));

  return !!blend_state.p;
}
Пример #3
0
// helper function to set a D3D11_SAMPLER_DESC
bool sampler_from_lua(lua_State *l, const char *sampler_name, CComPtr<ID3D11SamplerState>& sampler)
{
	// TODO: add support for border

	// push sampler table on stack
	lua_getglobal(l, sampler_name);
  sampler.Attach(rt::D3D11::SamplerDescription().
    AddressU_((D3D11_TEXTURE_ADDRESS_MODE)get_int_field(l, "AddressU")).
    AddressV_((D3D11_TEXTURE_ADDRESS_MODE)get_int_field(l, "AddressV")).
    Filter_((D3D11_FILTER)get_int_field(l, "Filter")).
    MipLODBias_(get_float_field(l, "MipLODBias")).
    MaxAnisotropy_(get_int_field(l, "MaxAnisotropy")).
    ComparisonFunc_((D3D11_COMPARISON_FUNC)get_int_field(l, "ComparisonFunc")).
    //BorderColor_(0, )
    MinLOD_(get_float_field(l, "MinLOD")).
    MaxLOD_(get_float_field(l, "MaxLOD")).
    Create(Graphics::instance().device()));

  return !!sampler.p;
}
Пример #4
0
static void checkarg_regaparams (lua_State *L, int stackpos,  regaparams_t *argP) {
  if (lua_type (L, stackpos) != LUA_TTABLE) /* allow for userdata? */
    luaL_argerror (L, stackpos, "table expected");
  lua_pushvalue (L, stackpos);
  argP->cost_ins   = get_int_field (L, "cost_ins");
  argP->cost_del   = get_int_field (L, "cost_del");
  argP->cost_subst = get_int_field (L, "cost_subst");
  argP->max_cost   = get_int_field (L, "max_cost");
  argP->max_ins    = get_int_field (L, "max_ins");
  argP->max_del    = get_int_field (L, "max_del");
  argP->max_subst  = get_int_field (L, "max_subst");
  argP->max_err    = get_int_field (L, "max_err");
  lua_pop (L, 1);
}
Пример #5
0
/*
 * Connects to MySQL.
 */
static int connect (lua_State *L) {
    mysql_rec *m;
    const char *host, *user, *passwd, *db, *unix_socket, *charset;
    int port;

    luaL_checktype(L, 1, LUA_TTABLE);
    host = get_string_field(L, 1, "host", NULL);
    user = get_string_field(L, 1, "user", NULL);
    passwd = get_string_field(L, 1, "password", NULL);
    db = get_string_field(L, 1, "database", NULL);
    port = get_int_field(L, 1, "port", 0);
    unix_socket = get_string_field(L, 1, "unix_socket", NULL);
    charset = get_string_field(L, 1, "charset", NULL);

    m = (mysql_rec *) lua_newuserdata(L, sizeof(mysql_rec));
    memset(m, 0, sizeof(mysql_rec));
#ifdef _REENTRANT
    if (pthread_mutex_lock(&lock) != 0) {
        lua_pushliteral(L, "Error acquiring MySQL lock");
        lua_error(L);
    }
#endif
    m->mysql = mysql_init(NULL);
#ifdef _REENTRANT
    if (pthread_mutex_unlock(&lock) != 0) {
        lua_pushliteral(L, "Error releasing MySQL lock");
        lua_error(L);
    }
#endif
    if (!m->mysql) {
        lua_pushliteral(L, "MySQL error: out of memory");
        lua_error(L);
    }
    if (!mysql_real_connect(m->mysql, host, user, passwd, db, port,
                            unix_socket, 0)) {
        lua_pushfstring(L, "MySQL error %d (%s): %s",
                        mysql_errno(m->mysql), mysql_sqlstate(m->mysql),
                        mysql_error(m->mysql));
        mysql_close(m->mysql);
        lua_error(L);
    }
    if (charset) {
        if (mysql_set_character_set(m->mysql, charset)) {
            error(L, m);
        }
    }

    luaL_getmetatable(L, IS_MYSQL_METATABLE);
    lua_setmetatable(L, -2);

    return 1;
}
Пример #6
0
/*
 * Parse the string in 'line' using the CSV format from the problem spec.
 * Assumes 'line' is a proper C string ('\0' terminated).
 *
 * Returns true iff the string is sytactically correct.
 */
int parse_line(char line[]) {
	int nmatches = 0 ;	// assume no matches.

	init_regexps() ;

	if( regexec(&parse_5, line, MAX_MATCHES, matches, 0) == 0 ) {
		nmatches = 5 ;
	} else if( regexec(&parse_4, line, MAX_MATCHES, matches, 0) == 0 ) {
		nmatches = 4 ;
	}

	if( nmatches != 0) {
		last_reading.room_id = get_int_field(line, matches[1]) ;
		last_reading.event.sensor = get_int_field(line, matches[2]) ;
		get_time_string_field(last_reading.event.time_stamp,
				line, matches[3]) ;
		last_reading.event.event_id = get_int_field(line, matches[4]) ;
		last_reading.event.event_info =
			(nmatches == 5) ? get_int_field(line, matches[5]) : -1 ;
	}
	return nmatches != 0;
}
Пример #7
0
bool rasterizer_state_from_lua(lua_State *l, const char *state_name, CComPtr<ID3D11RasterizerState>& state)
{
  lua_getglobal(l, state_name);
  state.Attach(rt::D3D11::RasterizerDescription().
    FillMode_((D3D11_FILL_MODE)get_int_field(l, "FillMode")).
    CullMode_((D3D11_CULL_MODE)get_int_field(l, "CullMode")).
    FrontCounterClockwise_(get_int_field(l, "FrontCounterClockwise")).
    DepthBias_(get_int_field(l, "DepthBias")).
    DepthBiasClamp_(get_float_field(l, "DepthBiasClamp")).
    SlopeScaledDepthBias_(get_float_field(l, "SlopeScaledDepthBias")).
    DepthClipEnable_(get_int_field(l, "DepthClipEnable")).
    ScissorEnable_(get_int_field(l, "ScissorEnable")).
    MultisampleEnable_(get_int_field(l, "MultisampleEnable")).
    AntialiasedLineEnable_(get_int_field(l, "AntialiasedLineEnable")).
    Create(Graphics::instance().device()));

  return !!state.p;
}
Пример #8
0
bool depth_stencil_state_from_lua(lua_State *l, const char *state_name, CComPtr<ID3D11DepthStencilState>& dss)
{
	// push sampler table on stack
	lua_getglobal(l, state_name);

  dss.Attach(rt::D3D11::DepthStencilDescription().
    DepthEnable_(get_int_field(l, "DepthEnable")).
    DepthWriteMask_((D3D11_DEPTH_WRITE_MASK)get_int_field(l, "DepthWriteMask")).
    DepthFunc_((D3D11_COMPARISON_FUNC)get_int_field(l, "DepthFunc")).
    StencilEnable_(get_int_field(l, "StencilEnable")).
    StencilReadMask_(get_int_field(l, "StencilReadMask")).
    StencilWriteMask_(get_int_field(l, "StencilWriteMask")).
    FrontStencilFailOp_((D3D11_STENCIL_OP)get_int_field(l, "FrontStencilFailOp")).
    FrontStencilDepthFailOp_((D3D11_STENCIL_OP)get_int_field(l, "FrontStencilDepthFailOp")).
    FrontStencilPassOp_((D3D11_STENCIL_OP)get_int_field(l, "FrontStencilPassOp")).
    FrontStencilFunc_((D3D11_COMPARISON_FUNC)get_int_field(l, "FrontStencilFunc")).
    BackStencilFailOp_((D3D11_STENCIL_OP)get_int_field(l, "BackStencilFailOp")).
    BackStencilDepthFailOp_((D3D11_STENCIL_OP)get_int_field(l, "BackStencilDepthFailOp")).
    BackStencilPassOp_((D3D11_STENCIL_OP)get_int_field(l, "BackStencilPassOp")).
    BackStencilFunc_((D3D11_COMPARISON_FUNC)get_int_field(l, "BackStencilFunc")).
    Create(Graphics::instance().device()));

  return !!dss.p;
}
Пример #9
0
JNIEXPORT jstring JNICALL SUBMIT_MESSAGE (JNIEnv *env, jobject obj) {

    const char FUNCNAME[] = "submitMessage";
    MsgObject       the_msg;
    char            *tmpstr;
    char            *msg_id;
    int             check_flag;
    int             actionCode;
    int             retry_count;
    char            *user_id;
    char            *subject;
    char            *valid_time;
    long            valid_time_long;
    char            *timeout_time;
    long            timeout_time_long;
    int             priority;
    int             type;
    char            *product;
    char            *body_file;
    char            *bodybuf	= NULL;
    size_t          bodybufsiz;
    jclass          msg_class;
    jstring         jmsg_id;
    char            buf[200];

    /* Start code ----------------------------------------------------------------------------------- */
    dwbNETsetEnv(0, (char **) NULL);

    msg_class = (*env)->GetObjectClass(env, obj);
    sprintf(buf, "%s/MhsSubmitException", PACKAGE_CLASS);
    if ((newExcCls = (*env)->FindClass(env, buf)) == NULL) {
	sprintf(statbuf, "Could not find Exception Class \"%s/MhsSubmitException\"\n", PACKAGE_CLASS);
        printf(statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }

    /* Note: To get the various signatures, use this command: javap -s -p com.raytheon.messaging.mhs.MhsMessage */

    /* Get the showTrace flag ----------------------------------------------------------------------- */
    if (!get_boolean_field(env, obj, msg_class, "showTrace", &show_trace)) {
        strcpy(statbuf, "Could not get boolean field \"showTrace\"");
        throw_submit_exception(env, FAIL_JNI, statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }

    /* Get the message type ------------------------------------------------------------------------- */
    if (!get_message_type(env, obj, msg_class, &type)) {
        strcpy(statbuf, "Could not get message type field");
        throw_submit_exception(env, FAIL_JNI, statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }

    /* Create the message object -------------------------------------------------------------------- */
    if (!(the_msg = coDDM_createMsg(type))) {
        sprintf (statbuf, "Failed createMsg type=%d\n", type);
        throw_submit_exception(env, FAIL_CREATE, statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }

    /* Get the productID ---------------------------------------------------------------------------- */
    if (!get_string_field(env, obj, msg_class, "productId", &product)) {
        strcpy(statbuf, "Could not get product ID");
        throw_submit_exception(env, FAIL_JNI, statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }

    if (strlen(product) > 0) {
        if (show_trace) printf ("Product ID: %s\n", product);
        if (coDDM_setProdID(the_msg, product) < 0) {
            sprintf (statbuf, "Failed setProdID '%s'\n", product);
            free(product);
            throw_submit_exception(env, FAIL_PRODID, statbuf);
            return((*env)->NewStringUTF(env, statbuf));
        }
    }
    free(product);

    /* Get the verifyAddressees flag ---------------------------------------------------------------- */
    if (!get_boolean_field(env, obj, msg_class, "verifyAddressees", &check_flag)) {
        strcpy(statbuf, "Could not get verifyAddressees field");
        throw_submit_exception(env, FAIL_JNI, statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }
    if (show_trace) printf ("Verify addressees flag: %d\n", check_flag);

    /* Get the Addressees --------------------------------------------------------------------------- */
    if (!set_msg_addressees(the_msg, env, obj, msg_class)) {
        return((*env)->NewStringUTF(env, statbuf));
    }

    if (show_trace) {
        AddrObject  addr;
        for (addr = addrListGetFirstItem(the_msg->addr_list); addr; addr = addrListGetNextItem(the_msg->addr_list)) {
            printf ("Addressee from msg object: %s %s\n", addr->addressee_name, addr->ack_required ? "(A)" : "");
        }
    }

    /* If check flag is set, don't send the message -- only verify the addressees ------------------- */
    if (check_flag) {
        int     bufsiz = 0;
        char    *addrbuf;
        char    *p_addrlist_out;

        for (tmpstr = coDDM_getFirstAddrName(the_msg); tmpstr; tmpstr = coDDM_getNextAddrName(the_msg)) {
            bufsiz += strlen(tmpstr)+1;
        }

        if (!(addrbuf = malloc(bufsiz+1))) {
            sprintf (statbuf, "Could not allocate %d bytes in %s\n", bufsiz+1, FUNCNAME);
            coDDM_destroyMsg(&the_msg);
            throw_submit_exception(env, FAIL_JNI, statbuf);
            return((*env)->NewStringUTF(env, statbuf));
        }

        addrbuf[0] = '\0';
        for (tmpstr = coDDM_getFirstAddrName(the_msg); tmpstr; tmpstr = coDDM_getNextAddrName(the_msg)) {
            if (strlen(addrbuf)) {
                strcat (addrbuf, ",");
            }
            strcat(addrbuf, tmpstr);
        }

        if (show_trace) printf ("check string: %s\n", addrbuf);
        p_addrlist_out = NULL;
        if (mqc_check_addr(the_msg->prodid, addrbuf, &p_addrlist_out) < 0) {
            sprintf (statbuf, "Failed check addr list '%s'\n", addrbuf);
            free (addrbuf);
            coDDM_destroyMsg(&the_msg);
            throw_submit_exception(env, FAIL_ADDR, statbuf);
            return((*env)->NewStringUTF(env, statbuf));
        }

        if (p_addrlist_out) {
            printf("Addr list: %s\n", p_addrlist_out);
        } else {
            printf("\n");
        }
        free (addrbuf);
        coDDM_destroyMsg(&the_msg);
        return((*env)->NewStringUTF(env, strlen(p_addrlist_out) ? p_addrlist_out : "\n"));
    }

    /* Get the message action code ------------------------------------------------------------------ */
    if (!get_int_field(env, obj, msg_class, "actionCode", &actionCode)) {
        coDDM_destroyMsg(&the_msg);
        strcpy(statbuf, "Could not get actionCode");
        throw_submit_exception(env, FAIL_JNI, statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }

    if (show_trace) printf ("Action Code: %d\n", actionCode);

    if (coDDM_setMsgCode(the_msg, actionCode) < 0) {
        sprintf (statbuf, "Failed setMsgCode '%d'\n", actionCode);
        coDDM_destroyMsg(&the_msg);
        throw_submit_exception(env, FAIL_CODE, statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }

    /* Get the subject string ----------------------------------------------------------------------- */
    if (!get_string_field(env, obj, msg_class, "subject", &subject)) {
        coDDM_destroyMsg(&the_msg);
        strcpy(statbuf, "Could not get subject");
        throw_submit_exception(env, FAIL_JNI, statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }

    if (strlen(subject) > 0) {
        if (show_trace) printf ("Message subject: %s\n", subject);
        if (coDDM_setSubject(the_msg, subject) < 0) {
            sprintf (statbuf, "Failed setSubject '%s'\n", subject);
            coDDM_destroyMsg(&the_msg);
            free(subject);
            throw_submit_exception(env, FAIL_SUBJECT, statbuf);
            return((*env)->NewStringUTF(env, statbuf));
        }
    }
    free(subject);

    /* Get the message priority code ---------------------------------------------------------------- */
    if (!get_priority(env, obj, msg_class, &priority)) {
        coDDM_destroyMsg(&the_msg);
        strcpy(statbuf, "Could not get priority");
        throw_submit_exception(env, FAIL_JNI, statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }

    if (show_trace) printf ("Priority: %d\n", priority);

    if (coDDM_setPriority(the_msg, priority) < 0) {
        sprintf (statbuf, "Failed setPriority '%d'\n", priority);
        coDDM_destroyMsg(&the_msg);
        throw_submit_exception(env, FAIL_PRIORITY, statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }

    /* Get the body file name ----------------------------------------------------------------------- */
    if (!get_string_field(env, obj, msg_class, "bodyFile", &body_file)) {
        coDDM_destroyMsg(&the_msg);
        strcpy(statbuf, "Could not get bodyFile");
        throw_submit_exception(env, FAIL_JNI, statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }

    if (strlen(body_file) > 0) {
        if (show_trace) printf ("Message body file name: %s\n", body_file);
        if (buffer_file((char *) body_file, &bodybuf, &bodybufsiz) < 0) {
            free(bodybuf);
            free(body_file);
            coDDM_destroyMsg(&the_msg);
            throw_submit_exception(env, FAIL_BODY, statbuf);
            return((*env)->NewStringUTF(env, statbuf));
        }
        if (show_trace) printf ("Message body: %s", bodybuf);

        if (coDDM_setMsgBody(the_msg, bodybuf, bodybufsiz) < 0) {
            sprintf (statbuf, "Failed setMsgBody '%s'\n", body_file);
            free(bodybuf);
            free(body_file);
            coDDM_destroyMsg(&the_msg);
            throw_submit_exception(env, FAIL_BODY, statbuf);
            return((*env)->NewStringUTF(env, statbuf));
        }
        free(bodybuf);
    }

    free(body_file);

    /* Set the Enclosure list ----------------------------------------------------------------------- */
    if (!set_enclosures(the_msg, env, obj, msg_class)) {
        coDDM_destroyMsg(&the_msg);
        return((*env)->NewStringUTF(env, statbuf));
    }

    if (show_trace) {
        Enclosure   encl;
        for (encl = encListGetFirstItem(the_msg->enc_list); encl; encl = encListGetNextItem(the_msg->enc_list)) {
            printf ("Enclosure file from msg object: %s\n", encl->filename);
        }
    }

    /* Get the valid time string -------------------------------------------------------------------- */
    if (!get_string_field(env, obj, msg_class, "validTimeString", &valid_time)) {
        coDDM_destroyMsg(&the_msg);
        strcpy(statbuf, "Could not get validTimeString");
        throw_submit_exception(env, FAIL_JNI, statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }

    if (strlen(valid_time) > 0) {
        if (show_trace) printf ("Valid Time String: %s\n", valid_time);
        valid_time_long = hhmmToUtime((char *) valid_time);
        if (coDDM_setValidTime(the_msg, valid_time_long) < 0) {
            sprintf (statbuf, "Failed setValidTime: %s", ctime((const time_t *)&valid_time_long));
            coDDM_destroyMsg(&the_msg);
            free(valid_time);
            throw_submit_exception(env, FAIL_VALID_TIME, statbuf);
            return((*env)->NewStringUTF(env, statbuf));
        }
    }

    free(valid_time);

    /* Get the timeout time string ------------------------------------------------------------------ */
    if (!get_string_field(env, obj, msg_class, "timeoutTimeString", &timeout_time)) {
        coDDM_destroyMsg(&the_msg);
        strcpy(statbuf, "Could not get timeoutTimeString");
        throw_submit_exception(env, FAIL_JNI, statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }

    if (strlen(timeout_time) > 0) {
        if (show_trace) printf ("Time Out String: %s\n", timeout_time);
        timeout_time_long = hhmmToUtime((char *) timeout_time);
        if (coDDM_setTimeoutTime(the_msg, timeout_time_long) < 0) {
            sprintf (statbuf, "Failed setTimeoutTime: %s", ctime((const time_t *)&timeout_time_long));
            coDDM_destroyMsg(&the_msg);
            free(timeout_time);
            throw_submit_exception(env, FAIL_TIMEOUT_TIME, statbuf);
            return((*env)->NewStringUTF(env, statbuf));
        }
    }

    free(timeout_time);

    /* Get the retry count -------------------------------------------------------------------------- */
    if (!get_int_field(env, obj, msg_class, "retryCount", &retry_count)) {
        coDDM_destroyMsg(&the_msg);
        strcpy(statbuf, "Could not get retryCount");
        throw_submit_exception(env, FAIL_JNI, statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }

    if (retry_count > 0) {
        if (show_trace) printf ("Retry count = %d\n", retry_count);
        if (coDDM_setRetryCount(the_msg, retry_count) < 0) {
            sprintf (statbuf, "Failed setRetryCount '%d'\n", retry_count);
            coDDM_destroyMsg(&the_msg);
            throw_submit_exception(env, FAIL_RETRY_COUNT, statbuf);
            return((*env)->NewStringUTF(env, statbuf));
        }
    }

    /* Get user ID string --------------------------------------------------------------------------- */
    if (!get_string_field(env, obj, msg_class, "userId", &user_id)) {
        coDDM_destroyMsg(&the_msg);
        strcpy(statbuf, "Could not get userId");
        throw_submit_exception(env, FAIL_JNI, statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }

    if (strlen(user_id) > 0) {
        if (show_trace) printf ("User ID: %s\n", user_id);
        if (coDDM_setUserID(the_msg, (char *) user_id) < 0) {
            sprintf (statbuf, "Failed setUserID '%s'\n", user_id);
            coDDM_destroyMsg(&the_msg);
            free(user_id);
            throw_submit_exception(env, FAIL_USER_ID, statbuf);
            return((*env)->NewStringUTF(env, statbuf));
        }
    }

    free(user_id);

    /* Submit the message  -------------------------------------------------------------------------- */
    if (coDDM_submitMsg(the_msg) < 0) {
        sprintf (statbuf, "Failed submitMsg\n");
        coDDM_destroyMsg(&the_msg);
        throw_submit_exception(env, FAIL_SUBMIT, statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }

    if ((msg_id = coDDM_getMsgID(the_msg))) {
        if (show_trace) printf ("Message successfully submitted.  Message ID: %s\n", msg_id);
        jmsg_id = (*env)->NewStringUTF(env, msg_id);
        coDDM_destroyMsg(&the_msg);
        return(jmsg_id);
    } else {
        sprintf (statbuf, "Failed getMsgID\n");
        coDDM_destroyMsg(&the_msg);
        throw_submit_exception(env, FAIL_MSGID, statbuf);
        return((*env)->NewStringUTF(env, statbuf));
    }
}