annotate loadtools/clmain.c @ 275:cedf09b6b5ac

started laying the foundation for fc-fsio host utility
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 23 Feb 2014 20:27:15 +0000
parents e4257294102b
children 837ba1b47478
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This module contains the main() function for the XRAM chain-loading
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * utility fc-xram.
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <sys/types.h>
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdint.h>
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <stdio.h>
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <stdlib.h>
53
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
10 #include <termios.h>
42
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include <unistd.h>
53
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
12 #include "baudrate.h"
42
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "srecreader.h"
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 extern char *target_ttydev;
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 extern struct srecreader iramimage;
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 extern char default_loadagent_image[];
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 extern struct srecreader xramimage;
45
16315ed6401a init-script logic implemented in fc-xram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 42
diff changeset
19 extern char hw_init_script[];
53
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
20 extern struct baudrate baud_rate_table[];
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
21 extern struct baudrate *current_baud_rate;
84
ccc5161848c7 loadtools: support building for GTA0x AP
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
22 extern int gta_modem_poweron;
53
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
23
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
24 extern struct baudrate *find_baudrate_by_name();
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
25
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
26 struct baudrate *xram_load_baudrate;
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
27 struct baudrate *xram_run_baudrate = baud_rate_table; /* 1st entry default */
42
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28
135
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
29 char **passon_argv;
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
30 int passon_argc;
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
31
42
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 main(argc, argv)
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 char **argv;
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 {
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 extern char *optarg;
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 extern int optind;
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 int c;
53
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
38 struct baudrate *br;
42
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39
135
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
40 while ((c = getopt(argc, argv, "+a:b:B:h:H:i:nr:")) != EOF)
42
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 switch (c) {
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 case 'a':
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 iramimage.filename = optarg;
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 continue;
53
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
45 case 'b':
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
46 set_romload_baudrate(optarg);
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
47 continue;
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
48 case 'B':
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
49 br = find_baudrate_by_name(optarg);
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
50 if (!br)
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
51 exit(1); /* error msg already printed */
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
52 xram_load_baudrate = br;
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
53 continue;
42
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 case 'h':
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 read_hwparam_file_shortname(optarg);
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 continue;
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 case 'H':
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 read_hwparam_file_fullpath(optarg);
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 continue;
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 case 'i':
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 set_beacon_interval(optarg);
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 continue;
84
ccc5161848c7 loadtools: support building for GTA0x AP
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
63 case 'n':
ccc5161848c7 loadtools: support building for GTA0x AP
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
64 gta_modem_poweron = 0;
ccc5161848c7 loadtools: support building for GTA0x AP
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
65 continue;
135
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
66 case 'r':
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
67 br = find_baudrate_by_name(optarg);
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
68 if (!br)
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
69 exit(1); /* error msg already printed */
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
70 xram_run_baudrate = br;
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
71 continue;
42
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 case '?':
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 default:
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 usage: fprintf(stderr,
135
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
75 "usage: fc-xram [options] ttyport xramimage.srec [2ndprog]\n");
42
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 exit(1);
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 }
53
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
78 if (argc - optind < 2)
42
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 goto usage;
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 target_ttydev = argv[optind];
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 xramimage.filename = argv[optind+1];
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 if (!iramimage.filename)
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 iramimage.filename = default_loadagent_image;
53
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
84 if (argc - optind >= 3) {
135
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
85 passon_argv = argv + optind + 2;
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
86 passon_argc = argc - optind - 2;
53
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
87 }
42
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 open_target_serial();
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 perform_romload();
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 /* loadagent should be running now */
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 if (tpinterf_pass_output(1) < 0)
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 exit(1);
45
16315ed6401a init-script logic implemented in fc-xram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 42
diff changeset
94 if (hw_init_script[0]) {
16315ed6401a init-script logic implemented in fc-xram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 42
diff changeset
95 printf("Executing init script %s\n", hw_init_script);
16315ed6401a init-script logic implemented in fc-xram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 42
diff changeset
96 c = exec_init_script(hw_init_script);
16315ed6401a init-script logic implemented in fc-xram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 42
diff changeset
97 if (c)
16315ed6401a init-script logic implemented in fc-xram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 42
diff changeset
98 exit(1);
16315ed6401a init-script logic implemented in fc-xram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 42
diff changeset
99 }
53
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
100 if (xram_load_baudrate && xram_load_baudrate != current_baud_rate) {
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
101 c = loadagent_switch_baud(xram_load_baudrate);
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
102 if (c)
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
103 exit(1);
604648026e9c fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
104 }
42
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105 printf("Sending XRAM image to loadagent\n");
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106 perform_chain_load();
135
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
107 if (passon_argv)
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
108 exec_2nd_prog();
42
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 tty_passthru();
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 exit(0);
5da0cbee2b89 fc-xram tool written, compiles, now needs to be debugged
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111 }
135
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
112
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
113 exec_2nd_prog()
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
114 {
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
115 char **execp_argv;
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
116 char **sp, **dp;
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
117 extern int target_fd;
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
118 char desc_arg[16];
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
119
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
120 sprintf(desc_arg, "-d%d", target_fd);
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
121 execp_argv = (char **) malloc(sizeof(char *) * (passon_argc + 2));
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
122 if (!execp_argv) {
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
123 perror("malloc argv for execvp");
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
124 exit(1);
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
125 }
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
126 sp = passon_argv;
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
127 dp = execp_argv;
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
128 *dp++ = *sp++;
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
129 *dp++ = desc_arg;
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
130 while (*sp)
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
131 *dp++ = *sp++;
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
132 *dp = NULL;
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
133 execvp(execp_argv[0], execp_argv);
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
134 fprintf(stderr, "Unable to execvp %s\n", passon_argv[0]);
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
135 exit(1);
e4257294102b fc-xram: execvp of secondary program implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
136 }