コード例 #1
0
ファイル: MsgSndTest.c プロジェクト: fangbaolei/AppC
int main(void)
{
    MSG_BUF msg,msg1;
    int MsgId,MsgId1;
    MsgId = MsgInit(&msg, 8, SYS_MSG_KEY, MSG_TYPE_MSG2);
    MsgId1 = MsgInit(&msg1, 55, SYS_MSG_KEY1, MSG_TYPE_MSG3);
    while(1)
    {
        Msg_Send(MsgId, (void *)&msg, sizeof(MSG_BUF));
        printf("send:%d\n",msg.cmd);
        Msg_Send(MsgId1, (void *)&msg1, sizeof(MSG_BUF));
        printf("send1:%d\n",msg1.cmd);
        sleep(1);
    }
    return 0;
}
コード例 #2
0
static void do_init_stuff( char **cmdline )
/*****************************************/
{
    char        *env;
    char        buff[80];

    if( !MsgInit() )
        exit(1);

    AsmInit( -1, -1, -1, -1 );                // initialize hash table
    strcpy( buff, "__WASM__=" BANSTR( _BANVER ) );
    add_constant( buff );
    ForceInclude = getenv( "FORCE" );
    do_envvar_cmdline( "WASM" );
    parse_cmdline( cmdline );
    set_build_target();
    get_os_include();
    env = getenv( "INCLUDE" );
    if( env != NULL )
        AddStringToIncludePath( env );
    if( !Options.quiet && !Options.banner_printed ) {
        Options.banner_printed = TRUE;
        trademark();
    }
    open_files();
    PushLineQueue();
    AsmLookup( "$" );    // create "$" symbol for current segment counter
}
コード例 #3
0
ファイル: libs.c プロジェクト: bongo-project/bongo
PyMODINIT_FUNC
initlibs()
{
    char dbfdir[PATH_MAX];

    /* Initialize the various bongo libraries */
    if (!ConnStartup(DEFAULT_CONNECTION_TIMEOUT)) {
        PyErr_SetString(PyExc_ImportError,
                        "bongo.libs error: ConnStartup() failed");
        return;
    }

    MsgInit();

    if (!BongoCalInit(MsgGetDir(MSGAPI_DIR_DBF, NULL, 0))) {
        PyErr_SetString(PyExc_ImportError,
                        "bongo.libs error: BongoCalInit() failed");
        return;
    }

    if (!NMAPInitialize()) {
        PyErr_SetString(PyExc_ImportError,
                        "bongo.libs error: NMAPInitialize() failed");
        return;
    }

    if (!StreamioInit()) {
        PyErr_SetString(PyExc_ImportError,
                        "bongo.libs error: StreamioInit() failed");
        return;
    }

    if (!BongoJsonPreInit()) {
        PyErr_SetString(PyExc_ImportError,
                        "bongo.libs error: BongoJsonPreInit() failed");
        return;
    }

    /* Create the libs module */
    PyObject *module = Py_InitModule("libs", ModuleMethods);

    /* Add the Bongo libs */
    AddLibrary(module, "cal", CalMethods, NULL);
    //AddLibrary(module, "calcmd", CalCmdMethods, CalCmdEnums);
    AddLibrary(module, "msgapi", MsgApiMethods, NULL);
    AddLibrary(module, "streamio", StreamIOMethods, NULL);
    AddLibrary(module, "bongojson", BongoJsonMethods, NULL);
    AddLibrary(module, "bongoutil", BongoUtilMethods, NULL);
    AddLibrary(module, "tests", TestMethods, NULL);

    BongoJsonPostInit(module);
    BongoCalPostInit(module);
}
コード例 #4
0
ファイル: bdiff.c プロジェクト: Graham-stott/open-watcom-v2
void main( int argc, char **argv )
{
    long        savings;
    foff        buffsize;
    algorithm   alg;

    if( !MsgInit() )
        exit( EXIT_FAILURE );
    alg = ParseArgs( argc, argv );

    EndOld = FileSize( argv[1], &OldCorrection );
    EndNew = FileSize( argv[2], &NewCorrection );

    buffsize = ( EndOld > EndNew ) ? ( EndOld ) : ( EndNew );
    buffsize += sizeof( PATCH_LEVEL );
    OldFile = ReadIn( argv[1], buffsize, EndOld );
    NewFile = ReadIn( argv[2], buffsize, EndNew );

    ScanSyncString( SyncString );

    switch( alg ) {
    case ALG_NOTHING:
        FindRegions();
        break;
#ifdef USE_DBGINFO
    case ALG_ONLY_NEW:
    case ALG_BOTH:
        SymbolicDiff( alg, argv[1], argv[2] );
        break;
#endif
    }

    if( NumHoles == 0 && DiffSize == 0 && EndOld == EndNew ) {
        printf( "Patch file not created - files are identical\n" );
        MsgFini();
        exit( EXIT_SUCCESS );
    }
    MakeHoleArray();
    SortHoleArray();
    ProcessHoleArray( 0 );
    savings = HolesToDiffs();
    WritePatchFile( argv[3], newName );
    FreeHoleArray();
    VerifyCorrect( argv[2] );

    print_stats( savings );

    MsgFini();
    exit( EXIT_SUCCESS );
}
コード例 #5
0
ファイル: main.c プロジェクト: ABratovic/open-watcom-v2
int  main()
/*********/

{
    char                *cmd;
    void               (*parse_object)( void );

#if defined( _M_I86SM ) || defined( _M_I86MM )
    _heapgrow();    /* grow the near heap */
#endif
    if( !MsgInit() ) return( EXIT_FAILURE );
    cmd = AllocMem( CMD_LINE_SIZE );
    getcmd( cmd );
    InitOutput();
    initOptions();
    parseOptions( cmd );
    openFiles();
    InitObj();
    parse_object = InitORL() ? ParseObjectORL : ParseObjectOMF;
    for( ;; ) {
        InitTables();
        ModNameORL = rootName;
        parse_object();
        if( Mod == NULL ) {
            break;
        }
        if( srcReqd ) {
            if( SrcName == NULL ) {
                if( CommentName != NULL ) {
                    SrcName = CommentName;
                } else if( Mod->name != NULL ) {
                    SrcName = Mod->name;
                } else {
                    SrcName = rootName;
                }
            }
            OpenSource();
        }
        DisAssemble();
        if( Source != NULL ) {
            CloseTxt( Source );
        }
        SrcName = NULL;         /* if another module, get name from obj file */
    }
    if( UseORL ) FiniORL();
    CloseBin( ObjFile );
    CloseTxt( Output );
    MsgFini();
    return( 0 );
}
コード例 #6
0
ファイル: main.c プロジェクト: NoSuchProcess/open-watcom-v2
static void do_init_stuff( char **cmdline )
/*****************************************/
{
    char        *env;

    if( !MsgInit() )
        exit(1);

    add_constant( "WASM=" BANSTR( _BANVER ), true );
    ForceInclude = AsmStrDup( getenv( "FORCE" ) );
    do_envvar_cmdline( "WASM" );
    parse_cmdline( cmdline );
    set_build_target();
    set_cpu_mode();
    set_fpu_mode();
    get_os_include();
    env = getenv( "INCLUDE" );
    if( env != NULL )
        AddItemToIncludePath( env, NULL );
    PrintBanner();
    open_files();
    PushLineQueue();
}
コード例 #7
0
return_val Init( void )
{
    return_val          error;
    const char *        const *list;
    const char          *name;
    hash_entry_data     key_entry;

    error = RC_OKAY;

    OutputDest = STDOUT_FILENO;
    ChangePrintDest( OutputDest );

    relocSections.first = NULL;
    relocSections.last = NULL;
    if( !MsgInit() ) {
        // MsgInit does its own error message printing
        return( RC_ERROR );
    }
    MemOpen();

    error = HandleArgs();
    if( error != RC_OKAY ) {
        return( error );
    }

    openFiles();
    initGlobals();
    error = initHashTables();
    if( error != RC_OKAY ) {
        PrintErrorMsg( error, WHERE_INIT_HASH_TABLES );
        return( error );
    }
    error = initServicesUsed();
    if( error != RC_OKAY ) {
        // initServicesUsed does its own error message printing
        return( error );
    }
    error = initSectionTables();
    if( error != RC_OKAY ) {
        PrintErrorMsg( error, WHERE_CREATE_SEC_TABLES );
        return( error );
    }
    if( Options & PRINT_PUBLICS ) {
        CreatePublicsArray();
    }
    if( IsMasmOutput() ) {
        CommentString = MASM_COMMENT_STRING;
    }
    if( IsIntelx86() ) {
        SkipRefTable = HashTableCreate( RECOGNITION_TABLE_SIZE, HASH_STRING_IGNORECASE );
        if( SkipRefTable != NULL ) {
            for( list = intelSkipRefList; (name = *list) != NULL; ++list ) {
                key_entry.key.u.string = name;
                key_entry.data.u.string = *list;
                error = HashTableInsert( SkipRefTable, &key_entry );
                if( error != RC_OKAY ) {
                    break;
                }
            }
        }
    }
    if( LabelChar == 0 ) {
        if( IsMasmOutput() ) {
            LabelChar = 'L';
        } else {
            LabelChar = 'X';
        }
    }
    return( error );
}
コード例 #8
0
ファイル: main.c プロジェクト: ABratovic/open-watcom-v2
void main( int argc, char *argv[] ) {
#pragma on (unreferenced);

    uint        i;
    uint        num_files;
    cmdline_t   *cmd;
    int         multi_module;
    pobj_lib_info pli;

    atexit( cleanupHandler );
    MemInit();
    MsgInit( argv[0] );
    cmd = CmdLineParse();
    init();
    while( cmd->action != NULL ) {
        ActionInit( cmd );
        num_files = cmd->action->num_files;
        i = 0;
        do {
            ActionInfile( cmd, inputFile, i );
            fileIn = ObjReadOpen( inputFile );
            if( fileIn == NULL ) {
                Fatal( MSG_UNABLE_TO_OPEN_FILE, inputFile );
            }
            if( cmd->need_output ) {
                ActionOutfile( cmd, outputFile, i );
                fileOut = ObjWriteOpen( outputFile );
                if( fileOut == NULL ) {
                    Fatal( MSG_UNABLE_TO_OPEN_FILE, outputFile );
                }
            } else {
                fileOut = NULL;
            }
            if( cmd->quiet == 0 ) {
                char    msgbuff[MAX_RESOURCE_SIZE];

                MsgGet( MSG_CONVERTING, msgbuff );
                PrtFmt( msgbuff, inputFile );
                PrtFmt( "\n" );
            }
            pli.is_lib = 0;
            do {
                multi_module = PObj( fileIn, fileOut, &pli );
                prune();
            } while( multi_module );
            ObjReadClose( fileIn );
            if( fileOut != NULL ) {
                ObjWriteClose( fileOut );
                ActionRename( cmd, inputFile, outputFile, i, pli.is_lib,
                    pli.page_len );
            }
            ++i;
        } while( i < num_files );
        ActionFini( cmd );
    }
    fini();
    MsgFini();
    MemFini();
    outputFile[0] = '\0';
    exit( EXIT_SUCCESS );
}
コード例 #9
0
ファイル: init.c プロジェクト: Ukusbobra/open-watcom-v2
void Init( void )
{
    char                cmd_line[ CMD_LINE_LEN ];
    return_val          error;
    char                **list;

    OutputDest = STDOUT_FILENO;
    ChangePrintDest( OutputDest );

    relocSections.first = NULL;
    relocSections.last = NULL;
    if( !MsgInit() ) {
        // MsgInit does its own error message printing
        exit( -1 );
    }
    MemOpen();

    getcmd( cmd_line );
    HandleArgs( cmd_line );

    openFiles();
    initGlobals();
    error = initHashTables();
    if( error == OKAY ) {
        error = initServicesUsed();
        if( error == OKAY ) {
            error = initSectionTables();
            if( error != OKAY ) {
                // free hash tables and services
                MemClose();
                LeaveProgram( error, WHERE_CREATE_SEC_TABLES );
            }
        } else {
            // free hash tables
            CloseFiles();
            FreeHashTables();
            // initServicesUsed does its own error message printing
            exit( error );
        }
    } else {
        CloseFiles();
        MemClose();
        LeaveProgram( error, WHERE_INIT_HASH_TABLES );
    }
    if( Options & PRINT_PUBLICS ) {
        CreatePublicsArray();
    }
    if( IsMasmOutput() ) {
        CommentString = MASM_COMMENT_STRING;
    }
    if( IsIntelx86() ) {
        SkipRefTable = HashTableCreate( RECOGNITION_TABLE_SIZE, HASH_STRING,
                                        (hash_table_comparison_func) stricmp );
        if( SkipRefTable ) {
            list = intelSkipRefList;
            while( *list ) {
                error = HashTableInsert( SkipRefTable, (hash_value) *list,
                                         (hash_data) *list );
                if( error != OKAY ) break;
                list++;
            }
        }
    }

    if( !LabelChar ) {
        if( IsMasmOutput() ) {
            LabelChar = 'L';
        } else {
            LabelChar = 'X';
        }
    }
}
コード例 #10
0
/*
 * WinMain - main windows entry point
 */
int PASCAL WinMain( HINSTANCE inst, HINSTANCE previnst, LPSTR cmd, int show)
{
    HINSTANCE           newinst;
    HANDLE              h;
    MSG                 msg;
    parm_data           parm;
    command_data        cmddat;
    char                FAR_PTR *cmdline;
    char                filename[_MAX_PATH];

    /*
     * are we the first? if so, winexec another one of ourselves
     * and then start sampling
     */
    if( !previnst ) {
        SharedMemory = NULL;
        StartWDebug386();
        if( !WDebug386 ) {
            WinMessage( "Could not find WDEBUG.386" );
            return( FALSE );
        }
        if( !MsgInit( inst ) ) fatal();
        cmddat.nCmdShow = SW_NORMAL;
        if( cmd == NULL || cmd[0] == 0 ) {
            if( !GetFileName( inst, show, filename ) ) {
                CloseShop();
                return( FALSE );
            }
            cmdline = filename;
        } else {
            cmddat.nCmdShow = SW_MINIMIZE;
            cmdline = cmd;
        }

        h = GlobalAlloc( GMEM_SHARE | GMEM_FIXED | GMEM_ZEROINIT, sizeof( shared_data ) );
        if( h == NULL ) {
            CloseShop();
            return( FALSE );
        }
        SharedMemory = MK_FP( h,0 );

        WaitForFirst = TRUE;    /* tell our counterpart to wait for
                               us before starting the timer */
        cmddat.always2= 2;
        parm.wEnvSeg = 0;
        parm.lpCmdLine = (char far *) "";
        parm.lpCmdShow = (void far *) &cmddat;
        parm.dwReserved = 0;
        newinst = LoadModule( "wsamplew.exe", (LPVOID) &parm );
        if( (UINT)newinst < 32 ) {
            WinMessage( MsgArray[MSG_SAMPLE_12-ERR_FIRST_MESSAGE] );
            CloseShop();
            return( FALSE );
        }
        /*
         * wait for our counterpart to initialize - if he fails,
         * then we must die too
         */
        do {
            GetIData( newinst, (void near *)&IsSecondOK, sizeof( IsSecondOK ) );
            MessageLoop();
        } while( !IsSecondOK );
        if( IsSecondOK == NOT_OK ) {
            WinMessage( MsgArray[MSG_SAMPLE_12-ERR_FIRST_MESSAGE] );
            CloseShop();
            return( FALSE );
        }

        /*
         * get data created by our counterpart
         */
        GetIData( newinst, &OutputWindow, sizeof( OutputWindow ) );
        GetIData( newinst, &MainWindowHandle, sizeof( MainWindowHandle ) );
        GetIData( newinst, &SampSave, sizeof( SampSave) );

        /*
         * start the sampler - our other half will be re-started
         * once we have loaded the task to be sampled.
         */
        sample_main( cmdline );
        CloseShop();
        SendMessage( MainWindowHandle, WM_CLOSE, 0, 0 );
        return( FALSE );

    } else {

        /*
         * we are the second instance (the guy who waits for
         * timer events and then tries to write the sample file)
         * init our windows stuff, then wait for the first instance
         * to start the samplee, set a timer, and go
         */
        PrevInstance = previnst;
        if( !MsgInit( inst ) ) fatal();
        if( !WindowsInit( inst, show ) ) {
            IsSecondOK = NOT_OK;
            return( FALSE );
        }
        IsSecondOK = A_OK;
        do {
            GetIData( previnst, (void near *)&WaitForFirst, sizeof( WaitForFirst ) );
            MessageLoop();
        } while( WaitForFirst );
        GetIData( previnst, (void near *) &Samples, sizeof( Samples ) );
        GetIData( previnst, &SharedMemory, sizeof( SharedMemory ) );
        KillTimer( MainWindowHandle, TIMER_ID );
        SetTimer( MainWindowHandle, TIMER_ID, 4500, 0L); /* 4.5 seconds */
    }

    /*
     * main message loop for the second instance
     */
    while( GetMessage( &msg, NULL, 0, 0 ) ) {
        TranslateMessage( &msg );
        DispatchMessage( &msg );
    }
    return( FALSE );

} /* WinMain */
コード例 #11
0
ファイル: main.c プロジェクト: tonylazarew/jwasm
int main( int argc, char **argv )
/*******************************/
{
    char    *pEnv;
    int     numArgs = 0;
    int     numFiles = 0;
    int     rc = 0;
#if WILDCARDS
    long    fh; /* _findfirst/next/close() handle, must be long! */
    struct  _finddata_t finfo;
    char    drv[_MAX_DRIVE];
    char    dir[_MAX_DIR];
    char    fname[_MAX_PATH];
#endif

#if 0 //def DEBUG_OUT    /* DebugMsg() cannot be used that early */
    int i;
    for ( i = 1; i < argc; i++ ) {
        printf("argv[%u]=>%s<\n", i, argv[i] );
    }
#endif

    pEnv = getenv( "JWASM" );
    if ( pEnv == NULL )
        pEnv = "";
    argv[0] = pEnv;

#ifndef DEBUG_OUT
    signal(SIGSEGV, genfailure);
#endif

#if CATCHBREAK
    signal(SIGBREAK, genfailure);
#else
    signal(SIGTERM, genfailure);
#endif

    MsgInit();

    while ( 1 ) {
        if ( ParseCmdline( (const char **)argv, &numArgs ) == NULL )
            break;  /* exit if no source file name supplied */
        numFiles++;
        write_logo();
#if WILDCARDS
        if ((fh = _findfirst( Options.names[ASM], &finfo )) == -1 ) {
            DebugMsg(("main: _findfirst(%s) failed\n", Options.names[ASM] ));
            EmitErr( CANNOT_OPEN_FILE, Options.names[ASM], ErrnoStr() );
            break;
        }
        _splitpath( Options.names[ASM], drv, dir, NULL, NULL );
        DebugMsg(("main: _splitpath(%s): drv=\"%s\" dir=\"%s\"\n", Options.names[ASM], drv, dir ));
        do {
            _makepath( fname, drv, dir, finfo.name, NULL );
            DebugMsg(("main: _makepath(\"%s\", \"%s\", \"%s\")=\"%s\"\n", drv, dir, finfo.name, fname ));
            rc = AssembleModule( fname );  /* assemble 1 module */
        } while ( ( _findnext( fh, &finfo ) != -1 ) );
        _findclose( fh );
#else
        rc = AssembleModule( Options.names[ASM] );
#endif
    };
    CmdlineFini();
    if ( numArgs == 0 ) {
        write_logo();
        printf( MsgGetEx( MSG_USAGE ) );
    } else if ( numFiles == 0 )
        EmitError( NO_FILENAME_SPECIFIED );

    MsgFini();
    return( 1 - rc ); /* zero if no errors */
}