1 /*
2  * Copyright (c) 2017, NVIDIA CORPORATION.  All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 /* clang-format off */
19 
20 /*	run3fqq.c - Implements DFLIB runqq subprogram.  */
21 
22 #include <string.h>
23 #include "ent3f.h"
24 #include "mpalloc.h"
25 
26 extern char *__fstr2cstr();
27 extern void __cstr_free();
28 extern void *_mp_malloc();
29 
ENT3F(RUNQQ,runqq)30 short ENT3F(RUNQQ, runqq)(DCHAR(fname), DCHAR(cline) DCLEN(fname) DCLEN(cline))
31 {
32   char *fn;
33   char *cl;
34   char *m;
35   short i;
36   int len;
37 
38   fn = __fstr2cstr(CADR(fname), CLEN(fname));
39   cl = __fstr2cstr(CADR(cline), CLEN(cline));
40   len = strlen(fn) + strlen(cl) + 1;
41   m = (char *)_mp_malloc((len + 1) * sizeof(char));
42   m = strcpy(m, fn);
43   m = strcat(m, " ");
44   m = strcat(m, cl);
45   i = system(m);
46   _mp_free(m);
47   __cstr_free(fn);
48   __cstr_free(cl);
49   return i;
50 }
51