jed-users mailing list

[2022 Date Index] [2022 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

[jed-users] Passing variable by reference [optionally] in C


Greetings fellow jed users

While this matter can be solve with multiple returns in stack. 
I would like to know how to implement it this helpful routine in C.

Example:
```
% syntax: [output =] c_shell ( command [, &exit_code [, &error_code] );

% simple code
out = c_shell("head -1 /etc/shells");

% get exit code
out = c_shell("head -1 /etc/shells", &exit_code);
if ( exit_code == 0 ) % succeed
	% do something with the output buffer

% get error code
out = c_shell("head -1 /etc/shells", &exit_code, &error_code);
if ( exit_code ) % failed
	printf("System returns errno = %d\n", error_code);
```

For now i use stack, 
```
(output, exit_status, error_code) = c_shell("head -1 /etc/shells");
```
but I would prefer the first way. I search documentation didnt find
something relative except that it can do it in S-Lang.
(https://www.jedsoft.org/slang/doc/html/slang-3.html#ss3.4)

Best regards.
Code is available in github (under GPL) in case that you want to study
or use it.
-- 
Nicholas Christopoulos <mailto:nereus@xxxxxxxxxxx>
Personal Pages: <https://nicholas-christopoulos.dev>
Github repositories: <https://github.com/nereusx>
_______________________________________________
For list information, visit <http://jedsoft.org/jed/mailinglists.html>.


[2022 date index] [2022 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]