wince_wmain_adapter.cpp 1.31 KB
Newer Older
John Koleszar's avatar
John Koleszar committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
/*
 *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license and patent
 *  grant that can be found in the LICENSE file in the root of the source
 *  tree. All contributing project authors may be found in the AUTHORS
 *  file in the root of the source tree.
 */


/* This program is created to take command arguments and pass
 * them to main() in example.c or example_xma.c, because the
 * correspending part in example.c or example_xma.c does not
 * work on Pocket PC platform.
 * To modify the command arguments, go to "Property" page and
 * fill in "Command arguments." For example:
 *  --codec vp6 --flipuv --progress _bnd.vp6
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_NUM_ARG 64
#define MAX_SIZ_ARG 512

extern "C"
{
    int main(int argc, char **argv);
}

int wmain(int argc, wchar_t **argv) {
    char *cargv[MAX_NUM_ARG];
    char chargv[MAX_SIZ_ARG];
    int ret;

    /* transform command line arguments from (wchar_t *) to (char *) */
    for(int i=0; i<argc; i++) {
        wcstombs( chargv, argv[i], sizeof(chargv));
        cargv[i] = _strdup(chargv);
    }

    ret = main(argc, (char **)cargv);

    //free the memory located by _strdup()
    for(int i=0; i<argc; i++)
        free(cargv[i]);

    return ret;
}