Annotation of qemu/roms/SLOF/clients/net-snk/kernel/crt0.c, revision 1.1

1.1     ! root        1: /******************************************************************************
        !             2:  * Copyright (c) 2004, 2008 IBM Corporation
        !             3:  * All rights reserved.
        !             4:  * This program and the accompanying materials
        !             5:  * are made available under the terms of the BSD License
        !             6:  * which accompanies this distribution, and is available at
        !             7:  * http://www.opensource.org/licenses/bsd-license.php
        !             8:  *
        !             9:  * Contributors:
        !            10:  *     IBM Corporation - initial implementation
        !            11:  *****************************************************************************/
        !            12: 
        !            13: 
        !            14: #include <stdlib.h>
        !            15: #include <string.h>
        !            16: extern int main (int, char**);
        !            17: extern int callback (int, char **);
        !            18: 
        !            19: #define MAX_ARGV 10
        !            20: int
        !            21: gen_argv(const char *arg_string, int len, char* argv[])
        !            22: {
        !            23:   const char *str, *str_end, *arg_string_end = arg_string + len;
        !            24:   int i;
        !            25: 
        !            26:   str = arg_string;
        !            27:   for (i = 0; i < MAX_ARGV; i++)
        !            28:     {
        !            29:       str_end = str;
        !            30: 
        !            31:       while((*str_end++ != ' ') && (str_end <= arg_string_end));
        !            32: 
        !            33:       argv[i] = malloc(str_end-str);
        !            34: 
        !            35:       memcpy (argv[i], str, str_end-str-1);
        !            36:       argv[i][str_end-str-1] = '\0';
        !            37:       str = str_end-1;
        !            38:       while(*(++str) == ' ');
        !            39:       if (str >= arg_string_end)
        !            40:        break;
        !            41:     }
        !            42:   return i+1;
        !            43: }
        !            44: 
        !            45: 
        !            46: 
        !            47: int
        !            48: _start(char * arg_string, long len)
        !            49: {
        !            50:     int rc;
        !            51:     int argc;
        !            52:     char* argv[MAX_ARGV];
        !            53: 
        !            54:     argc = gen_argv(arg_string, len, argv);
        !            55: 
        !            56:     rc = main(argc, argv);
        !            57: 
        !            58:     return rc;
        !            59: }
        !            60: 
        !            61: /*
        !            62:  * Takes a Forth representation of a string and generates an argument array,
        !            63:  * then calls callback().
        !            64:  */
        !            65: unsigned long
        !            66: callback_entry(void *base, unsigned long len) {
        !            67:        char *argv[MAX_ARGV];
        !            68:        int argc;
        !            69: 
        !            70:        argc = gen_argv(base, len, argv);
        !            71: 
        !            72:        return (callback(argc, argv));
        !            73: }
        !            74: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.