~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to erts/emulator/sys/unix/erl9_start.c

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * %CopyrightBegin%
3
 
 * 
4
 
 * Copyright Ericsson AB 2002-2009. All Rights Reserved.
5
 
 * 
6
 
 * The contents of this file are subject to the Erlang Public License,
7
 
 * Version 1.1, (the "License"); you may not use this file except in
8
 
 * compliance with the License. You should have received a copy of the
9
 
 * Erlang Public License along with this software. If not, it can be
10
 
 * retrieved online at http://www.erlang.org/.
11
 
 * 
12
 
 * Software distributed under the License is distributed on an "AS IS"
13
 
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
 
 * the License for the specific language governing rights and limitations
15
 
 * under the License.
16
 
 * 
17
 
 * %CopyrightEnd%
18
 
 */
19
 
#ifdef HAVE_CONFIG_H
20
 
#  include "config.h"
21
 
#endif
22
 
#include "sys.h"
23
 
#include "erl_vm.h"
24
 
#include "global.h"
25
 
#include <stdio.h>
26
 
#include <string.h>
27
 
#include <stdlib.h>
28
 
 
29
 
/*
30
 
 * XXX This is a temporary dummy to make sys.c happy until we'll rewrite it.
31
 
 */
32
 
unsigned preloaded_size_ring0 = 1;
33
 
unsigned char preloaded_ring0[1] = {0};
34
 
 
35
 
Preload pre_loaded[] = {
36
 
    {"ring0", 1, preloaded_ring0},
37
 
    {0, 0, 0}
38
 
};
39
 
 
40
 
int
41
 
main(int argc, char** argv)
42
 
{
43
 
    char sbuf[1024];
44
 
    struct {
45
 
        void* p;
46
 
        int sz;
47
 
    } bins[2];
48
 
    int bin_num = 0;
49
 
    FILE* fp;
50
 
    char* progname = argv[0];
51
 
    char* eq;
52
 
 
53
 
    argv++, argc--;
54
 
 
55
 
    if (argc > 0 && argv[0][0] == '-') {
56
 
        argv++, argc--;
57
 
    }
58
 
    if (argc < 1) {
59
 
        abort();
60
 
    }
61
 
    if ((fp = fopen(argv[0], "r")) == NULL) {
62
 
        abort();
63
 
    }
64
 
    
65
 
    /* Needs to be called before any memory allocation */
66
 
    erts_short_init();
67
 
 
68
 
    while (fgets(sbuf, sizeof sbuf, fp)) {
69
 
        if (sbuf[0] == '#') {
70
 
            continue;           /* Comment */
71
 
        } else if (sbuf[0] == 'e' && strncmp("exec", sbuf, 4) == 0) {
72
 
            continue;           /* Comment ;-) */
73
 
        } else if ((eq = strchr(sbuf, '=')) != NULL) {
74
 
            char* val;
75
 
            char* p = strchr(sbuf, '\n');
76
 
            if (p) {
77
 
                *p = '\0';
78
 
            }
79
 
            *eq = '\0';
80
 
            val = erts_read_env(sbuf);
81
 
            if (val == NULL) {
82
 
                *eq = '=';
83
 
                erts_sys_putenv(sbuf, eq - &sbuf[0]);
84
 
            }
85
 
            erts_free_read_env(val);
86
 
        } else if (sbuf[0] == ':' && '0' <= sbuf[1] && sbuf[1] <= '9') {
87
 
            int load_size = atoi(sbuf+1);
88
 
            void* bin;
89
 
            
90
 
            bin = malloc(load_size);
91
 
            if (fread(bin, 1, load_size, fp) != load_size) {
92
 
                abort();
93
 
            }
94
 
            bins[bin_num].p = bin;
95
 
            bins[bin_num].sz = load_size;
96
 
            bin_num++;
97
 
        } else if (strcmp(sbuf, "--end--\n") == 0) {
98
 
            int rval;
99
 
            Eterm mod = NIL;
100
 
            char *val;
101
 
 
102
 
            fclose(fp);
103
 
 
104
 
            if (bin_num != 2) {
105
 
                abort();
106
 
            }
107
 
 
108
 
            val = erts_read_env("ERLBREAKHANDLER");
109
 
            if (val) {
110
 
                init_break_handler();
111
 
            }
112
 
            erts_free_read_env(val);
113
 
 
114
 
            if ((rval = erts_load_module(NULL, 0, NIL, &mod, bins[0].p, bins[0].sz)) < 0) {
115
 
                fprintf(stderr, "%s: Load of initial module failed: %d\n",
116
 
                        progname, rval);
117
 
                abort();
118
 
            }
119
 
            erts_first_process(mod, bins[1].p, bins[1].sz, argc, argv);
120
 
            free(bins[0].p);
121
 
            free(bins[1].p);
122
 
            process_main();
123
 
            abort();
124
 
        } else {
125
 
            fprintf(stderr, "%s: bad line: %s\n", progname, sbuf);
126
 
            abort();
127
 
        }
128
 
    }
129
 
    abort();
130
 
}