コード例 #1
0
ファイル: sockdev.c プロジェクト: pfg504/hercules-plus
int unix_socket (char* path)
{
#if !defined( HAVE_SYS_UN_H )
    UNREFERENCED(path);
    WRMSG (HHC01032, "E");
    return -1;
#else // defined( HAVE_SYS_UN_H )

    struct sockaddr_un addr;
    int sd;

    logdebug ("unix_socket(%s)\n", path);

    if (strlen (path) > sizeof(addr.sun_path) - 1)
    {
        WRMSG (HHC01033, "E", path, (int) sizeof(addr.sun_path) - 1);
        return -1;
    }

    addr.sun_family = AF_UNIX;
    strlcpy( addr.sun_path, path,sizeof(addr.sun_path) ); /* guaranteed room by above check */
    sd = socket (PF_UNIX, SOCK_STREAM, 0);

    if (sd == -1)
    {
        WRMSG (HHC01034, "E", "socket()", strerror(HSO_errno));
        return -1;
    }

    unlink (path);
    fchmod (sd, 0700);

    if (0
            || bind (sd, (struct sockaddr*) &addr, sizeof(addr)) == -1
            || listen (sd, 0) == -1
       )
    {
        WRMSG (HHC01034, "E", "bind()", strerror(HSO_errno));
        return -1;
    }

    return sd;

#endif // !defined( HAVE_SYS_UN_H )
}
コード例 #2
0
ファイル: mpc.c プロジェクト: rahimazizarab/sand-dyn75
/* the first MPC_PUS of the required type will ever be returned.      */
DLL_EXPORT MPC_PUS*  mpc_point_pus( DEVBLK* pDEVBLK, MPC_PUK* pMPC_PUK, BYTE bType )
{
    MPC_PUS*   pMPC_PUS;
    int        iTotLenPUS;
    U16        uTotLenPUS;
    U16        uLenPUS;
    U16        uLenPUK;

    UNREFERENCED( pDEVBLK );

    /* Get the length of the MPC_PUK, the total length of the */
    /* following MPC_PUSs, then point to the first MPC_PUS.   */
    FETCH_HW( uLenPUK, pMPC_PUK->length );
    FETCH_HW( uTotLenPUS, pMPC_PUK->lenpus );
    iTotLenPUS = uTotLenPUS;
    pMPC_PUS = (MPC_PUS*)((BYTE*)pMPC_PUK + uLenPUK);

    /* Find the required MPC_PUS. */
    while( iTotLenPUS > 0 )
    {
        /* Ensure there are at least the first 4-bytes of an MPC_PUS. */
        if( iTotLenPUS < 4 )
            return NULL;

        /* Get the length of the MPC_PUS. */
        FETCH_HW( uLenPUS, pMPC_PUS->length );
        if( uLenPUS == 0 )                  /* Better safe than sorry */
            return NULL;

        /* Ensure there is the whole of the MPC_PUS. */
        if( iTotLenPUS < uLenPUS )
            return NULL;

        /* Check for the required MPC_PUS. */
        if( pMPC_PUS->type == bType )
            return pMPC_PUS;

        /* Point to the next MPC_PUS. */
        pMPC_PUS = (MPC_PUS*)((BYTE*)pMPC_PUS + uLenPUS);
        iTotLenPUS -= uLenPUS;
    }

    return NULL;
}   /* End function  mpc_point_pus() */
コード例 #3
0
ファイル: clientcert.c プロジェクト: jamezp/wildfly-openssl
WF_OPENSSL(void, setSSLVerify)(JNIEnv *e, jobject o, jlong ssl, jint level, jint depth)
{
#pragma comment(linker, "/EXPORT:"__FUNCTION__"="__FUNCDNAME__)
    tcn_ssl_ctxt_t *c;
    int verify;
    SSL *ssl_ = J2P(ssl, SSL *);

    if (ssl_ == NULL) {
        throwIllegalStateException(e, "ssl is null");
        return;
    }

    c = SSL_get_app_data2(ssl_);

    verify = SSL_VERIFY_NONE;

    UNREFERENCED(o);
    c->verify_mode = level;

    if (c->verify_mode == SSL_CVERIFY_UNSET)
        c->verify_mode = SSL_CVERIFY_NONE;
    if (depth > 0)
        c->verify_depth = depth;
    /*
     *  Configure callbacks for SSL context
     */
    if (c->verify_mode == SSL_CVERIFY_REQUIRE)
        verify |= SSL_VERIFY_PEER_STRICT;
    if ((c->verify_mode == SSL_CVERIFY_OPTIONAL) ||
        (c->verify_mode == SSL_CVERIFY_OPTIONAL_NO_CA))
        verify |= SSL_VERIFY_PEER;
    if (!c->store) {
        if (ssl_methods.SSL_CTX_set_default_verify_paths(c->ctx)) {
            c->store = ssl_methods.SSL_CTX_get_cert_store(c->ctx);
            crypto_methods.X509_STORE_set_flags(c->store, 0);
        }
        else {
            /* XXX: See if this is fatal */
        }
    }

    ssl_methods.SSL_set_verify(ssl_, verify, SSL_callback_SSL_verify);
}
コード例 #4
0
ファイル: puser.c プロジェクト: chunhualiu/OpenNT
APIERR MNetUserModalsSet(
	const TCHAR FAR	 * pszServer,
	UINT		   Level,
	BYTE FAR	 * pbBuffer,
	UINT		   cbBuffer,
	UINT		   ParmNum )
{
    UNREFERENCED( cbBuffer );

    if( ParmNum != PARMNUM_ALL )
    {
    	return ERROR_NOT_SUPPORTED;
    }

    return (APIERR)NetUserModalsSet( (TCHAR *)pszServer,
				     Level,
				     pbBuffer,
				     NULL );
}   // MNetUserModalsSet
コード例 #5
0
/* Called by the JVM when APR_JAVA is loaded */
JNIEXPORT jint JNICALL JNI_OnLoad_netty_tcnative(JavaVM *vm, void *reserved) 
{
    JNIEnv *env;
    apr_version_t apv;
    int apvn;

    UNREFERENCED(reserved);
    if ((*vm)->GetEnv(vm, (void **)&env, TCN_JNI_VERSION)) {
        return JNI_ERR;
    }
    tcn_global_vm = vm;

    /* Before doing anything else check if we have a valid
     * APR version.
     */
    apr_version(&apv);
    apvn = apv.major * 1000 + apv.minor * 100 + apv.patch;
    if (apvn < 1201) {
        tcn_Throw(env, "Unupported APR version (%s)",
                  apr_version_string());
        return JNI_ERR;
    }


    /* Initialize global java.lang.String class */
    TCN_LOAD_CLASS(env, jString_class, "java/lang/String", JNI_ERR);

    TCN_GET_METHOD(env, jString_class, jString_init,
                   "<init>", "([B)V", JNI_ERR);
    TCN_GET_METHOD(env, jString_class, jString_getBytes,
                   "getBytes", "()[B", JNI_ERR);

    TCN_LOAD_CLASS(env, byteArrayClass, "[B", JNI_ERR);
    TCN_LOAD_CLASS(env, keyMaterialClass, "io/netty/tcnative/jni/CertificateRequestedCallback$KeyMaterial", JNI_ERR);

    TCN_GET_FIELD(env, keyMaterialClass, keyMaterialCertificateChainFieldId,
                   "certificateChain", "J", JNI_ERR);
    TCN_GET_FIELD(env, keyMaterialClass, keyMaterialPrivateKeyFieldId,
                   "privateKey", "J", JNI_ERR);

    return TCN_JNI_VERSION;
}
コード例 #6
0
ファイル: impl.c プロジェクト: blackpit73/hyperion
/*-------------------------------------------------------------------*/
static void delayed_exit (int exit_code)
{
    UNREFERENCED(exit_code);

    /* Delay exiting is to give the system
     * time to display the error message. */
#if defined( _MSVC_ )
    SetConsoleCtrlHandler( NULL, FALSE); // disable Ctrl-C intercept
#endif
    sysblk.shutimmed = TRUE;

    fflush(stderr);
    fflush(stdout);
    usleep(100000);
    do_shutdown();
    fflush(stderr);
    fflush(stdout);
    usleep(100000);
    return;
}
コード例 #7
0
ファイル: mpc.c プロジェクト: rahimazizarab/sand-dyn75
/*--------------------------------------------------------------------*/
DLL_EXPORT MPC_PUK*  mpc_point_puk( DEVBLK* pDEVBLK, MPC_TH* pMPC_TH, MPC_RRH* pMPC_RRH )
{
    MPC_PH*    pMPC_PH;
    MPC_PUK*   pMPC_PUK;
    U32        uOffData;
    U16        uOffPH;

    UNREFERENCED( pDEVBLK );

    // Point to the MPC_PH.
    FETCH_HW( uOffPH, pMPC_RRH->offph );
    pMPC_PH = (MPC_PH*)((BYTE*)pMPC_RRH + uOffPH);

    // Get the length of and point to the data referenced by the
    // MPC_PH. The data contain a MPC_PUK and one or more MPC_PUSs.
    FETCH_FW( uOffData, pMPC_PH->offdata );
    pMPC_PUK = (MPC_PUK*)((BYTE*)pMPC_TH + uOffData);

    return pMPC_PUK;
}   /* End function  mpc_point_puk() */
コード例 #8
0
ファイル: dasdcopy.c プロジェクト: Orfheo/hyperion
/*-------------------------------------------------------------------*/
void status (int i, int n)
{
#ifdef EXTERNALGUI
    if (extgui)
    {
        UNREFERENCED( n );
        if (i % 100)
            return;
        EXTGUIMSG( "TRK=%d\n", i );
        return;
    }
    else
#endif /*EXTERNALGUI*/
    {
        static char indic[] = "|/-\\";
//      if (i % 101 != 1)
//          return;
        printf ("\r%c %3d%% %7d", indic[i%4], (int)((i*100.0)/n), i);
    }
} /* end function status */
コード例 #9
0
/*-------------------------------------------------------------------*/
void ARCH_DEP(diag224_call) (int r1, int r2, REGS *regs)
{
RADR              abs;                 /* abs addr of data area      */
BYTE             *p;                   /* pointer to the data area   */
unsigned int      i;                   /* loop index                 */

//FIXME : this is probably incomplete.
//        see linux/arch/s390/hypfs/hypfs_diag.c
    UNREFERENCED(r1);

    abs = APPLY_PREFIXING (regs->GR_L(r2), regs->PX);

    /* Program check if data area is not on a page boundary */
    if ( (abs & PAGEFRAME_BYTEMASK) != 0x000)
        ARCH_DEP(program_interrupt) (regs, PGM_SPECIFICATION_EXCEPTION);

    /* Program check if data area is outside main storage */
    if ( abs > regs->mainlim )
        ARCH_DEP(program_interrupt) (regs, PGM_ADDRESSING_EXCEPTION);

    /* Point to DIAG 224 data area */
    p = regs->mainstor + abs;

    /* Mark page referenced */
    STORAGE_KEY(abs, regs) |= STORKEY_REF | STORKEY_CHANGE;

    /* First byte contains the number of entries - 1 */
    *p = 5;

    /* Clear the next 15 bytes */
    memset (p + 1, 0, 15);

    /* Set the 6 possible entries */
    p += 16;
    memcpy(p,diag224_cputable,sizeof(diag224_cputable)-1);

    /* Convert to EBCDIC */
    for (i = 0; i < sizeof(diag224_cputable); i++)
        p[i] = host_to_guest(p[i]);

} /* end function diag224_call */
コード例 #10
0
ファイル: extrae_wrapper.c プロジェクト: mogeb/extrae-paraver
JNIEXPORT void JNICALL Java_es_bsc_cepbatools_extrae_Wrapper_nEvent (JNIEnv *env,
	jclass jc, jintArray types, jlongArray values)
{
	jint countTypes = 0;
	jint countValues = 0;

	UNREFERENCED(jc);

	jint *typesArray = (*env)->GetIntArrayElements(env, types, NULL);
	jlong *valuesArray = (*env)->GetLongArrayElements(env, values, NULL);

	if (typesArray != NULL && valuesArray != NULL)
	{
		countTypes = (*env)->GetArrayLength(env, types);
		countValues = (*env)->GetArrayLength(env, values);
		if (countTypes == countValues)
			Extrae_nevent (countTypes, (extrae_type_t *)typesArray, (extrae_value_t *)valuesArray);
		(*env)->ReleaseIntArrayElements(env, types, typesArray, JNI_ABORT);
		(*env)->ReleaseLongArrayElements(env, values, valuesArray, JNI_ABORT);
	}
}
コード例 #11
0
ファイル: coretemp_freebsd.c プロジェクト: naps62/CPD_PAPI
/** Triggered by eventset operations like add or remove */
int coretemp_update_control_state( hwd_control_state_t * ptr,
	NativeInfo_t * native, int count, hwd_context_t * ctx )
{
	int i, index;
	coretemp_control_state_t *c = (coretemp_control_state_t *) ptr;
	UNREFERENCED(ctx);

	SUBDBG("coretemp_update_control_state %p %p...\n", ptr, ctx);

	for (i = 0; i < count; i++)
	{
		index = native[i].ni_event & PAPI_NATIVE_AND_MASK & PAPI_COMPONENT_AND_MASK;
		native[i].ni_position = coretemp_native_table[index].resources.selector - 1;
		c->added[native[i].ni_position] = TRUE;

		SUBDBG ("\nnative[%i].ni_position = coretemp_native_table[%i].resources.selector-1 = %i;\n",
		  i, index, native[i].ni_position );
	}

	return PAPI_OK;
}
コード例 #12
0
/* Callback for bubble help events */
void handleBubbleHelp(Widget w, XtPointer clientData, XEvent *event,
  Boolean *ctd)
{
  /* Avoid compiler warning messages */
    UNREFERENCED(ctd);

  /* Switch depending on type */
    switch (event->type) {
    case EnterNotify:
      /* Manage the bubble help widget*/
	makeBubbleHelpWidget(w,(char *)clientData);
	break;
    case LeaveNotify:
      /* Destroy the bubble help widget*/
	if(bubbleHelpWidget) {
	    XtDestroyWidget(bubbleHelpWidget);
	    bubbleHelpWidget=NULL;
	}
	break;
    }
}
コード例 #13
0
ファイル: pserver.c プロジェクト: chunhualiu/OpenNT
APIERR MNetServerSetInfo(
	const TCHAR FAR	 * pszServer,
	UINT		   Level,
	BYTE FAR	 * pbBuffer,
	UINT		   cbBuffer,
	UINT		   ParmNum )
{
    UNREFERENCED( cbBuffer );

    // mapping layer does not do  this right now, since UI never uses it.
    if( ParmNum != PARMNUM_ALL )	
    {
    	return ERROR_NOT_SUPPORTED;
    }

    return (APIERR)NetServerSetInfo( (TCHAR *)pszServer,
    				     Level,
				     pbBuffer,
				     NULL );

}   // MNetServerSetInfo
コード例 #14
0
ファイル: premote.c プロジェクト: chunhualiu/OpenNT
APIERR MNetRemoteMove(
	const TCHAR FAR	 * pszSourcePath,
	const TCHAR FAR	 * pszDestPath,
	const TCHAR FAR	 * pszSourcePasswd,
	const TCHAR FAR	 * pszDestPasswd,
	UINT		   fOpen,
	UINT		   fCopy,
	BYTE FAR	** ppbBuffer )
{
    UNREFERENCED( pszSourcePath );
    UNREFERENCED( pszDestPath );
    UNREFERENCED( pszSourcePasswd );
    UNREFERENCED( pszDestPasswd );
    UNREFERENCED( fOpen );
    UNREFERENCED( fCopy );
    UNREFERENCED( ppbBuffer );

    return ERROR_NOT_SUPPORTED;	    	// NOT NEEDED FOR LMOBJ

}   // MNetRemoteMove
コード例 #15
0
ファイル: pserver.c プロジェクト: chunhualiu/OpenNT
APIERR MNetServerAdminCommand(
	const TCHAR FAR	 * pszServer,
	const TCHAR FAR	 * pszCommand,
	UINT FAR	 * pResult,
	BYTE FAR	 * pbBuffer,
	UINT		   cbBuffer,
	UINT FAR	 * pcbReturned,
	UINT FAR	 * pcbTotalAvail )
{
    UNREFERENCED( pszServer );
    UNREFERENCED( pszCommand );
    UNREFERENCED( pResult );
    UNREFERENCED( pbBuffer );
    UNREFERENCED( cbBuffer );
    UNREFERENCED( pcbReturned );
    UNREFERENCED( pcbTotalAvail );

    return ERROR_NOT_SUPPORTED;	    	// NOT NEEDED FOR LMOBJ

}   // MNetServerAdminCommand
コード例 #16
0
ファイル: impl.c プロジェクト: blackpit73/hyperion
/*-------------------------------------------------------------------*/
static char *rcname = NULL;             /* hercules.rc name pointer  */
static void* process_rc_file (void* dummy)
{
int     is_default_rc  = 0;             /* 1 == default name used    */
char    pathname[MAX_PATH];             /* (work)                    */

    UNREFERENCED(dummy);

    /* Obtain the name of the hercules.rc file or default */

    if (!rcname)
    {
        if (!(rcname = getenv("HERCULES_RC")))
        {
            rcname = "hercules.rc";
            is_default_rc = 1;
        }
    }

    if(!strcasecmp(rcname,"None"))
        return NULL;

    hostpath(pathname, rcname, sizeof(pathname));

    /* Wait for panel thread to engage */
// ZZ FIXME:THIS NEED TO GO
    while (!sysblk.panel_init)
        usleep( 10 * 1000 );

    /* Run the script processor for this file */

    if (process_script_file(pathname,1) != 0)
        if (ENOENT == errno)
            if (!is_default_rc)
                WRMSG(HHC01405, "E", pathname);
        // (else error message already issued)

    return NULL;
}
コード例 #17
0
ファイル: hconsole.c プロジェクト: 2kranki/spinhawk
int  get_console_dim( FILE* confp, int* rows, int* cols )
{
    char* env;
#if defined(TIOCGWINSZ)
    struct winsize winsize;
#else
    UNREFERENCED( confp );
#endif

    if ( !rows || !cols )
    {
        errno = EINVAL;
        return -1;
    }

#if defined(TIOCGWINSZ)
    if (ioctl(fileno(confp), TIOCGWINSZ, &winsize) >= 0)
    {
        *rows = winsize.ws_row;
        *cols = winsize.ws_col;
    }
    else
#endif
    {
        if (!(env = getenv( "LINES"   ))) *rows = 24;
        else                              *rows = atoi(env);
        if (!(env = getenv( "COLUMNS" ))) *cols = 80;
        else                              *cols = atoi(env);
    }

    if (!*rows || !*cols)
    {
        errno = EIO;
        return -1;
    }

    return 0;
}
コード例 #18
0
ファイル: misc.c プロジェクト: rmaucher/tomcat-openssl
TCN_IMPLEMENT_CALL(jint, OS, random)(TCN_STDARGS, jbyteArray buf,
                                     jint len)
{
#if APR_HAS_RANDOM
    apr_status_t rv;
    jbyte *b = (*e)->GetPrimitiveArrayCritical(e, buf, NULL);

    UNREFERENCED(o);
    if ((rv = apr_generate_random_bytes((unsigned char *)b,
            (apr_size_t)len)) == APR_SUCCESS)
        (*e)->ReleasePrimitiveArrayCritical(e, buf, b, 0);
    else
        (*e)->ReleasePrimitiveArrayCritical(e, buf, b, JNI_ABORT);

    if ((*e)->ExceptionCheck(e)) {
        (*e)->ExceptionClear(e);
        rv = APR_EGENERAL;
    }
    return (jint)rv;
#else
    return APR_ENOTIMPL;
#endif
}
コード例 #19
0
ファイル: system.c プロジェクト: fakechris/TomCatUdp
TCN_IMPLEMENT_CALL(jstring, OS, expand)(TCN_STDARGS, jstring val)
{
    jstring str;
    jchar buf[TCN_BUFFER_SZ] = L"";
    DWORD len;
    TCN_ALLOC_WSTRING(val);

    UNREFERENCED(o);
    TCN_INIT_WSTRING(val);

    len = ExpandEnvironmentStringsW(J2W(val), buf, TCN_BUFFER_SZ - 1);
    if (len > (TCN_BUFFER_SZ - 1)) {
        jchar *dbuf = malloc((len + 1) * 2);
        ExpandEnvironmentStringsW(J2W(val), dbuf, len);
        str = (*e)->NewString(e, dbuf, wcslen(dbuf));
        free(dbuf);
    }
    else
        str = (*e)->NewString(e, buf, wcslen(buf));

    TCN_FREE_WSTRING(val);
    return str;
}
コード例 #20
0
ファイル: system.c プロジェクト: fakechris/TomCatUdp
TCN_IMPLEMENT_CALL(jstring, OS, syserror)(TCN_STDARGS, jint err)
{
    jstring str;
    void *buf;

    UNREFERENCED(o);
    if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
                       FORMAT_MESSAGE_FROM_SYSTEM |
                       FORMAT_MESSAGE_IGNORE_INSERTS,
                       NULL,
                       err,
                       MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                       (LPTSTR)&buf,
                       0,
                       NULL)) {
        str = AJP_TO_JSTRING("Unknown Error");
    }
    else {
        str = AJP_TO_JSTRING((const char *)buf);
        LocalFree(buf);
    }
    return str;
}
コード例 #21
0
ファイル: pstatist.c プロジェクト: chunhualiu/OpenNT
APIERR MNetStatisticsGet(
	const TCHAR FAR	 * pszServer,
	const TCHAR FAR	 * pszService,
	ULONG	 	   ulReserved,
	UINT		   Level,
	ULONG		   flOptions,
	BYTE FAR	** ppbBuffer ) 
{
    UNREFERENCED( pszServer );
    UNREFERENCED( pszService );
    UNREFERENCED( ulReserved );
    UNREFERENCED( Level );
    UNREFERENCED( flOptions );
    UNREFERENCED( ppbBuffer );

    return ERROR_NOT_SUPPORTED;	    	// NOT NEEDED FOR LMOBJ

}   // MNetStatisticsGet
コード例 #22
0
ファイル: pchar.c プロジェクト: chunhualiu/OpenNT
APIERR MNetCharDevQSetInfo(
	const TCHAR FAR	 * pszServer,
	const TCHAR FAR	 * pszQueueName,
	UINT		   Level,
	BYTE FAR	 * pbBuffer,
	UINT		   cbBuffer,
	UINT		   ParmNum ) 
{
    UNREFERENCED( pszServer );
    UNREFERENCED( pszQueueName );
    UNREFERENCED( Level );
    UNREFERENCED( pbBuffer );
    UNREFERENCED( cbBuffer );
    UNREFERENCED( ParmNum );

    return ERROR_NOT_SUPPORTED;	    	// NOT NEEDED FOR LMOBJ

}   // MNetCharDevQSetInfo
コード例 #23
0
size_t debug_port_write_chars(lref_t port, const _TCHAR *buf, size_t count)
{
     UNREFERENCED(port);
     assert(PORTP(port));

     _TCHAR block[DEBUG_PORT_BLOCK_SIZE + 1];

     size_t buf_loc = 0;
     size_t block_loc = 0;

     size_t len = count;

     /* Filter nulls out of the input string, and ensure that the
      * buffer we pass to OutputDebugString has as terminating
      * null. */
     while (len > 0)
     {
          for (block_loc = 0;
               (block_loc < DEBUG_PORT_BLOCK_SIZE) && (len > 0); block_loc++, buf_loc++, len--)
          {
               if (buf[buf_loc] == '\0')
                    block[block_loc] = '~';
               else
                    block[block_loc] = buf[buf_loc];
          }

          block[block_loc] = '\0';

          if (DEBUG_FLAG(DF_DEBUGGER_TO_ODS))
               sys_output_debug_string(block);
          else
               fputs(block, stderr);
     }

     return len;
}
コード例 #24
0
ファイル: extrae_wrapper.c プロジェクト: mogeb/extrae-paraver
JNIEXPORT void JNICALL Java_es_bsc_cepbatools_extrae_Wrapper_defineEventType
	(JNIEnv *env, jclass jc, jint type, jstring description,
	jlongArray values, jobjectArray descriptionValues)
{
	char *cDescr;
	jint countValues, countDescriptionValues;

	UNREFERENCED(jc);

	if (values != NULL)
		countValues = (*env)->GetArrayLength(env, values);
	else
		countValues = 0;

	if (descriptionValues != NULL)
		countDescriptionValues = (*env)->GetArrayLength(env, descriptionValues);
	else
		countDescriptionValues = 0;

	cDescr = (char*)(*env)->GetStringUTFChars(env, description, NULL);
	if (cDescr != NULL)
	{
		if (countValues == countDescriptionValues && countValues > 0)
		{
			jlong *valuesArray = NULL;
			char *valDesc[countValues];

			valuesArray = (*env)->GetLongArrayElements(env, values, NULL);
			if (valuesArray != NULL)
			{
				jlong i;
				for (i = 0; i < countValues; i++)
				{
					valDesc[i] = (char*)(*env)->GetStringUTFChars(env,
					  (*env)->GetObjectArrayElement(env, descriptionValues, i),
					  NULL);
					if (valDesc[i] == NULL)
						return;
				}
				Extrae_define_event_type ((extrae_type_t *)&type, cDescr,
				  (unsigned *) &countValues, (extrae_value_t *)valuesArray,
			 	 valDesc);

				(*env)->ReleaseLongArrayElements(env, values, valuesArray,
				  JNI_ABORT);
				for (i = 0; i < countValues; i++)
				{
					jstring elem = (jstring)(*env)->GetObjectArrayElement (env,
					  descriptionValues, i);
					(*env)->ReleaseStringUTFChars(env, elem, valDesc[i]);
				}
			}
		}
		else
		{
			unsigned zero = 0;
			Extrae_define_event_type ((extrae_type_t*)&type, cDescr, &zero,
			  NULL, NULL);
		}
		(*env)->ReleaseStringUTFChars(env, description, cDescr);
	}
}
コード例 #25
0
ファイル: hao.c プロジェクト: 2kranki/hercules-390
/*---------------------------------------------------------------------------*/
static void* hao_thread(void* dummy)
{
  char*  msgbuf  = NULL;
  int    msgidx  = -1;
  int    msgamt  = 0;
  char*  msgend  = NULL;
  char   svchar  = 0;
  int    bufamt  = 0;

  UNREFERENCED(dummy);

  /* Do not start HAO if no logger is active 
   * the next hao command will restart the thread
   */
  if(!logger_status())
  {
    haotid = 0;
    return NULL;
  }

  WRMSG(HHC00100, "I", (u_long)thread_id(), getpriority(PRIO_PROCESS,0), "Hercules Automatic Operator");

  /* Wait for panel thread to engage */
  /* Do until shutdown */
  while(!sysblk.shutdown && msgamt >= 0)
  {
    /* wait for message data */
    msgamt = log_read(&msgbuf, &msgidx, LOG_BLOCK);
    if(msgamt > 0)
    {
      /* append to existing data */
      if(msgamt > (int)((sizeof(ao_msgbuf) - 1) - bufamt))
        msgamt = (int)((sizeof(ao_msgbuf) - 1) - bufamt);
      strncpy( &ao_msgbuf[bufamt], msgbuf, msgamt );
      ao_msgbuf[bufamt += msgamt] = 0;
      msgbuf = ao_msgbuf;

      /* process only complete messages */
      msgend = strchr(msgbuf,'\n');
      while(msgend)
      {
        /* null terminate message */
        svchar = *(msgend+1);
        *(msgend+1) = 0;

        /* process message */
        hao_message(msgbuf);

        /* restore destroyed byte */
        *(msgend+1) = svchar;
        msgbuf = msgend+1;
        msgend = strchr(msgbuf,'\n');
      }

      /* shift message buffer */
      memmove( ao_msgbuf, msgbuf, bufamt -= (msgbuf - ao_msgbuf) );
    }
  }

  WRMSG(HHC00101, "I", (u_long)thread_id(), getpriority(PRIO_PROCESS,0), "Hercules Automatic Operator");
  return NULL;
}
コード例 #26
0
/*-------------------------------------------------------------------*/
int decomptrk(
              BYTE *ibuf,         /* input buffer address            */
              int ibuflen,        /* input buffer length             */
              BYTE *obuf,         /* output buffer address           */
              int obuflen,        /* output buffer length            */
              int heads,          /* >=0 means CKD, else FBA         */
              int trk,            /* relative track or block number  */
              char *msg           /* addr of 80 byte msg buf or NULL */
             )
/* ibuf points at CKDDASD_TRKHDR header followed by track data       */
/* ibuflen specifies length of TRKHDR and data                       */
/* This code based on decompression logic in cdsk_valid_trk.         */
/* Returns length of decompressed data or -1 on error.               */
{
#if defined( HAVE_LIBZ ) || defined( CCKD_BZIP2 )
int             rc;                     /* Return code               */
#endif
unsigned int    bufl;                   /* Buffer length             */
#ifdef CCKD_BZIP2
unsigned int    ubufl;                  /* when size_t != unsigned int */
#endif

#if !defined( HAVE_LIBZ ) && !defined( CCKD_BZIP2 )
    UNREFERENCED(heads);
    UNREFERENCED(trk);
    UNREFERENCED(msg);
#endif

    memset(obuf, 0, obuflen);  /* clear output buffer             */

    /* Uncompress the track/block image */
    switch (ibuf[0] & CCKD_COMPRESS_MASK) {

    case CCKD_COMPRESS_NONE:
        bufl = (ibuflen < obuflen) ? ibuflen : obuflen;
        memcpy (obuf, ibuf, bufl);
        break;

#ifdef HAVE_LIBZ
    case CCKD_COMPRESS_ZLIB:
        memcpy (obuf, ibuf, CKDDASD_TRKHDR_SIZE);
        bufl = obuflen - CKDDASD_TRKHDR_SIZE;
        rc = uncompress(&obuf[CKDDASD_TRKHDR_SIZE],
                         (void *)&bufl,
                         &ibuf[CKDDASD_TRKHDR_SIZE],
                         ibuflen);
        if (rc != Z_OK) {
            if (msg)
                MSGBUF(msg, "%s %d uncompress error, rc=%d;"
                         "%2.2x%2.2x%2.2x%2.2x%2.2x",
                         heads >= 0 ? "trk" : "blk", trk, rc,
                         ibuf[0], ibuf[1], ibuf[2], ibuf[3], ibuf[4]);
            return -1;
        }
        bufl += CKDDASD_TRKHDR_SIZE;
        break;
#endif

#ifdef CCKD_BZIP2
    case CCKD_COMPRESS_BZIP2:
        memcpy(obuf, ibuf, CKDDASD_TRKHDR_SIZE);
        ubufl = obuflen - CKDDASD_TRKHDR_SIZE;
        rc = BZ2_bzBuffToBuffDecompress (
                 (char *)&obuf[CKDDASD_TRKHDR_SIZE],
                 &ubufl,
                 (char *)&ibuf[CKDDASD_TRKHDR_SIZE],
                 ibuflen, 0, 0);
        if (rc != BZ_OK) {
            if (msg)
                MSGBUF(msg, "%s %d decompress error, rc=%d;"
                         "%2.2x%2.2x%2.2x%2.2x%2.2x",
                         heads >= 0 ? "trk" : "blk", trk, rc,
                         ibuf[0], ibuf[1], ibuf[2], ibuf[3], ibuf[4]);
            return -1;
        }
        bufl=ubufl;
        bufl += CKDDASD_TRKHDR_SIZE;
        break;
#endif

    default:
        return -1;

    } /* switch (buf[0] & CCKD_COMPRESS_MASK) */
    return bufl;
}
コード例 #27
0
ファイル: httpserv.c プロジェクト: rmblair/h390-sandhawk
void *http_server (void *arg)
{
int                 rc;                 /* Return code               */
int                 lsock;              /* Socket for listening      */
int                 csock;              /* Socket for conversation   */
struct sockaddr_in  server;             /* Server address structure  */
fd_set              selset;             /* Read bit map for select   */
int                 optval;             /* Argument for setsockopt   */
TID                 httptid;            /* Negotiation thread id     */
struct timeval      timeout;            /* timeout value             */


    UNREFERENCED(arg);

    http_serv.httpshutdown = TRUE;

    hdl_adsc("http_shutdown",http_shutdown, NULL);

    /* Set root mode in order to set priority */
    SETMODE(ROOT);

    /* Set server thread priority; ignore any errors */
    if(setpriority(PRIO_PROCESS, 0, sysblk.srvprio))
       WRMSG(HHC00136, "W", "setpriority()", strerror(errno));

    /* Back to user mode */
    SETMODE(USER);

    /* Display thread started message on control panel */
    WRMSG (HHC00100, "I", (u_long)thread_id(), getpriority(PRIO_PROCESS,0), "HTTP server");

    /* make sure root path is built */
    if ( http_root() == NULL )
        goto http_server_stop;

    /* Obtain a socket */
    lsock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);

    if (lsock < 0)
    {
        WRMSG(HHC01800,"E", "socket()", strerror(HSO_errno));
        goto http_server_stop;
    }

    /* Allow previous instance of socket to be reused */
    optval = 1;
    setsockopt (lsock, SOL_SOCKET, SO_REUSEADDR,
                (void*)&optval, sizeof(optval));

    /* Prepare the sockaddr structure for the bind */
    memset (&server, 0, sizeof(server));
    server.sin_family = AF_INET;
    server.sin_addr.s_addr = INADDR_ANY;
    server.sin_port = http_serv.httpport;
    server.sin_port = htons(server.sin_port);

    http_serv.httpbinddone = FALSE;
    /* Attempt to bind the socket to the port */
    while (TRUE)
    {
        rc = bind (lsock, (struct sockaddr *)&server, sizeof(server));

        if (rc == 0 || HSO_errno != HSO_EADDRINUSE) break;

        WRMSG(HHC01804, "W", http_serv.httpport);
        SLEEP(10);
    } /* end while */

    if (rc != 0)
    {
        WRMSG(HHC01800,"E", "bind()", strerror(HSO_errno));
        goto http_server_stop;
    }
    else
        http_serv.httpbinddone = TRUE;

    /* Put the socket into listening state */
    rc = listen (lsock, 32);

    if (rc < 0)
    {
        WRMSG(HHC01800,"E", "listen()", strerror(HSO_errno));
        http_serv.httpbinddone = FALSE;
        goto http_server_stop;
    }

    http_serv.httpshutdown = FALSE;

    WRMSG(HHC01803, "I", http_serv.httpport);

    /* Handle http requests */
    while ( !http_serv.httpshutdown )
    {

        /* Initialize the select parameters */
        FD_ZERO (&selset);
        FD_SET (lsock, &selset);

        timeout.tv_sec  = 0;
        timeout.tv_usec = 10000;

        /* until a better way to implement this use standard windows */
#undef select
        /* Wait for a file descriptor to become ready  use NON-BLOCKING select()*/
        rc = select ( lsock+1, &selset, NULL, NULL, &timeout );

        if ( rc == 0 || http_serv.httpshutdown ) continue;

        if (rc < 0 )
        {
            if (HSO_errno == HSO_EINTR) continue;
            WRMSG(HHC01800, "E", "select()", strerror(HSO_errno));
            break;
        }

        /* If a http request has arrived then accept it */
        if (FD_ISSET(lsock, &selset))
        {
            /* Accept the connection and create conversation socket */
            csock = accept (lsock, NULL, NULL);

            if (csock < 0)
            {
                WRMSG(HHC01800, "E", "accept()", strerror(HSO_errno));
                continue;
            }

            /* Create a thread to execute the http request */
            rc = create_thread (&httptid, DETACHED,
                                http_request, (void *)(uintptr_t)csock,
                                "http_request");
            if(rc)
            {
                WRMSG(HHC00102, "E", strerror(rc));
                close_socket (csock);
            }

        } /* end if(lsock) */

    } /* end while */

    /* Close the listening socket */
    close_socket (lsock);

http_server_stop:
    if ( !sysblk.shutdown )
        hdl_rmsc(http_shutdown, NULL);

    /* Display thread started message on control panel */
    WRMSG(HHC00101, "I", (u_long)thread_id(), getpriority(PRIO_PROCESS,0), "HTTP server");

    sysblk.httptid = 0;

    http_serv.httpbinddone = FALSE;

    signal_condition(&http_serv.http_wait_shutdown);

    return NULL;

} /* end function http_server */
コード例 #28
0
ファイル: system.c プロジェクト: fakechris/TomCatUdp
TCN_IMPLEMENT_CALL(jint, OS, info)(TCN_STDARGS,
                                   jlongArray inf)
{
    jint rv;
    int  i;
    jsize ilen = (*e)->GetArrayLength(e, inf);
    jlong *pvals = (*e)->GetLongArrayElements(e, inf, NULL);

    UNREFERENCED(o);
    if (ilen < 16) {
        return APR_EINVAL;
    }
    for (i = 0; i < 16; i++)
        pvals[i] = 0;
#if defined(__linux__)
    {
        struct sysinfo info;
        if (sysinfo(&info))
            rv = apr_get_os_error();
        else {
            pvals[0] = (jlong)(info.totalram  * info.mem_unit);
            pvals[1] = (jlong)(info.freeram   * info.mem_unit);
            pvals[2] = (jlong)(info.totalswap * info.mem_unit);
            pvals[3] = (jlong)(info.freeswap  * info.mem_unit);
            pvals[4] = (jlong)(info.sharedram * info.mem_unit);
            pvals[5] = (jlong)(info.bufferram * info.mem_unit);
            pvals[6] = (jlong)(100 - (info.freeram * 100 / info.totalram));
            rv = APR_SUCCESS;
        }
    }
#elif defined(sun)
    {
        /* static variables with basic procfs info */
        static long creation = 0;              /* unix timestamp of process creation */
        static int psinf_fd = 0;               /* file descriptor for the psinfo procfs file */
        static int prusg_fd = 0;               /* file descriptor for the usage procfs file */
        static size_t rss = 0;                 /* maximum of resident set size from previous calls */
        /* static variables with basic kstat info */
        static kstat_ctl_t *kstat_ctl = NULL;  /* kstat control object, only initialized once */
        static kstat_t *kstat_cpu[MAX_CPUS];   /* array of kstat objects for per cpu statistics */
        static int cpu_count = 0;              /* number of cpu structures found in kstat */
        static kid_t kid = 0;                  /* kstat ID, for which the kstat_ctl holds the correct chain */
        /* non-static variables - general use */
        int res = 0;                           /* general result state */
        /* non-static variables - sysinfo/swapctl use */
        long ret_sysconf;                      /* value returned from sysconf call */
        long tck_dividend;                     /* factor used by transforming tick numbers to milliseconds */
        long tck_divisor;                      /* divisor used by transforming tick numbers to milliseconds */
        long sys_pagesize = sysconf(_SC_PAGESIZE); /* size of a system memory page in bytes */
        long sys_clk_tck = sysconf(_SC_CLK_TCK); /* number of system ticks per second */
        struct anoninfo info;                  /* structure for information about sizes in anonymous memory system */
        /* non-static variables - procfs use */
        psinfo_t psinf;                        /* psinfo structure from procfs */
        prusage_t prusg;                       /* usage structure from procfs */
        size_t new_rss = 0;                    /* resident set size read from procfs */
        time_t now;                            /* time needed for calculating process creation time */
        /* non-static variables - kstat use */
        kstat_t *kstat = NULL;                 /* kstat working pointer */
        cpu_sysinfo_t cpu;                     /* cpu sysinfo working pointer */
        kid_t new_kid = 0;                     /* kstat ID returned from chain update */
        int new_kstat = 0;                     /* flag indicating, if kstat structure has changed since last call */

        rv = APR_SUCCESS;

        if (sys_pagesize <= 0) {
            rv = apr_get_os_error();
        }
        else {
            ret_sysconf = sysconf(_SC_PHYS_PAGES);
            if (ret_sysconf >= 0) {
                pvals[0] = (jlong)((jlong)sys_pagesize * ret_sysconf);
            }
            else {
                rv = apr_get_os_error();
            }
            ret_sysconf = sysconf(_SC_AVPHYS_PAGES);
            if (ret_sysconf >= 0) {
                pvals[1] = (jlong)((jlong)sys_pagesize * ret_sysconf);
            }
            else {
                rv = apr_get_os_error();
            }
            res=swapctl(SC_AINFO, &info);
            if (res >= 0) {
                pvals[2] = (jlong)((jlong)sys_pagesize * info.ani_max);
                pvals[3] = (jlong)((jlong)sys_pagesize * info.ani_free);
                pvals[6] = (jlong)(100 - (jlong)info.ani_free * 100 / info.ani_max);
            }
            else {
                rv = apr_get_os_error();
            }
        }

        if (psinf_fd == 0) {
            psinf_fd = proc_open("psinfo");
        }
        res = proc_read(&psinf, PSINFO_T_SZ, psinf_fd);
        if (res >= 0) {
            new_rss = psinf.pr_rssize*1024;
            pvals[13] = (jlong)(new_rss);
            if (new_rss > rss) {
                rss = new_rss;
            }
            pvals[14] = (jlong)(rss);
        }
        else {
            psinf_fd = 0;
            rv = apr_get_os_error();
        }
        if (prusg_fd == 0) {
            prusg_fd = proc_open("usage");
        }
        res = proc_read(&prusg, PRUSAGE_T_SZ, prusg_fd);
        if (res >= 0) {
            if (creation <= 0) {
                time(&now);
                creation = (long)(now - (prusg.pr_tstamp.tv_sec -
                                         prusg.pr_create.tv_sec));
            }
            pvals[10] = (jlong)(creation);
            pvals[11] = (jlong)((jlong)prusg.pr_stime.tv_sec * 1000 +
                                (prusg.pr_stime.tv_nsec / 1000000));
            pvals[12] = (jlong)((jlong)prusg.pr_utime.tv_sec * 1000 +
                                (prusg.pr_utime.tv_nsec / 1000000));
            pvals[15] = (jlong)(prusg.pr_majf);
        }
        else {
            prusg_fd = 0;
            rv = apr_get_os_error();
        }

        if (sys_clk_tck <= 0) {
            rv = apr_get_os_error();
        }
        else {
            tck_dividend = 1000;
            tck_divisor = sys_clk_tck;
            for (i = 0; i < 3; i++) {
                if (tck_divisor % 2 == 0) {
                    tck_divisor = tck_divisor / 2;
                    tck_dividend = tck_dividend / 2;
                }
                if (tck_divisor % 5 == 0) {
                    tck_divisor = tck_divisor / 5;
                    tck_dividend = tck_dividend / 5;
                }
            }
            if (kstat_ctl == NULL) {
                kstat_ctl = kstat_open();
                kid = kstat_ctl->kc_chain_id;
                new_kstat = 1;
            } else {
                new_kid = kstat_chain_update(kstat_ctl);
                if (new_kid < 0) {
                    res=kstat_close(kstat_ctl);
                    kstat_ctl = kstat_open();
                    kid = kstat_ctl->kc_chain_id;
                    new_kstat = 1;
                } else if (new_kid > 0 && kid != new_kid) {
                    kid = new_kid;
                    new_kstat = 1;
                }
            }
            if (new_kstat) {
                cpu_count = 0;
                for (kstat = kstat_ctl->kc_chain; kstat; kstat = kstat->ks_next) {
                    if (strncmp(kstat->ks_name, "cpu_stat", 8) == 0) {
                        kstat_cpu[cpu_count++]=kstat;
                    }
                }
            }
            for (i = 0; i < cpu_count; i++) {
                new_kid = kstat_read(kstat_ctl, kstat_cpu[i], NULL);
                if (new_kid >= 0) {
                    cpu = ((cpu_stat_t *)kstat_cpu[i]->ks_data)->cpu_sysinfo;
                    if ( tck_divisor == 1 ) {
                        pvals[7] += (jlong)(((jlong)cpu.cpu[CPU_IDLE]) * tck_dividend);
                        pvals[7] += (jlong)(((jlong)cpu.cpu[CPU_WAIT]) * tck_dividend);
                        pvals[8] += (jlong)(((jlong)cpu.cpu[CPU_KERNEL]) * tck_dividend);
                        pvals[9] += (jlong)(((jlong)cpu.cpu[CPU_USER]) * tck_dividend);
                    } else {
                        pvals[7] += (jlong)(((jlong)cpu.cpu[CPU_IDLE]) * tck_dividend / tck_divisor);
                        pvals[7] += (jlong)(((jlong)cpu.cpu[CPU_WAIT]) * tck_dividend / tck_divisor);
                        pvals[8] += (jlong)(((jlong)cpu.cpu[CPU_KERNEL]) * tck_dividend / tck_divisor);
                        pvals[9] += (jlong)(((jlong)cpu.cpu[CPU_USER]) * tck_dividend / tck_divisor);
                    }
                }
            }
        }

        /*
         * The next two are not implemented yet for Solaris
         * inf[4]  - Amount of shared memory
         * inf[5]  - Memory used by buffers
         *
         */
    }

#elif defined(DARWIN)

    uint64_t mem_total;
    size_t len = sizeof(mem_total);

    vm_statistics_data_t vm_info;
    mach_msg_type_number_t info_count = HOST_VM_INFO_COUNT;

    sysctlbyname("hw.memsize", &mem_total, &len, NULL, 0);
    pvals[0] = (jlong)mem_total;

    host_statistics(mach_host_self (), HOST_VM_INFO, (host_info_t)&vm_info, &info_count);
    pvals[1] = (jlong)(((double)vm_info.free_count)*vm_page_size);
    pvals[6] = (jlong)(100 - (pvals[1] * 100 / mem_total));
    rv = APR_SUCCESS;

/* DARWIN */
#else
    rv = APR_ENOTIMPL;
#endif
   (*e)->ReleaseLongArrayElements(e, inf, pvals, 0);
    return rv;
}
コード例 #29
0
/*-------------------------------------------------------------------*/
int HelpCommand( CMDFUNC_ARGS_PROTO )
{
    static int didinit = 0;
    CMDTAB* pCmdTab;
    int     rc = 1;
    int     pfxlen = -1;
    char   *p = NULL;

    UNREFERENCED( cmdline );

    if (!didinit)
    {
        qsort( cmdtab, _countof( cmdtab ), sizeof( CMDTAB ), SortCmdTab );
        didinit = 1;
    }

    /* Too many arguments? */
    if (argc > 2)
    {
        // "Invalid command usage. Type 'help %s' for assistance."
        WRMSG( HHC02299, "E", "help" );
        return 1;
    }

    /* If "help pfx*", calculate prefix length */
    if (argc == 2)
    {
        p = strchr(argv[1], '*');
        if (p != NULL)
        {
            pfxlen = (int)(p - argv[1]);
            if (strlen( argv[1] ) > (unsigned) (pfxlen + 1))
            {
                // "Invalid command usage. Type 'help %s' for assistance."
                WRMSG( HHC02299, "E", argv[0] );
                return -1;
            }
        }
    }

    /* List all commands or those matching given prefix?  */
    if (argc < 2 || pfxlen >= 0)    /* "help" or "help pfx*" ? */
    {
        int found = FALSE;
        int didlong = FALSE;
        char longflag;

        if (argc < 2)
            pfxlen = 0;

        /* List standard formatted commands from our routing table */
        for (pCmdTab = cmdtab; pCmdTab->statement; pCmdTab++)
        {
            if (  (pCmdTab->type & sysblk.sysgroup)
                    && (pCmdTab->shortdesc)
                    && (pfxlen == 0 || !strncasecmp( argv[1], pCmdTab->statement, pfxlen ))
               )
            {
                longflag = ' ';
                if (pCmdTab->longdesc)
                {
                    longflag = '*';
                    didlong = TRUE;
                }
                if (!found)
                {
                    found = TRUE;
                    WRMSG( HHC01603, "I", "" );
                    WRMSG( HHC01602, "I", "Command", ' ', "Description" );
                    WRMSG( HHC01602, "I", "-------", ' ', "-----------------------------------------------" );
                }
                WRMSG( HHC01602, "I", pCmdTab->statement, longflag, pCmdTab->shortdesc );
            }
        }

        /* Prefix given but no matches found? */
        if (pfxlen > 0 && !found)
        {
            // "No help available for mask '%s'"
            WRMSG( HHC01609, "E", argv[1] );
            rc = -1;
        }
        else
        {
            WRMSG( HHC01603, "I", "" );
            if (didlong)
            {
                // " (*)  More help available."
                WRMSG( HHC01610, "I" );
                WRMSG( HHC01603, "I", "" );
            }
            rc = 0;
        }
    }
    else /* (argc == 2 && pfxlen < 0) "help cmd": Show help for given command */
    {
        char longflag;
        size_t cmdlen, matchlen;

        for (pCmdTab = cmdtab; pCmdTab->statement; pCmdTab++)
        {
            cmdlen = pCmdTab->mincmdlen ? pCmdTab->mincmdlen : strlen( pCmdTab->statement );
            matchlen = MAX( strlen(argv[1]), cmdlen );

            if (1
                    && (pCmdTab->shortdesc)
                    && (pCmdTab->type & sysblk.sysgroup)
                    && !strncasecmp( argv[1], pCmdTab->statement, matchlen )
               )
            {
                longflag = (pCmdTab->longdesc) ? '*' : ' ';

                WRMSG( HHC01603, "I", "" );
                WRMSG( HHC01602, "I", "Command", ' ', "Description" );
                WRMSG( HHC01602, "I", "-------", ' ', "-------------------------------------------------------" );
                WRMSG( HHC01602, "I", pCmdTab->statement, longflag, pCmdTab->shortdesc);

                if (pCmdTab->longdesc)
                {
                    char buf[257];
                    int i = 0;
                    int j;

                    WRMSG( HHC01603, "I", "" );
                    while(pCmdTab->longdesc[i])
                    {
                        for(j = 0; j < (int)sizeof(buf)      &&
                                pCmdTab->longdesc[i] &&
                                pCmdTab->longdesc[i] != '\n'; i++, j++)
                        {
                            buf[j] = pCmdTab->longdesc[i];
                        }

                        buf[j] = '\0';
                        if(pCmdTab->longdesc[i] == '\n')
                            i++;
                        WRMSG( HHC01603, "I", buf );
                    }
                }
                WRMSG( HHC01603, "I", "" );
                rc = 0;
                break;
            }
        }

        /* If command not found, check if message help (e.g. "help HHCnnnnn[s]") */
        if (rc == 1)  /* (not found?) */
        {
            /* "help HHCnnnnn" or "help HHCnnnnns" */
            if (strncasecmp( argv[1], "HHC", 3 ) == 0
                    && (strlen( argv[1] ) == 8 ||
                        strlen( argv[1] ) == 9))
            {
                rc = HelpMessage( argv[1] );
            }
            else
            {
                // "Unknown herc command '%s', no help available"
                WRMSG( HHC01604, "I", argv[1] );
                rc = -1;
            }
        }
    }
    return rc;
}
コード例 #30
0
ファイル: hthreads.c プロジェクト: herrold/hyperion
/*-------------------------------------------------------------------*/
DLL_EXPORT int locks_cmd( int argc, char* argv[], char* cmdline )
{
    ILOCK*       ilk;               /* Pointer to ILOCK array        */
    char         tod[27];           /* "YYYY-MM-DD HH:MM:SS.uuuuuu"  */
    TID          tid = 0;           /* Requested thread id           */
    int          seq = 1;           /* Requested sort order          */
    int count, i, rc = 0;
    char c;

    UNREFERENCED( cmdline );

    /*  Format: "locks [ALL|tid|HELD] [SORT NAME|OWNER|TIME|LOC]"  */
    /*  Note:    TID is alias for OWNER,  TOD is alias for TIME.   */

    if (argc <= 1)
        tid = 0;
    else if (strcasecmp( argv[1], "ALL"  ) == 0)
        tid = 0;
    else if (strcasecmp( argv[1], "HELD" ) == 0)
        tid = -1;
    else if (sscanf( argv[1], TIDPAT"%c", (U64*)&tid, &c ) != 1)
        rc = -1;

    if (!rc)
    {
        if (argc == 4)
        {
            if (strcasecmp( argv[2], "SORT" ) != 0)
                rc = -1;
            else
            {
                     if (strcasecmp( argv[3], "TIME"  ) == 0) seq = 1;
                else if (strcasecmp( argv[3], "TOD"   ) == 0) seq = 1;
                else if (strcasecmp( argv[3], "OWNER" ) == 0) seq = 2;
                else if (strcasecmp( argv[3], "TID"   ) == 0) seq = 2;
                else if (strcasecmp( argv[3], "NAME"  ) == 0) seq = 3;
                else if (strcasecmp( argv[3], "LOC"   ) == 0) seq = 4;
                else
                    rc = -1;
            }
        }
        else if (argc != 1 && argc != 2)
            rc = -1;

        /* If no errors, perform the requested function */

        if (!rc)
        {
            /* Retrieve a copy of the locks list */

            count = hthreads_copy_locks_list( &ilk );

            /* Sort them into the requested sequence */

            if (count)
            {
                switch (seq)
                {
                case 1: qsort( ilk, count, sizeof( ILOCK ), (CMPFUNC*) sortby_tim ); break;
                case 2: qsort( ilk, count, sizeof( ILOCK ), (CMPFUNC*) sortby_tid ); break;
                case 3: qsort( ilk, count, sizeof( ILOCK ), (CMPFUNC*) sortby_nam ); break;
                case 4: qsort( ilk, count, sizeof( ILOCK ), (CMPFUNC*) sortby_loc ); break;
                default:
                    BREAK_INTO_DEBUGGER();
                }

                /* Display the requested locks */

                for (c=0, i=0; i < count; i++ )
                {
                    if (0
                        || !tid
                        || (equal_threads( tid, -1 ) && !equal_threads( ilk[i].tid, 0 ))
                        || equal_threads( tid, ilk[i].tid )
                    )
                    {
                        c=1;
                        FormatTIMEVAL( &ilk[i].time, tod, sizeof( tod ));
                        // "Lock=%s, tid="TIDPAT", tod=%s, loc=%s"
                        WRMSG( HHC90017, "I", ilk[i].name, ilk[i].tid, &tod[11], TRIMLOC( ilk[i].location ));
                    }
                }

                free( ilk );
            }
            else
                c = 1;

            /* Print results */

            if (!c)
            {
                // "No locks found for thread "TIDPAT"."
                WRMSG( HHC90019, "W", tid );
            }
            else if (!tid)
            {
                // "Total locks defined: %d"
                WRMSG( HHC90018, "I", count );
            }
        }
    }

    if (rc)
    {
        // "Missing or invalid argument(s)"
        WRMSG( HHC17000, "E" );
    }

    return rc;
}