appshell.c

来自「用于TM1300/PNX1300系列DSP(主要用于视频处理)的动态下载程序源码」· C语言 代码 · 共 82 行

C
82
字号
/*
 * Copyright (c) 1995,2000 TriMedia Technologies Inc.       
 *
 * +------------------------------------------------------------------+
 * | This software is furnished under a license and may only be used  |
 * | and copied in accordance with the terms and conditions of  such  |
 * | a license and with the inclusion of this copyright notice. This  |
 * | software or any other copies of this software may not be provided|
 * | or otherwise made available to any other person.  The ownership  |
 * | and title of this software is not transferred.                   |
 * |                                                                  |
 * | The information in this software is subject  to change without   |
 * | any  prior notice and should not be construed as a commitment by |
 * | TriMedia Technologies.                                           |
 * |                                                                  |
 * | this code and information is provided "as is" without any        |
 * | warranty of any kind, either expressed or implied, including but |
 * | not limited to the implied warranties of merchantability and/or  |
 * | fitness for any particular purpose.                              |
 * +------------------------------------------------------------------+
 *
 *  Module name              : appshell.c    1.6
 *
 *  Last update              : 16:57:56 - 00/06/16
 *
 *  Description              :  simple application shell.
 *
 */

/*----------------------------includes----------------------------------------*/

#include <stdio.h>
#include <tmlib/tmtypes.h>
#include <tmlib/DynamicLoader.h>


/*------------------------ Application Shell ---------------------------------*/


extern Int  _rts_trace_dynldr;

typedef     Int(*Main_Function) ();

Int main(Int argc, String *argv)
{
    DynLoad_Status 		  load_status;
    DynLoad_Code_Segment_Handle   module;
    String                        progname=argv[0];

    if ( (argc >= 2) && (strcmp(argv[1],"-trace") == 0) ) {
        _rts_trace_dynldr= True;
        argc--; argv++;
    }

    if (argc < 2) {
        fprintf(stderr, "%s: usage: %s app arg1 arg2 ... \n", progname, progname);
        exit(-1);
    } 

    load_status = DynLoad_load_application(argv[1], &module);

    if (load_status != DynLoad_OK) {
        String error_msg= Null;

        switch (load_status) {
        case DynLoad_UnknownObjectVersion  : error_msg= "unknown object version";    break;
        case DynLoad_InconsistentObject    : error_msg= "inconsistent object";       break;
        case DynLoad_WrongChecksum         : error_msg= "wrong checksum";            break;
        case DynLoad_WrongEndian           : error_msg= "wrong endian";              break;
        case DynLoad_NotAnApp              : error_msg= "not an application object"; break;
        case DynLoad_FileNotFound          : error_msg= "file not found";            break;
        case DynLoad_InsufficientMemory    : error_msg= "memory overflow";           break;
        }

        fprintf(stderr, "%s: loading of `%s` failed with status %d (%s)\n",
               progname, argv[1], load_status, error_msg);
        exit(-1);
    }

    exit ( ((Main_Function) module->start) (argc-1, argv+1) );
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?