]>
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.
20 /* Internal interrupt counter. */
24 /* Constructs a list of command-line elements using the format specified by the
27 * Given argv array should have at least MAXARGC + 1 elements.
28 * Slot numbers may be between 0 and 998 (inclusive).
30 * Constructed argv list will be zero terminated. Character arrays referenced by
31 * the argv structure elements will be either elements from the give shell list,
32 * internal static buffers or the given command string and should thus not
33 * considered owned by or released via the argv structure and should be
34 * considered invalidated by the next argv_from_shell() call.
36 * Shell list elements:
37 * - Starting with '%' - represent the command string.
38 * - Starting with '!' - represent the slot number (increased by one).
39 * - Anything else - used as a literal.
40 * - If no '%' element is found, the command string is appended as an extra.
43 void argv_from_shell( char const * * argv
, LIST
* shell
, char const * command
,
46 static char jobno
[ 4 ];
50 LISTITER iter
= list_begin( shell
);
51 LISTITER end
= list_end( shell
);
55 sprintf( jobno
, "%d", slot
+ 1 );
57 for ( i
= 0; iter
!= end
&& i
< MAXARGC
; ++i
, iter
= list_next( iter
) )
59 switch ( object_str( list_item( iter
) )[ 0 ] )
61 case '%': argv
[ i
] = command
; ++gotpercent
; break;
62 case '!': argv
[ i
] = jobno
; break;
63 default : argv
[ i
] = object_str( list_item( iter
) );
68 argv
[ i
++ ] = command
;
74 /* Returns whether the given command string contains lines longer than the given
77 int check_cmd_for_too_long_lines( char const * command
, int const max
,
78 int * const error_length
, int * const error_max_length
)
82 size_t const l
= strcspn( command
, "\n" );
86 *error_max_length
= max
;
87 return EXEC_CHECK_LINE_TOO_LONG
;
97 /* Checks whether the given shell list is actually a request to execute raw
98 * commands without an external shell.
100 int is_raw_command_request( LIST
* shell
)
102 return !list_empty( shell
) &&
103 !strcmp( object_str( list_front( shell
) ), "%" ) &&
104 list_next( list_begin( shell
) ) == list_end( shell
);
108 /* Returns whether an interrupt has been detected so far. */
110 int interrupted( void )
116 /* Internal interrupt handler. */
118 void onintr( int disp
)
121 out_printf( "...interrupted\n" );