]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/engine/execcmd.c
2 * Copyright 1993, 1995 Christopher Seiwald.
3 * Copyright 2007 Noel Belcourt.
5 * Utility functions shared between different exec*.c platform specific
6 * implementation modules.
8 * This file is part of Jam - see jam.c for Copyright information.
19 /* Internal interrupt counter. */
23 /* Constructs a list of command-line elements using the format specified by the
26 * Given argv array should have at least MAXARGC + 1 elements.
27 * Slot numbers may be between 0 and 998 (inclusive).
29 * Constructed argv list will be zero terminated. Character arrays referenced by
30 * the argv structure elements will be either elements from the give shell list,
31 * internal static buffers or the given command string and should thus not
32 * considered owned by or released via the argv structure and should be
33 * considered invalidated by the next argv_from_shell() call.
35 * Shell list elements:
36 * - Starting with '%' - represent the command string.
37 * - Starting with '!' - represent the slot number (increased by one).
38 * - Anything else - used as a literal.
39 * - If no '%' element is found, the command string is appended as an extra.
42 void argv_from_shell( char const * * argv
, LIST
* shell
, char const * command
,
45 static char jobno
[ 4 ];
49 LISTITER iter
= list_begin( shell
);
50 LISTITER end
= list_end( shell
);
54 sprintf( jobno
, "%d", slot
+ 1 );
56 for ( i
= 0; iter
!= end
&& i
< MAXARGC
; ++i
, iter
= list_next( iter
) )
58 switch ( object_str( list_item( iter
) )[ 0 ] )
60 case '%': argv
[ i
] = command
; ++gotpercent
; break;
61 case '!': argv
[ i
] = jobno
; break;
62 default : argv
[ i
] = object_str( list_item( iter
) );
67 argv
[ i
++ ] = command
;
73 /* Returns whether the given command string contains lines longer than the given
76 int check_cmd_for_too_long_lines( char const * command
, int const max
,
77 int * const error_length
, int * const error_max_length
)
81 size_t const l
= strcspn( command
, "\n" );
85 *error_max_length
= max
;
86 return EXEC_CHECK_LINE_TOO_LONG
;
96 /* Checks whether the given shell list is actually a request to execute raw
97 * commands without an external shell.
99 int is_raw_command_request( LIST
* shell
)
101 return !list_empty( shell
) &&
102 !strcmp( object_str( list_front( shell
) ), "%" ) &&
103 list_next( list_begin( shell
) ) == list_end( shell
);
107 /* Returns whether an interrupt has been detected so far. */
109 int interrupted( void )
115 /* Internal interrupt handler. */
117 void onintr( int disp
)
120 out_printf( "...interrupted\n" );