Removed useless mark for translation
[anjuta.git] / launcher / anjuta-launcher.c
blob9a742207fe13fb18ca7c9c5860bbee80a54f1038
1 /*
2 anjuta-launcher.c
3 Copyright (C) 2000 Kh. Naba Kumar Singh
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifdef HAVE_CONFIG_H
21 # include <config.h>
22 #endif
24 #include <sys/types.h>
25 #include <sys/unistd.h>
26 #include <sys/wait.h>
27 #include <stdio.h>
28 #include <glib.h>
29 #include <unistd.h>
30 #include <string.h>
31 #include <stdlib.h>
33 /* #define DEBUG */
35 int
36 main (int argc, char **argv)
38 pid_t pid;
39 int status, i;
40 char **arg_v;
42 if (argc < 2)
44 printf ("\nUsage:\n");
45 printf
46 ("anjuta-launcher program_name [program_parameter ... ]\n\n");
47 exit (-1);
50 if (strcmp (argv[1], "--version") == 0)
52 printf ("anjuta-launcher version 0.1.2\n");
53 exit (0);
55 if (strcmp (argv[1], "--__debug_terminal") == 0)
57 FILE *fp;
59 if (argc != 3)
61 printf ("\nUsage:\n");
62 printf ("anjuta-launcher program_name [program_parameter ... ]\n\n");
63 exit (-1);
65 fp = fopen (argv[2], "w");
66 if (fp == NULL)
68 g_warning ("Fatal Error: Cannot write to redirection file\n");
70 else
72 char* tty_name;
73 tty_name = ttyname(0);
74 if (tty_name)
76 fprintf (fp, "%s\n", tty_name);
77 fclose (fp);
78 printf ("Debug Terminal for the process:\n");
79 printf ("-------------------------------\n");
80 while (1) pause ();
81 exit (0);
83 else
85 fprintf (fp, "__ERROR__\n");
86 fclose (fp);
87 g_warning ("Fatal Error: Unexpected error -- Unknowm tty\n");
90 getchar ();
91 exit (-1);
94 arg_v = g_malloc ((argc) * sizeof (char *));
95 printf ("EXECUTING:\n");
96 for (i = 1; i < argc; i++)
98 printf ("%s ", argv[i]);
99 arg_v[i - 1] = g_strdup (argv[i]);
101 printf ("\n----------------------------------------------\n");
102 arg_v[i - 1] = NULL;
104 if ((pid = fork ()) == 0)
106 execvp (argv[1], arg_v);
107 printf ("Unable to execute the command (not found)\n");
108 exit (-1);
110 if (pid < 0)
112 printf ("\n----------------------------------------------\n");
113 printf ("There was an error in launching the program\n");
114 status = -1;
116 else
118 waitpid (pid, &status, 0);
119 printf ("\n----------------------------------------------\n");
121 waitpid (pid, &status, 0);
123 if (WIFSIGNALED (status)) {
124 int signal = WTERMSIG (status);
126 printf ("Program has been terminated receiving signal %d (%s)\n", signal, g_strsignal (signal));
127 } else if (WIFEXITED (status))
128 printf ("Program exited with errcode (%d)\n", WEXITSTATUS (status));
130 printf ("Press the Enter key to close this terminal ... \n");
131 getchar ();
132 return WEXITSTATUS (status);