mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-03-28 14:56:28 +01:00
Bug 568079: Reformat source code using clang-format
This will enforce formatting when building the native code Change-Id: I6c047f4c0672609df322b7ba716fc786f0e3aab4 Signed-off-by: Torbjörn Svensson <azoff@svenskalinuxforeningen.se>
This commit is contained in:
parent
7f10dce12f
commit
6431307e70
46 changed files with 2707 additions and 3505 deletions
12
.clang-format
Normal file
12
.clang-format
Normal file
|
@ -0,0 +1,12 @@
|
|||
BasedOnStyle: LLVM
|
||||
|
||||
# Set column width to 120
|
||||
ColumnLimit: 120
|
||||
|
||||
# Sorting include statements will put "windows.h" last and result in build error.
|
||||
# To avoid unpredictable build errors, disable sorting.
|
||||
SortIncludes: false
|
||||
|
||||
# Use 4 spaces as indentation
|
||||
IndentWidth: 4
|
||||
UseTab: Never
|
1
.gitattributes
vendored
1
.gitattributes
vendored
|
@ -135,6 +135,7 @@ test_commands text
|
|||
|
||||
# Other special files
|
||||
cdtOptions text
|
||||
.clang-format text
|
||||
.contentsettings text
|
||||
*.csv text
|
||||
*.dia binary
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,189 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_assignment=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_base_clause_in_type_declaration=80
|
||||
org.eclipse.cdt.core.formatter.alignment_for_binary_expression=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_compact_if=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_conditional_expression=34
|
||||
org.eclipse.cdt.core.formatter.alignment_for_conditional_expression_chain=18
|
||||
org.eclipse.cdt.core.formatter.alignment_for_constructor_initializer_list=0
|
||||
org.eclipse.cdt.core.formatter.alignment_for_declarator_list=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_enumerator_list=48
|
||||
org.eclipse.cdt.core.formatter.alignment_for_expression_list=0
|
||||
org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_lambda_expression=20
|
||||
org.eclipse.cdt.core.formatter.alignment_for_member_access=0
|
||||
org.eclipse.cdt.core.formatter.alignment_for_overloaded_left_shift_chain=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_array_initializer=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_block=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_block_in_case=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_linkage_declaration=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_method_declaration=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_namespace_declaration=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_switch=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_type_declaration=end_of_line
|
||||
org.eclipse.cdt.core.formatter.comment.line_up_line_comment_in_blocks_on_first_column=false
|
||||
org.eclipse.cdt.core.formatter.comment.min_distance_between_code_and_line_comment=1
|
||||
org.eclipse.cdt.core.formatter.comment.never_indent_line_comments_on_first_column=true
|
||||
org.eclipse.cdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=true
|
||||
org.eclipse.cdt.core.formatter.comment_formatter_off_tag=@formatter\:off
|
||||
org.eclipse.cdt.core.formatter.comment_formatter_on_tag=@formatter\:on
|
||||
org.eclipse.cdt.core.formatter.compact_else_if=true
|
||||
org.eclipse.cdt.core.formatter.continuation_indentation=2
|
||||
org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer=2
|
||||
org.eclipse.cdt.core.formatter.format_block_comment=true
|
||||
org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line=false
|
||||
org.eclipse.cdt.core.formatter.format_header_comment=true
|
||||
org.eclipse.cdt.core.formatter.format_line_comment=true
|
||||
org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header=false
|
||||
org.eclipse.cdt.core.formatter.indent_access_specifier_extra_spaces=0
|
||||
org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier=true
|
||||
org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_linkage=false
|
||||
org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_namespace_header=false
|
||||
org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases=true
|
||||
org.eclipse.cdt.core.formatter.indent_declaration_compare_to_template_header=false
|
||||
org.eclipse.cdt.core.formatter.indent_empty_lines=false
|
||||
org.eclipse.cdt.core.formatter.indent_label_compare_to_statements=true
|
||||
org.eclipse.cdt.core.formatter.indent_statements_compare_to_block=true
|
||||
org.eclipse.cdt.core.formatter.indent_statements_compare_to_body=true
|
||||
org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||
org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch=false
|
||||
org.eclipse.cdt.core.formatter.indentation.size=4
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_after_colon_in_constructor_initializer_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_after_label=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_after_template_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_colon_in_constructor_initializer_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_assignment_operator=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_binary_operator=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_arguments=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_parameters=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_base_clause=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_base_types=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_declarator_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_expression_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_structured_binding_name_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_arguments=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_parameters=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_lambda_return=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_exception_specification=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_structured_binding_name_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_pointer_in_declarator_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_pointer_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_postfix_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_prefix_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_unary_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_binary_operator=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_exception_specification=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_structured_binding_name_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_base_clause=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_base_types=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_declarator_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_expression_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_structured_binding_name_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_lambda_return=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_linkage_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_namespace_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_exception_specification=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_structured_binding_name_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_pointer_in_declarator_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_pointer_in_method_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_prefix_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_ref_qualifier_in_structured_binding=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_semicolon=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_unary_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_brackets=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_exception_specification=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
|
||||
org.eclipse.cdt.core.formatter.join_wrapped_lines=true
|
||||
org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line=false
|
||||
org.eclipse.cdt.core.formatter.keep_empty_array_initializer_on_one_line=false
|
||||
org.eclipse.cdt.core.formatter.keep_imple_if_on_one_line=false
|
||||
org.eclipse.cdt.core.formatter.keep_then_statement_on_same_line=false
|
||||
org.eclipse.cdt.core.formatter.lineSplit=120
|
||||
org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve=1
|
||||
org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line=true
|
||||
org.eclipse.cdt.core.formatter.tabulation.char=tab
|
||||
org.eclipse.cdt.core.formatter.tabulation.size=4
|
||||
org.eclipse.cdt.core.formatter.use_comment_formatter_tag=true
|
||||
org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
|
@ -1,3 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
formatter_profile=_Unmanaged profile 'CDT'
|
||||
formatter_settings_version=1
|
|
@ -12,32 +12,30 @@ extern "C" {
|
|||
* Method: openMaster
|
||||
* Signature: (Z)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster
|
||||
(JNIEnv *, jobject, jboolean);
|
||||
JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster(JNIEnv *, jobject, jboolean);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_pty_PTY
|
||||
* Method: change_window_size
|
||||
* Signature: (III)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size
|
||||
(JNIEnv *, jobject, jint, jint, jint);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size(JNIEnv *, jobject, jint, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_pty_PTY
|
||||
* Method: exec2
|
||||
* Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;Ljava/lang/String;IZ)I
|
||||
* Signature:
|
||||
* ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;Ljava/lang/String;IZ)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_exec2
|
||||
(JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jobjectArray, jstring, jint, jboolean);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_exec2(JNIEnv *, jobject, jobjectArray, jobjectArray, jstring,
|
||||
jobjectArray, jstring, jint, jboolean);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_pty_PTY
|
||||
* Method: waitFor
|
||||
* Signature: (II)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_waitFor
|
||||
(JNIEnv *, jobject, jint, jint);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_waitFor(JNIEnv *, jobject, jint, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -18,16 +18,14 @@ extern "C" {
|
|||
* Method: read0
|
||||
* Signature: (I[BI)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0
|
||||
(JNIEnv *, jobject, jint, jbyteArray, jint);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv *, jobject, jint, jbyteArray, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_pty_PTYInputStream
|
||||
* Method: close0
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0
|
||||
(JNIEnv *, jobject, jint);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0(JNIEnv *, jobject, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -14,16 +14,14 @@ extern "C" {
|
|||
* Method: write0
|
||||
* Signature: (I[BI)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0
|
||||
(JNIEnv *, jobject, jint, jbyteArray, jint);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0(JNIEnv *, jobject, jint, jbyteArray, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_pty_PTYOutputStream
|
||||
* Method: close0
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0
|
||||
(JNIEnv *, jobject, jint);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0(JNIEnv *, jobject, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -10,42 +10,42 @@ extern "C" {
|
|||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_Spawner
|
||||
* Method: exec0
|
||||
* Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;)I
|
||||
* Signature:
|
||||
* ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0
|
||||
(JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jobjectArray);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv *, jobject, jobjectArray, jobjectArray,
|
||||
jstring, jobjectArray);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_Spawner
|
||||
* Method: exec1
|
||||
* Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1
|
||||
(JNIEnv *, jobject, jobjectArray, jobjectArray, jstring);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv *, jobject, jobjectArray, jobjectArray,
|
||||
jstring);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_Spawner
|
||||
* Method: exec2
|
||||
* Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;Ljava/lang/String;IZ)I
|
||||
* Signature:
|
||||
* ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;Ljava/lang/String;IZ)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
|
||||
(JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jobjectArray, jstring, jint, jboolean);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2(JNIEnv *, jobject, jobjectArray, jobjectArray,
|
||||
jstring, jobjectArray, jstring, jint, jboolean);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_Spawner
|
||||
* Method: raise
|
||||
* Signature: (II)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise
|
||||
(JNIEnv *, jobject, jint, jint);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise(JNIEnv *, jobject, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_Spawner
|
||||
* Method: waitFor
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor
|
||||
(JNIEnv *, jobject, jint);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor(JNIEnv *, jobject, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -18,24 +18,22 @@ extern "C" {
|
|||
* Method: read0
|
||||
* Signature: (Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;[BI)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0
|
||||
(JNIEnv *, jobject, jobject, jbyteArray, jint);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0(JNIEnv *, jobject, jobject,
|
||||
jbyteArray, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream
|
||||
* Method: close0
|
||||
* Signature: (Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0
|
||||
(JNIEnv *, jobject, jobject);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0(JNIEnv *, jobject, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream
|
||||
* Method: available0
|
||||
* Signature: (Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_available0
|
||||
(JNIEnv *, jobject, jobject);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_available0(JNIEnv *, jobject, jobject);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -12,16 +12,15 @@ extern "C" {
|
|||
* Method: write0
|
||||
* Signature: (Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;[BI)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0
|
||||
(JNIEnv *, jobject, jobject, jbyteArray, jint);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0(JNIEnv *, jobject, jobject,
|
||||
jbyteArray, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream
|
||||
* Method: close0
|
||||
* Signature: (Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0
|
||||
(JNIEnv *, jobject, jobject);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0(JNIEnv *, jobject, jobject);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -22,6 +22,6 @@
|
|||
extern pid_t exec0(const char *path, char *const argv[], char *const envp[], const char *dirpath, int channels[3]);
|
||||
|
||||
extern pid_t exec_pty(const char *path, char *const argv[], char *const envp[], const char *dirpath, int channels[3],
|
||||
const char *pts_name, int fdm, int console);
|
||||
const char *pts_name, int fdm, int console);
|
||||
|
||||
extern int wait0(pid_t pid);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
* Wind River Systems, Inc.
|
||||
* Wind River Systems, Inc.
|
||||
* Mikhail Zabaluev (Nokia) - bug 82744
|
||||
* Mikhail Sennikovsky - bug 145737
|
||||
*******************************************************************************/
|
||||
|
@ -26,166 +26,165 @@
|
|||
#include <termios.h>
|
||||
|
||||
/* from pfind.c */
|
||||
extern char* pfind(const char *name, char *const envp[]);
|
||||
extern char *pfind(const char *name, char *const envp[]);
|
||||
|
||||
pid_t exec_pty(const char *path, char *const argv[], char *const envp[], const char *dirpath, int channels[3],
|
||||
const char *pts_name, int fdm, int console) {
|
||||
int pipe2[2];
|
||||
pid_t childpid;
|
||||
char *full_path;
|
||||
const char *pts_name, int fdm, int console) {
|
||||
int pipe2[2];
|
||||
pid_t childpid;
|
||||
char *full_path;
|
||||
|
||||
/*
|
||||
* We use pfind() to check that the program exists and is an executable.
|
||||
* If not pass the error up. Also execve() wants a full path.
|
||||
*/
|
||||
full_path = pfind(path, envp);
|
||||
if (full_path == NULL) {
|
||||
fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : "");
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
* We use pfind() to check that the program exists and is an executable.
|
||||
* If not pass the error up. Also execve() wants a full path.
|
||||
*/
|
||||
full_path = pfind(path, envp);
|
||||
if (full_path == NULL) {
|
||||
fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : "");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure we can create our pipes before forking.
|
||||
*/
|
||||
if (channels != NULL && console) {
|
||||
if (pipe(pipe2) < 0) {
|
||||
fprintf(stderr, "%s(%d): returning due to error: %s\n", __func__, __LINE__, strerror(errno));
|
||||
free(full_path);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Make sure we can create our pipes before forking.
|
||||
*/
|
||||
if (channels != NULL && console) {
|
||||
if (pipe(pipe2) < 0) {
|
||||
fprintf(stderr, "%s(%d): returning due to error: %s\n", __func__, __LINE__, strerror(errno));
|
||||
free(full_path);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
childpid = fork();
|
||||
childpid = fork();
|
||||
|
||||
if (childpid < 0) {
|
||||
fprintf(stderr, "%s(%d): returning due to error: %s\n", __func__,
|
||||
__LINE__, strerror(errno));
|
||||
free(full_path);
|
||||
return -1;
|
||||
} else if (childpid == 0) { /* child */
|
||||
if (childpid < 0) {
|
||||
fprintf(stderr, "%s(%d): returning due to error: %s\n", __func__, __LINE__, strerror(errno));
|
||||
free(full_path);
|
||||
return -1;
|
||||
} else if (childpid == 0) { /* child */
|
||||
|
||||
chdir(dirpath);
|
||||
chdir(dirpath);
|
||||
|
||||
if (channels != NULL) {
|
||||
int fds;
|
||||
if (channels != NULL) {
|
||||
int fds;
|
||||
|
||||
if (!console && setsid() < 0) {
|
||||
perror("setsid()");
|
||||
return -1;
|
||||
}
|
||||
if (!console && setsid() < 0) {
|
||||
perror("setsid()");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fds = ptys_open(fdm, pts_name);
|
||||
if (fds < 0) {
|
||||
fprintf(stderr, "%s(%d): returning due to error: %s\n", __func__, __LINE__, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
fds = ptys_open(fdm, pts_name);
|
||||
if (fds < 0) {
|
||||
fprintf(stderr, "%s(%d): returning due to error: %s\n", __func__, __LINE__, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Close the read end of pipe2 */
|
||||
if (console && close(pipe2[0]) == -1) {
|
||||
perror("close(pipe2[0]))");
|
||||
}
|
||||
/* Close the read end of pipe2 */
|
||||
if (console && close(pipe2[0]) == -1) {
|
||||
perror("close(pipe2[0]))");
|
||||
}
|
||||
|
||||
/* close the master, no need in the child */
|
||||
close(fdm);
|
||||
/* close the master, no need in the child */
|
||||
close(fdm);
|
||||
|
||||
if (console) {
|
||||
set_noecho(fds);
|
||||
if (setpgid(getpid(), getpid()) < 0) {
|
||||
perror("setpgid()");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (console) {
|
||||
set_noecho(fds);
|
||||
if (setpgid(getpid(), getpid()) < 0) {
|
||||
perror("setpgid()");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* redirections */
|
||||
dup2(fds, STDIN_FILENO); /* dup stdin */
|
||||
dup2(fds, STDOUT_FILENO); /* dup stdout */
|
||||
if (console) {
|
||||
dup2(pipe2[1], STDERR_FILENO); /* dup stderr */
|
||||
} else {
|
||||
dup2(fds, STDERR_FILENO); /* dup stderr */
|
||||
}
|
||||
close(fds); /* done with fds. */
|
||||
}
|
||||
/* redirections */
|
||||
dup2(fds, STDIN_FILENO); /* dup stdin */
|
||||
dup2(fds, STDOUT_FILENO); /* dup stdout */
|
||||
if (console) {
|
||||
dup2(pipe2[1], STDERR_FILENO); /* dup stderr */
|
||||
} else {
|
||||
dup2(fds, STDERR_FILENO); /* dup stderr */
|
||||
}
|
||||
close(fds); /* done with fds. */
|
||||
}
|
||||
|
||||
/* Close all the fd's in the child */
|
||||
{
|
||||
int fdlimit = sysconf(_SC_OPEN_MAX);
|
||||
int fd = 3;
|
||||
/* Close all the fd's in the child */
|
||||
{
|
||||
int fdlimit = sysconf(_SC_OPEN_MAX);
|
||||
int fd = 3;
|
||||
|
||||
while (fd < fdlimit) {
|
||||
close(fd++);
|
||||
}
|
||||
}
|
||||
while (fd < fdlimit) {
|
||||
close(fd++);
|
||||
}
|
||||
}
|
||||
|
||||
if (envp[0] == NULL) {
|
||||
execv(full_path, argv);
|
||||
} else {
|
||||
execve(full_path, argv, envp);
|
||||
}
|
||||
if (envp[0] == NULL) {
|
||||
execv(full_path, argv);
|
||||
} else {
|
||||
execve(full_path, argv, envp);
|
||||
}
|
||||
|
||||
_exit(127);
|
||||
_exit(127);
|
||||
|
||||
} else if (childpid != 0) { /* parent */
|
||||
if (console) {
|
||||
set_noecho(fdm);
|
||||
}
|
||||
if (channels != NULL) {
|
||||
channels[0] = fdm; /* Input Stream. */
|
||||
channels[1] = fdm; /* Output Stream. */
|
||||
if (console) {
|
||||
/* close the write end of pipe1 */
|
||||
if (close(pipe2[1]) == -1) {
|
||||
perror("close(pipe2[1])");
|
||||
}
|
||||
channels[2] = pipe2[0]; /* stderr Stream. */
|
||||
} else {
|
||||
channels[2] = fdm; /* Error Stream. */
|
||||
}
|
||||
}
|
||||
} else if (childpid != 0) { /* parent */
|
||||
if (console) {
|
||||
set_noecho(fdm);
|
||||
}
|
||||
if (channels != NULL) {
|
||||
channels[0] = fdm; /* Input Stream. */
|
||||
channels[1] = fdm; /* Output Stream. */
|
||||
if (console) {
|
||||
/* close the write end of pipe1 */
|
||||
if (close(pipe2[1]) == -1) {
|
||||
perror("close(pipe2[1])");
|
||||
}
|
||||
channels[2] = pipe2[0]; /* stderr Stream. */
|
||||
} else {
|
||||
channels[2] = fdm; /* Error Stream. */
|
||||
}
|
||||
}
|
||||
|
||||
free(full_path);
|
||||
return childpid;
|
||||
}
|
||||
free(full_path);
|
||||
return childpid;
|
||||
}
|
||||
|
||||
free(full_path);
|
||||
return -1; /*NOT REACHED */
|
||||
free(full_path);
|
||||
return -1; /*NOT REACHED */
|
||||
}
|
||||
|
||||
#ifdef __STAND_ALONE__
|
||||
int main(int argc, char **argv, char **envp) {
|
||||
const char *path = "./bufferring_test";
|
||||
int channels[3] = { -1, -1, -1};
|
||||
int status;
|
||||
FILE *app_stdin;
|
||||
FILE *app_stdout;
|
||||
FILE *app_stderr;
|
||||
char pts_name[32];
|
||||
int fdm;
|
||||
char buffer[32];
|
||||
const char *path = "./bufferring_test";
|
||||
int channels[3] = {-1, -1, -1};
|
||||
int status;
|
||||
FILE *app_stdin;
|
||||
FILE *app_stdout;
|
||||
FILE *app_stderr;
|
||||
char pts_name[32];
|
||||
int fdm;
|
||||
char buffer[32];
|
||||
|
||||
fdm = ptym_open(pts_name);
|
||||
status = exec_pty(path, argv, envp, ".", channels, pts_name, fdm);
|
||||
if (status >= 0) {
|
||||
app_stdin = fdopen(channels[0], "w");
|
||||
app_stdout = fdopen(channels[1], "r");
|
||||
app_stderr = fdopen(channels[2], "r");
|
||||
if (app_stdout == NULL || app_stderr == NULL || app_stdin == NULL) {
|
||||
fprintf(stderr, "PROBLEMS\n");
|
||||
} else {
|
||||
fputs("foo\n", app_stdin);
|
||||
fputs("bar\n", app_stdin);
|
||||
while(fgets(buffer, sizeof buffer, app_stdout) != NULL) {
|
||||
fprintf(stdout, "STDOUT: %s\n", buffer);
|
||||
}
|
||||
while(fgets(buffer, sizeof buffer, app_stderr) != NULL) {
|
||||
fprintf(stdout, "STDERR: %s\n", buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
fputs("bye\n", stdout);
|
||||
close(channels[0]);
|
||||
close(channels[1]);
|
||||
close(channels[2]);
|
||||
return 0;
|
||||
fdm = ptym_open(pts_name);
|
||||
status = exec_pty(path, argv, envp, ".", channels, pts_name, fdm);
|
||||
if (status >= 0) {
|
||||
app_stdin = fdopen(channels[0], "w");
|
||||
app_stdout = fdopen(channels[1], "r");
|
||||
app_stderr = fdopen(channels[2], "r");
|
||||
if (app_stdout == NULL || app_stderr == NULL || app_stdin == NULL) {
|
||||
fprintf(stderr, "PROBLEMS\n");
|
||||
} else {
|
||||
fputs("foo\n", app_stdin);
|
||||
fputs("bar\n", app_stdin);
|
||||
while (fgets(buffer, sizeof buffer, app_stdout) != NULL) {
|
||||
fprintf(stdout, "STDOUT: %s\n", buffer);
|
||||
}
|
||||
while (fgets(buffer, sizeof buffer, app_stderr) != NULL) {
|
||||
fprintf(stdout, "STDERR: %s\n", buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
fputs("bye\n", stdout);
|
||||
close(channels[0]);
|
||||
close(channels[1]);
|
||||
close(channels[2]);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -23,136 +23,135 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
/* from pfind.c */
|
||||
extern char* pfind(const char *name, char *const envp[]);
|
||||
extern char *pfind(const char *name, char *const envp[]);
|
||||
|
||||
pid_t exec0(const char *path, char *const argv[], char *const envp[], const char *dirpath, int channels[3]) {
|
||||
int pipe0[2], pipe1[2], pipe2[2];
|
||||
pid_t childpid;
|
||||
char *full_path;
|
||||
int pipe0[2], pipe1[2], pipe2[2];
|
||||
pid_t childpid;
|
||||
char *full_path;
|
||||
|
||||
/*
|
||||
* We use pfind() to check that the program exists and is an executable.
|
||||
* If not pass the error up. Also execve() wants a full path.
|
||||
*/
|
||||
full_path = pfind(path, envp);
|
||||
if (full_path == NULL) {
|
||||
fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : "");
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
* We use pfind() to check that the program exists and is an executable.
|
||||
* If not pass the error up. Also execve() wants a full path.
|
||||
*/
|
||||
full_path = pfind(path, envp);
|
||||
if (full_path == NULL) {
|
||||
fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : "");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure we can create our pipes before forking.
|
||||
*/
|
||||
if (channels != NULL) {
|
||||
if (pipe(pipe0) < 0 || pipe(pipe1) < 0 || pipe(pipe2) < 0) {
|
||||
fprintf(stderr, "%s(%d): returning due to error.\n", __func__,
|
||||
__LINE__);
|
||||
free(full_path);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Make sure we can create our pipes before forking.
|
||||
*/
|
||||
if (channels != NULL) {
|
||||
if (pipe(pipe0) < 0 || pipe(pipe1) < 0 || pipe(pipe2) < 0) {
|
||||
fprintf(stderr, "%s(%d): returning due to error.\n", __func__, __LINE__);
|
||||
free(full_path);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
childpid = fork();
|
||||
childpid = fork();
|
||||
|
||||
if (childpid < 0) {
|
||||
fprintf(stderr, "%s(%d): returning due to error: %s\n", __func__, __LINE__, strerror(errno));
|
||||
free(full_path);
|
||||
return -1;
|
||||
} else if (childpid == 0) { /* child */
|
||||
chdir(dirpath);
|
||||
if (childpid < 0) {
|
||||
fprintf(stderr, "%s(%d): returning due to error: %s\n", __func__, __LINE__, strerror(errno));
|
||||
free(full_path);
|
||||
return -1;
|
||||
} else if (childpid == 0) { /* child */
|
||||
chdir(dirpath);
|
||||
|
||||
if (channels != NULL) {
|
||||
/* Close the write end of pipe0 */
|
||||
if (close(pipe0[1]) == -1) {
|
||||
perror("close(pipe0[1])");
|
||||
}
|
||||
if (channels != NULL) {
|
||||
/* Close the write end of pipe0 */
|
||||
if (close(pipe0[1]) == -1) {
|
||||
perror("close(pipe0[1])");
|
||||
}
|
||||
|
||||
/* Close the read end of pipe1 */
|
||||
if (close(pipe1[0]) == -1) {
|
||||
perror("close(pipe1[0])");
|
||||
}
|
||||
/* Close the read end of pipe1 */
|
||||
if (close(pipe1[0]) == -1) {
|
||||
perror("close(pipe1[0])");
|
||||
}
|
||||
|
||||
/* Close the read end of pipe2 */
|
||||
if (close(pipe2[0]) == -1) {
|
||||
perror("close(pipe2[0]))");
|
||||
}
|
||||
/* Close the read end of pipe2 */
|
||||
if (close(pipe2[0]) == -1) {
|
||||
perror("close(pipe2[0]))");
|
||||
}
|
||||
|
||||
/* redirections */
|
||||
dup2(pipe0[0], STDIN_FILENO); /* dup stdin */
|
||||
dup2(pipe1[1], STDOUT_FILENO); /* dup stdout */
|
||||
dup2(pipe2[1], STDERR_FILENO); /* dup stderr */
|
||||
}
|
||||
/* redirections */
|
||||
dup2(pipe0[0], STDIN_FILENO); /* dup stdin */
|
||||
dup2(pipe1[1], STDOUT_FILENO); /* dup stdout */
|
||||
dup2(pipe2[1], STDERR_FILENO); /* dup stderr */
|
||||
}
|
||||
|
||||
/* Close all the fd's in the child */
|
||||
{
|
||||
int fdlimit = sysconf(_SC_OPEN_MAX);
|
||||
int fd = 3;
|
||||
/* Close all the fd's in the child */
|
||||
{
|
||||
int fdlimit = sysconf(_SC_OPEN_MAX);
|
||||
int fd = 3;
|
||||
|
||||
while (fd < fdlimit) {
|
||||
close(fd++);
|
||||
}
|
||||
}
|
||||
while (fd < fdlimit) {
|
||||
close(fd++);
|
||||
}
|
||||
}
|
||||
|
||||
setpgid(getpid(), getpid());
|
||||
setpgid(getpid(), getpid());
|
||||
|
||||
if (envp[0] == NULL) {
|
||||
execv(full_path, argv);
|
||||
} else {
|
||||
execve(full_path, argv, envp);
|
||||
}
|
||||
if (envp[0] == NULL) {
|
||||
execv(full_path, argv);
|
||||
} else {
|
||||
execve(full_path, argv, envp);
|
||||
}
|
||||
|
||||
_exit(127);
|
||||
_exit(127);
|
||||
|
||||
} else if (childpid != 0) { /* parent */
|
||||
if (channels != NULL) {
|
||||
/* close the read end of pipe1 */
|
||||
if (close(pipe0[0]) == -1) {
|
||||
perror("close(pipe0[0])");
|
||||
}
|
||||
} else if (childpid != 0) { /* parent */
|
||||
if (channels != NULL) {
|
||||
/* close the read end of pipe1 */
|
||||
if (close(pipe0[0]) == -1) {
|
||||
perror("close(pipe0[0])");
|
||||
}
|
||||
|
||||
/* close the write end of pipe2 */
|
||||
if (close(pipe1[1]) == -1) {
|
||||
perror("close(pipe1[1])");
|
||||
}
|
||||
/* close the write end of pipe2 */
|
||||
if (close(pipe1[1]) == -1) {
|
||||
perror("close(pipe1[1])");
|
||||
}
|
||||
|
||||
/* close the write end of pipe2 */
|
||||
if (close(pipe2[1]) == -1) {
|
||||
perror("close(pipe2[1])");
|
||||
}
|
||||
/* close the write end of pipe2 */
|
||||
if (close(pipe2[1]) == -1) {
|
||||
perror("close(pipe2[1])");
|
||||
}
|
||||
|
||||
channels[0] = pipe0[1]; /* Output Stream. */
|
||||
channels[1] = pipe1[0]; /* Input Stream. */
|
||||
channels[2] = pipe2[0]; /* Input Stream. */
|
||||
}
|
||||
channels[0] = pipe0[1]; /* Output Stream. */
|
||||
channels[1] = pipe1[0]; /* Input Stream. */
|
||||
channels[2] = pipe2[0]; /* Input Stream. */
|
||||
}
|
||||
|
||||
free(full_path);
|
||||
return childpid;
|
||||
}
|
||||
free(full_path);
|
||||
return childpid;
|
||||
}
|
||||
|
||||
free(full_path);
|
||||
return -1; /*NOT REACHED */
|
||||
free(full_path);
|
||||
return -1; /*NOT REACHED */
|
||||
}
|
||||
|
||||
int wait0(pid_t pid) {
|
||||
int status;
|
||||
int val = -1;
|
||||
int status;
|
||||
int val = -1;
|
||||
|
||||
if (pid < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (pid < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
if (waitpid(pid, &status, 0) < 0) {
|
||||
if (errno == EINTR) {
|
||||
// interrupted system call - retry
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (WIFEXITED(status)) {
|
||||
val = WEXITSTATUS(status);
|
||||
}
|
||||
for (;;) {
|
||||
if (waitpid(pid, &status, 0) < 0) {
|
||||
if (errno == EINTR) {
|
||||
// interrupted system call - retry
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (WIFEXITED(status)) {
|
||||
val = WEXITSTATUS(status);
|
||||
}
|
||||
|
||||
return val;
|
||||
return val;
|
||||
}
|
||||
|
|
|
@ -22,95 +22,95 @@
|
|||
/* Header for class _org_eclipse_cdt_utils_spawner_SpawnerOutputStream */
|
||||
|
||||
static void ThrowByName(JNIEnv *env, const char *name, const char *msg) {
|
||||
jclass cls = (*env)->FindClass(env, name);
|
||||
jclass cls = (*env)->FindClass(env, name);
|
||||
|
||||
if (cls != 0) { /* Otherwise an exception has already been thrown */
|
||||
(*env)->ThrowNew(env, cls, msg);
|
||||
}
|
||||
if (cls != 0) { /* Otherwise an exception has already been thrown */
|
||||
(*env)->ThrowNew(env, cls, msg);
|
||||
}
|
||||
|
||||
/* It's a good practice to clean up the local references. */
|
||||
(*env)->DeleteLocalRef(env, cls);
|
||||
/* It's a good practice to clean up the local references. */
|
||||
(*env)->DeleteLocalRef(env, cls);
|
||||
}
|
||||
|
||||
static int channelToFileDesc(JNIEnv *env, jobject channel) {
|
||||
if (channel == 0) {
|
||||
ThrowByName(env, "java/io/IOException", "Invalid channel object");
|
||||
return -1;
|
||||
}
|
||||
if (channel == 0) {
|
||||
ThrowByName(env, "java/io/IOException", "Invalid channel object");
|
||||
return -1;
|
||||
}
|
||||
|
||||
jclass cls = (*env)->GetObjectClass(env, channel);
|
||||
if (cls == 0) {
|
||||
ThrowByName(env, "java/io/IOException", "Unable to get channel class");
|
||||
return -1;
|
||||
}
|
||||
jclass cls = (*env)->GetObjectClass(env, channel);
|
||||
if (cls == 0) {
|
||||
ThrowByName(env, "java/io/IOException", "Unable to get channel class");
|
||||
return -1;
|
||||
}
|
||||
|
||||
jfieldID fid = (*env)->GetFieldID(env, cls, "fd", "I");
|
||||
if (fid == 0) {
|
||||
ThrowByName(env, "java/io/IOException", "Unable to find fd");
|
||||
return -1;
|
||||
}
|
||||
jfieldID fid = (*env)->GetFieldID(env, cls, "fd", "I");
|
||||
if (fid == 0) {
|
||||
ThrowByName(env, "java/io/IOException", "Unable to find fd");
|
||||
return -1;
|
||||
}
|
||||
|
||||
jint fd = (*env)->GetIntField(env, channel, fid);
|
||||
return fd;
|
||||
jint fd = (*env)->GetIntField(env, channel, fid);
|
||||
return fd;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0(JNIEnv *env, jobject jobj, jobject channel, jbyteArray buf,
|
||||
jint buf_len) {
|
||||
int fd;
|
||||
int status;
|
||||
jbyte *data;
|
||||
int data_len;
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0(JNIEnv *env, jobject jobj,
|
||||
jobject channel, jbyteArray buf,
|
||||
jint buf_len) {
|
||||
int fd;
|
||||
int status;
|
||||
jbyte *data;
|
||||
int data_len;
|
||||
|
||||
data = (*env)->GetByteArrayElements(env, buf, 0);
|
||||
data_len = buf_len;
|
||||
fd = channelToFileDesc(env, channel);
|
||||
data = (*env)->GetByteArrayElements(env, buf, 0);
|
||||
data_len = buf_len;
|
||||
fd = channelToFileDesc(env, channel);
|
||||
|
||||
status = read(fd, data, data_len);
|
||||
(*env)->ReleaseByteArrayElements(env, buf, data, 0);
|
||||
status = read(fd, data, data_len);
|
||||
(*env)->ReleaseByteArrayElements(env, buf, data, 0);
|
||||
|
||||
if (status == 0) {
|
||||
/* EOF. */
|
||||
status = -1;
|
||||
} else if (status == -1) {
|
||||
/* Error, toss an exception */
|
||||
jclass exception = (*env)->FindClass(env, "java/io/IOException");
|
||||
if (exception == NULL) {
|
||||
/* Give up. */
|
||||
return -1;
|
||||
}
|
||||
(*env)->ThrowNew(env, exception, "read error");
|
||||
}
|
||||
if (status == 0) {
|
||||
/* EOF. */
|
||||
status = -1;
|
||||
} else if (status == -1) {
|
||||
/* Error, toss an exception */
|
||||
jclass exception = (*env)->FindClass(env, "java/io/IOException");
|
||||
if (exception == NULL) {
|
||||
/* Give up. */
|
||||
return -1;
|
||||
}
|
||||
(*env)->ThrowNew(env, exception, "read error");
|
||||
}
|
||||
|
||||
return status;
|
||||
return status;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0(JNIEnv *env, jobject jobj, jobject channel) {
|
||||
int fd = channelToFileDesc(env, channel);
|
||||
return close(fd);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0(JNIEnv *env, jobject jobj,
|
||||
jobject channel) {
|
||||
int fd = channelToFileDesc(env, channel);
|
||||
return close(fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0(JNIEnv *env, jobject jobj, jobject channel,
|
||||
jbyteArray buf, jint buf_len) {
|
||||
int status;
|
||||
int fd;
|
||||
jbyte *data;
|
||||
int data_len;
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0(JNIEnv *env, jobject jobj,
|
||||
jobject channel, jbyteArray buf,
|
||||
jint buf_len) {
|
||||
int status;
|
||||
int fd;
|
||||
jbyte *data;
|
||||
int data_len;
|
||||
|
||||
data = (*env)->GetByteArrayElements(env, buf, 0);
|
||||
data_len = buf_len;
|
||||
fd = channelToFileDesc(env, channel);
|
||||
data = (*env)->GetByteArrayElements(env, buf, 0);
|
||||
data_len = buf_len;
|
||||
fd = channelToFileDesc(env, channel);
|
||||
|
||||
status = write(fd, data, data_len);
|
||||
(*env)->ReleaseByteArrayElements(env, buf, data, 0);
|
||||
status = write(fd, data, data_len);
|
||||
(*env)->ReleaseByteArrayElements(env, buf, data, 0);
|
||||
|
||||
return status;
|
||||
return status;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0(JNIEnv *env, jobject jobj, jobject channel) {
|
||||
int fd = channelToFileDesc(env, channel);
|
||||
return close(fd);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0(JNIEnv *env, jobject jobj,
|
||||
jobject channel) {
|
||||
int fd = channelToFileDesc(env, channel);
|
||||
return close(fd);
|
||||
}
|
||||
|
|
|
@ -40,95 +40,95 @@ int ptys_open(int fdm, const char *pts_name);
|
|||
void set_noecho(int fd);
|
||||
|
||||
int openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp) {
|
||||
char line[20];
|
||||
line[0] = 0;
|
||||
*amaster = ptym_open(line);
|
||||
if (*amaster < 0) {
|
||||
return -1;
|
||||
}
|
||||
*aslave = ptys_open(*amaster, line);
|
||||
if (*aslave < 0) {
|
||||
close(*amaster);
|
||||
return -1;
|
||||
}
|
||||
char line[20];
|
||||
line[0] = 0;
|
||||
*amaster = ptym_open(line);
|
||||
if (*amaster < 0) {
|
||||
return -1;
|
||||
}
|
||||
*aslave = ptys_open(*amaster, line);
|
||||
if (*aslave < 0) {
|
||||
close(*amaster);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (name) {
|
||||
strcpy(name, line);
|
||||
}
|
||||
if (name) {
|
||||
strcpy(name, line);
|
||||
}
|
||||
#ifndef TCSAFLUSH
|
||||
#define TCSAFLUSH TCSETAF
|
||||
#endif
|
||||
if (termp) {
|
||||
(void) tcsetattr(*aslave, TCSAFLUSH, termp);
|
||||
}
|
||||
if (termp) {
|
||||
(void)tcsetattr(*aslave, TCSAFLUSH, termp);
|
||||
}
|
||||
#ifdef TIOCSWINSZ
|
||||
if (winp) {
|
||||
(void) ioctl(*aslave, TIOCSWINSZ, (char *)winp);
|
||||
}
|
||||
if (winp) {
|
||||
(void)ioctl(*aslave, TIOCSWINSZ, (char *)winp);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void set_noecho(int fd) {
|
||||
struct termios stermios;
|
||||
if (tcgetattr(fd, &stermios) < 0) {
|
||||
return;
|
||||
}
|
||||
struct termios stermios;
|
||||
if (tcgetattr(fd, &stermios) < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* turn off echo */
|
||||
stermios.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
|
||||
/* Turn off the NL to CR/NL mapping ou output. */
|
||||
/*stermios.c_oflag &= ~(ONLCR);*/
|
||||
/* turn off echo */
|
||||
stermios.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
|
||||
/* Turn off the NL to CR/NL mapping ou output. */
|
||||
/*stermios.c_oflag &= ~(ONLCR);*/
|
||||
|
||||
stermios.c_iflag |= (IGNCR);
|
||||
stermios.c_iflag |= (IGNCR);
|
||||
|
||||
tcsetattr(fd, TCSANOW, &stermios);
|
||||
tcsetattr(fd, TCSANOW, &stermios);
|
||||
}
|
||||
|
||||
int ptym_open(char *pts_name) {
|
||||
int fdm;
|
||||
char *ptr;
|
||||
int fdm;
|
||||
char *ptr;
|
||||
|
||||
strcpy(pts_name, "/dev/ptmx");
|
||||
strcpy(pts_name, "/dev/ptmx");
|
||||
#ifdef __APPLE__
|
||||
fdm = posix_openpt(O_RDWR|O_NOCTTY);
|
||||
fdm = posix_openpt(O_RDWR | O_NOCTTY);
|
||||
#else
|
||||
fdm = getpt();
|
||||
fdm = getpt();
|
||||
#endif
|
||||
if (fdm < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (grantpt(fdm) < 0) { /* grant access to slave */
|
||||
close(fdm);
|
||||
return -2;
|
||||
}
|
||||
if (unlockpt(fdm) < 0) { /* clear slave's lock flag */
|
||||
close(fdm);
|
||||
return -3;
|
||||
}
|
||||
ptr = ptsname(fdm);
|
||||
if (ptr == NULL) { /* get slave's name */
|
||||
close(fdm);
|
||||
return -4;
|
||||
}
|
||||
strcpy(pts_name, ptr); /* return name of slave */
|
||||
return fdm; /* return fd of master */
|
||||
if (fdm < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (grantpt(fdm) < 0) { /* grant access to slave */
|
||||
close(fdm);
|
||||
return -2;
|
||||
}
|
||||
if (unlockpt(fdm) < 0) { /* clear slave's lock flag */
|
||||
close(fdm);
|
||||
return -3;
|
||||
}
|
||||
ptr = ptsname(fdm);
|
||||
if (ptr == NULL) { /* get slave's name */
|
||||
close(fdm);
|
||||
return -4;
|
||||
}
|
||||
strcpy(pts_name, ptr); /* return name of slave */
|
||||
return fdm; /* return fd of master */
|
||||
}
|
||||
|
||||
int ptys_open(int fdm, const char *pts_name) {
|
||||
int fds;
|
||||
/* following should allocate controlling terminal */
|
||||
fds = open(pts_name, O_RDWR);
|
||||
if (fds < 0) {
|
||||
close(fdm);
|
||||
return -5;
|
||||
}
|
||||
int fds;
|
||||
/* following should allocate controlling terminal */
|
||||
fds = open(pts_name, O_RDWR);
|
||||
if (fds < 0) {
|
||||
close(fdm);
|
||||
return -5;
|
||||
}
|
||||
|
||||
#if defined(TIOCSCTTY)
|
||||
/* TIOCSCTTY is the BSD way to acquire a controlling terminal. */
|
||||
if (ioctl(fds, TIOCSCTTY, (char *)0) < 0) {
|
||||
// ignore error: this is expected in console-mode
|
||||
}
|
||||
#if defined(TIOCSCTTY)
|
||||
/* TIOCSCTTY is the BSD way to acquire a controlling terminal. */
|
||||
if (ioctl(fds, TIOCSCTTY, (char *)0) < 0) {
|
||||
// ignore error: this is expected in console-mode
|
||||
}
|
||||
#endif
|
||||
return fds;
|
||||
return fds;
|
||||
}
|
||||
|
|
|
@ -32,85 +32,84 @@
|
|||
#define PATH_DEF "PATH="
|
||||
const int path_def_len = 5; /* strlen(PATH_DEF); */
|
||||
|
||||
char* path_val(char *const envp[]) {
|
||||
int i;
|
||||
if (envp == NULL || envp[0] == NULL) {
|
||||
return getenv("PATH");
|
||||
}
|
||||
char *path_val(char *const envp[]) {
|
||||
int i;
|
||||
if (envp == NULL || envp[0] == NULL) {
|
||||
return getenv("PATH");
|
||||
}
|
||||
|
||||
for (i = 0; envp[i] != NULL; i++) {
|
||||
char *p = envp[i];
|
||||
if (!strncmp(PATH_DEF, p, path_def_len)) {
|
||||
return p + path_def_len;
|
||||
}
|
||||
}
|
||||
for (i = 0; envp[i] != NULL; i++) {
|
||||
char *p = envp[i];
|
||||
if (!strncmp(PATH_DEF, p, path_def_len)) {
|
||||
return p + path_def_len;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* pfind(const char *name, char *const envp[]) {
|
||||
char *tok;
|
||||
char *sp;
|
||||
char *path;
|
||||
char fullpath[PATH_MAX + 1];
|
||||
struct stat sb;
|
||||
char *pfind(const char *name, char *const envp[]) {
|
||||
char *tok;
|
||||
char *sp;
|
||||
char *path;
|
||||
char fullpath[PATH_MAX + 1];
|
||||
struct stat sb;
|
||||
|
||||
/* Sanity check. */
|
||||
if (name == NULL) {
|
||||
fprintf(stderr, "pfind(): Null argument.\n");
|
||||
return NULL;
|
||||
}
|
||||
/* Sanity check. */
|
||||
if (name == NULL) {
|
||||
fprintf(stderr, "pfind(): Null argument.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* For absolute name or name with a path, check if it is an executable. */
|
||||
if (name[0] == '/' || name[0] == '.') {
|
||||
if (access(name, X_OK) == 0) {
|
||||
return strdup(name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/* For absolute name or name with a path, check if it is an executable. */
|
||||
if (name[0] == '/' || name[0] == '.') {
|
||||
if (access(name, X_OK) == 0) {
|
||||
return strdup(name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Search in the PATH environment. */
|
||||
path = path_val(envp);
|
||||
/* Search in the PATH environment. */
|
||||
path = path_val(envp);
|
||||
|
||||
if (path == NULL || strlen(path) <= 0) {
|
||||
fprintf(stderr, "Unable to get $PATH.\n");
|
||||
return NULL;
|
||||
}
|
||||
if (path == NULL || strlen(path) <= 0) {
|
||||
fprintf(stderr, "Unable to get $PATH.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* The value return by getenv() is read-only */
|
||||
path = strdup(path);
|
||||
/* The value return by getenv() is read-only */
|
||||
path = strdup(path);
|
||||
|
||||
tok = strtok_r(path, ":", &sp);
|
||||
while (tok != NULL) {
|
||||
snprintf(fullpath, sizeof(fullpath) - 1, "%s/%s", tok, name);
|
||||
tok = strtok_r(path, ":", &sp);
|
||||
while (tok != NULL) {
|
||||
snprintf(fullpath, sizeof(fullpath) - 1, "%s/%s", tok, name);
|
||||
|
||||
if (stat(fullpath, &sb) == 0 && S_ISREG(sb.st_mode)) { /* fullpath is a file */
|
||||
if (access(fullpath, X_OK) == 0) { /* fullpath is executable */
|
||||
free(path);
|
||||
return strdup(fullpath);
|
||||
}
|
||||
}
|
||||
if (stat(fullpath, &sb) == 0 && S_ISREG(sb.st_mode)) { /* fullpath is a file */
|
||||
if (access(fullpath, X_OK) == 0) { /* fullpath is executable */
|
||||
free(path);
|
||||
return strdup(fullpath);
|
||||
}
|
||||
}
|
||||
|
||||
tok = strtok_r(NULL, ":", &sp);
|
||||
}
|
||||
tok = strtok_r(NULL, ":", &sp);
|
||||
}
|
||||
|
||||
free(path);
|
||||
return NULL;
|
||||
free(path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef BUILD_WITH_MAIN
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
char *fullpath;
|
||||
int main(int argc, char **argv) {
|
||||
int i;
|
||||
char *fullpath;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
fullpath = pfind(argv[i], NULL);
|
||||
if (fullpath == NULL) {
|
||||
printf("Unable to find %s in $PATH.\n", argv[i]);
|
||||
} else {
|
||||
printf("Found %s @ %s.\n", argv[i], fullpath);
|
||||
}
|
||||
}
|
||||
for (i = 1; i < argc; i++) {
|
||||
fullpath = pfind(argv[i], NULL);
|
||||
if (fullpath == NULL) {
|
||||
printf("Unable to find %s in $PATH.\n", argv[i]);
|
||||
} else {
|
||||
printf("Found %s @ %s.\n", argv[i], fullpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -21,53 +21,51 @@
|
|||
* Method: forkpty
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_org_eclipse_cdt_utils_pty_PTY_openMaster(JNIEnv *env, jobject jobj, jboolean console) {
|
||||
jfieldID fid; /* Store the field ID */
|
||||
jstring jstr = NULL;
|
||||
int master = -1;
|
||||
char line[1024]; /* FIXME: Should be enough */
|
||||
jclass cls;
|
||||
JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster(JNIEnv *env, jobject jobj, jboolean console) {
|
||||
jfieldID fid; /* Store the field ID */
|
||||
jstring jstr = NULL;
|
||||
int master = -1;
|
||||
char line[1024]; /* FIXME: Should be enough */
|
||||
jclass cls;
|
||||
|
||||
line[0] = '\0';
|
||||
line[0] = '\0';
|
||||
|
||||
master = ptym_open(line);
|
||||
if (master >= 0) {
|
||||
// turn off echo
|
||||
if (console) {
|
||||
set_noecho(master);
|
||||
}
|
||||
master = ptym_open(line);
|
||||
if (master >= 0) {
|
||||
// turn off echo
|
||||
if (console) {
|
||||
set_noecho(master);
|
||||
}
|
||||
|
||||
/* Get a reference to the obj's class */
|
||||
cls = (*env)->GetObjectClass(env, jobj);
|
||||
/* Get a reference to the obj's class */
|
||||
cls = (*env)->GetObjectClass(env, jobj);
|
||||
|
||||
/* Set the master fd. */
|
||||
fid = (*env)->GetFieldID(env, cls, "master", "I");
|
||||
if (fid == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
(*env)->SetIntField(env, jobj, fid, (jint) master);
|
||||
/* Set the master fd. */
|
||||
fid = (*env)->GetFieldID(env, cls, "master", "I");
|
||||
if (fid == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
(*env)->SetIntField(env, jobj, fid, (jint)master);
|
||||
|
||||
/* Create a new String for the slave. */
|
||||
jstr = (*env)->NewStringUTF(env, line);
|
||||
}
|
||||
return jstr;
|
||||
/* Create a new String for the slave. */
|
||||
jstr = (*env)->NewStringUTF(env, line);
|
||||
}
|
||||
return jstr;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size(JNIEnv *env, jobject jobj, jint fdm,
|
||||
jint width, jint height) {
|
||||
jint width, jint height) {
|
||||
#ifdef TIOCSWINSZ
|
||||
struct winsize win;
|
||||
struct winsize win;
|
||||
|
||||
win.ws_col = width;
|
||||
win.ws_row = height;
|
||||
win.ws_xpixel = 0;
|
||||
win.ws_ypixel = 0;
|
||||
win.ws_col = width;
|
||||
win.ws_row = height;
|
||||
win.ws_xpixel = 0;
|
||||
win.ws_ypixel = 0;
|
||||
|
||||
return ioctl(fdm, TIOCSWINSZ, &win);
|
||||
return ioctl(fdm, TIOCSWINSZ, &win);
|
||||
#else
|
||||
#error no TIOCSWINSZ
|
||||
return 0;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -25,26 +25,26 @@
|
|||
* Method: read0
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv *env, jobject jobj, jint jfd, jbyteArray buf, jint buf_len) {
|
||||
int fd;
|
||||
int status;
|
||||
jbyte *data;
|
||||
int data_len;
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv *env, jobject jobj, jint jfd,
|
||||
jbyteArray buf, jint buf_len) {
|
||||
int fd;
|
||||
int status;
|
||||
jbyte *data;
|
||||
int data_len;
|
||||
|
||||
data = (*env)->GetByteArrayElements(env, buf, 0);
|
||||
data_len = buf_len;
|
||||
fd = jfd;
|
||||
data = (*env)->GetByteArrayElements(env, buf, 0);
|
||||
data_len = buf_len;
|
||||
fd = jfd;
|
||||
|
||||
status = read(fd, data, data_len);
|
||||
(*env)->ReleaseByteArrayElements(env, buf, data, 0);
|
||||
status = read(fd, data, data_len);
|
||||
(*env)->ReleaseByteArrayElements(env, buf, data, 0);
|
||||
|
||||
if (status == 0) {
|
||||
/* EOF. */
|
||||
status = -1;
|
||||
} else if (status == -1) {
|
||||
/* Error, toss an exception */
|
||||
/* Ignore the error for now, the debugger will attempt to close this multiple time. */
|
||||
if (status == 0) {
|
||||
/* EOF. */
|
||||
status = -1;
|
||||
} else if (status == -1) {
|
||||
/* Error, toss an exception */
|
||||
/* Ignore the error for now, the debugger will attempt to close this multiple time. */
|
||||
#if 0
|
||||
jclass exception = (*env)->FindClass(env, "java/io/IOException");
|
||||
if (exception == NULL) {
|
||||
|
@ -53,9 +53,9 @@ Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv *env, jobject jobj, j
|
|||
}
|
||||
(*env)->ThrowNew(env, exception, "read error");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -63,9 +63,8 @@ Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv *env, jobject jobj, j
|
|||
* Method: close0
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0(JNIEnv *env, jobject jobj, jint fd) {
|
||||
return close(fd);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0(JNIEnv *env, jobject jobj, jint fd) {
|
||||
return close(fd);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -73,21 +72,21 @@ Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0(JNIEnv *env, jobject jobj,
|
|||
* Method: write0
|
||||
* Signature: (II)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0(JNIEnv *env, jobject jobj, jint jfd, jbyteArray buf, jint buf_len) {
|
||||
int status;
|
||||
int fd;
|
||||
jbyte *data;
|
||||
int data_len;
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0(JNIEnv *env, jobject jobj, jint jfd,
|
||||
jbyteArray buf, jint buf_len) {
|
||||
int status;
|
||||
int fd;
|
||||
jbyte *data;
|
||||
int data_len;
|
||||
|
||||
data = (*env)->GetByteArrayElements(env, buf, 0);
|
||||
data_len = buf_len;
|
||||
fd = jfd;
|
||||
data = (*env)->GetByteArrayElements(env, buf, 0);
|
||||
data_len = buf_len;
|
||||
fd = jfd;
|
||||
|
||||
status = write(fd, data, data_len);
|
||||
(*env)->ReleaseByteArrayElements(env, buf, data, 0);
|
||||
status = write(fd, data, data_len);
|
||||
(*env)->ReleaseByteArrayElements(env, buf, data, 0);
|
||||
|
||||
return status;
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -95,7 +94,6 @@ Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0(JNIEnv *env, jobject jobj,
|
|||
* Method: close0
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0(JNIEnv *env, jobject jobj, jint fd) {
|
||||
return close(fd);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0(JNIEnv *env, jobject jobj, jint fd) {
|
||||
return close(fd);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
* Wind River Systems, Inc.
|
||||
* Wind River Systems, Inc.
|
||||
* Mikhail Zabaluev (Nokia) - bug 82744
|
||||
*******************************************************************************/
|
||||
#include <unistd.h>
|
||||
|
@ -26,7 +26,7 @@
|
|||
#define DEBUGIT 0
|
||||
|
||||
/*
|
||||
* Header for class org_eclipse_cdt_utils_spawner_Spawner
|
||||
* Header for class org_eclipse_cdt_utils_spawner_Spawner
|
||||
*/
|
||||
|
||||
#if DEBUGIT
|
||||
|
@ -44,57 +44,59 @@ static void print_array(char **c_array) {
|
|||
}
|
||||
#endif
|
||||
|
||||
static char** alloc_c_array(JNIEnv *env, jobjectArray j_array) {
|
||||
int i;
|
||||
jint c_array_size = (*env)->GetArrayLength(env, j_array);
|
||||
char **c_array = calloc(c_array_size + 1, sizeof(char*));
|
||||
static char **alloc_c_array(JNIEnv *env, jobjectArray j_array) {
|
||||
int i;
|
||||
jint c_array_size = (*env)->GetArrayLength(env, j_array);
|
||||
char **c_array = calloc(c_array_size + 1, sizeof(char *));
|
||||
|
||||
if (c_array == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (c_array == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < c_array_size; i++) {
|
||||
jstring j_str = (jstring)(*env)->GetObjectArrayElement(env, j_array, i);
|
||||
const char *c_str = (*env)->GetStringUTFChars(env, j_str, NULL);
|
||||
c_array[i] = (char*) strdup(c_str);
|
||||
(*env)->ReleaseStringUTFChars(env, j_str, c_str);
|
||||
(*env)->DeleteLocalRef(env, j_str);
|
||||
}
|
||||
for (i = 0; i < c_array_size; i++) {
|
||||
jstring j_str = (jstring)(*env)->GetObjectArrayElement(env, j_array, i);
|
||||
const char *c_str = (*env)->GetStringUTFChars(env, j_str, NULL);
|
||||
c_array[i] = (char *)strdup(c_str);
|
||||
(*env)->ReleaseStringUTFChars(env, j_str, c_str);
|
||||
(*env)->DeleteLocalRef(env, j_str);
|
||||
}
|
||||
|
||||
return c_array;
|
||||
return c_array;
|
||||
}
|
||||
|
||||
static void free_c_array(char **c_array) {
|
||||
if (c_array) {
|
||||
for (char **p = c_array; *p; p++) {
|
||||
free(*p);
|
||||
}
|
||||
free(c_array);
|
||||
}
|
||||
if (c_array) {
|
||||
for (char **p = c_array; *p; p++) {
|
||||
free(*p);
|
||||
}
|
||||
free(c_array);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2(JNIEnv *env, jobject jobj, jobjectArray jcmd,
|
||||
jobjectArray jenv, jstring jdir, jobjectArray jchannels, jstring jslaveName, jint masterFD, jboolean console) {
|
||||
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
|
||||
const char *pts_name = (*env)->GetStringUTFChars(env, jslaveName, NULL);
|
||||
char **cmd = NULL;
|
||||
char **envp = NULL;
|
||||
int fd[3];
|
||||
pid_t pid = -1;
|
||||
jobjectArray jenv, jstring jdir,
|
||||
jobjectArray jchannels, jstring jslaveName,
|
||||
jint masterFD, jboolean console) {
|
||||
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
|
||||
const char *pts_name = (*env)->GetStringUTFChars(env, jslaveName, NULL);
|
||||
char **cmd = NULL;
|
||||
char **envp = NULL;
|
||||
int fd[3];
|
||||
pid_t pid = -1;
|
||||
|
||||
if (jchannels == NULL) {
|
||||
goto bail_out;
|
||||
}
|
||||
if (jchannels == NULL) {
|
||||
goto bail_out;
|
||||
}
|
||||
|
||||
cmd = alloc_c_array(env, jcmd);
|
||||
if (cmd == NULL) {
|
||||
goto bail_out;
|
||||
}
|
||||
cmd = alloc_c_array(env, jcmd);
|
||||
if (cmd == NULL) {
|
||||
goto bail_out;
|
||||
}
|
||||
|
||||
envp = alloc_c_array(env, jenv);
|
||||
if (envp == NULL) {
|
||||
goto bail_out;
|
||||
}
|
||||
envp = alloc_c_array(env, jenv);
|
||||
if (envp == NULL) {
|
||||
goto bail_out;
|
||||
}
|
||||
|
||||
#if DEBUGIT
|
||||
fprintf(stderr, "command:");
|
||||
|
@ -105,42 +107,42 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2(JNIEnv *
|
|||
fprintf(stderr, "pts_name: %s\n", pts_name);
|
||||
#endif
|
||||
|
||||
pid = exec_pty(cmd[0], cmd, envp, dirpath, fd, pts_name, masterFD, console);
|
||||
if (pid < 0) {
|
||||
goto bail_out;
|
||||
}
|
||||
pid = exec_pty(cmd[0], cmd, envp, dirpath, fd, pts_name, masterFD, console);
|
||||
if (pid < 0) {
|
||||
goto bail_out;
|
||||
}
|
||||
|
||||
jobject cls = (*env)->FindClass(env, "org/eclipse/cdt/utils/spawner/Spawner$UnixChannel");
|
||||
jmethodID constructor = (*env)->GetMethodID(env, cls, "<init>", "(I)V");
|
||||
for (jsize i = 0; i < 3; i++) {
|
||||
jobject chan = (*env)->NewObject(env, cls, constructor, fd[i]);
|
||||
(*env)->SetObjectArrayElement(env, jchannels, i, chan);
|
||||
}
|
||||
jobject cls = (*env)->FindClass(env, "org/eclipse/cdt/utils/spawner/Spawner$UnixChannel");
|
||||
jmethodID constructor = (*env)->GetMethodID(env, cls, "<init>", "(I)V");
|
||||
for (jsize i = 0; i < 3; i++) {
|
||||
jobject chan = (*env)->NewObject(env, cls, constructor, fd[i]);
|
||||
(*env)->SetObjectArrayElement(env, jchannels, i, chan);
|
||||
}
|
||||
|
||||
bail_out: (*env)->ReleaseStringUTFChars(env, jdir, dirpath);
|
||||
(*env)->ReleaseStringUTFChars(env, jslaveName, pts_name);
|
||||
free_c_array(cmd);
|
||||
free_c_array(envp);
|
||||
return pid;
|
||||
bail_out:
|
||||
(*env)->ReleaseStringUTFChars(env, jdir, dirpath);
|
||||
(*env)->ReleaseStringUTFChars(env, jslaveName, pts_name);
|
||||
free_c_array(cmd);
|
||||
free_c_array(envp);
|
||||
return pid;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv *env, jobject jobj, jobjectArray jcmd, jobjectArray jenv,
|
||||
jstring jdir) {
|
||||
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
|
||||
char **cmd = NULL;
|
||||
char **envp = NULL;
|
||||
pid_t pid = -1;
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv *env, jobject jobj, jobjectArray jcmd,
|
||||
jobjectArray jenv, jstring jdir) {
|
||||
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
|
||||
char **cmd = NULL;
|
||||
char **envp = NULL;
|
||||
pid_t pid = -1;
|
||||
|
||||
cmd = alloc_c_array(env, jcmd);
|
||||
if (cmd == NULL) {
|
||||
goto bail_out;
|
||||
}
|
||||
cmd = alloc_c_array(env, jcmd);
|
||||
if (cmd == NULL) {
|
||||
goto bail_out;
|
||||
}
|
||||
|
||||
envp = alloc_c_array(env, jenv);
|
||||
if (envp == NULL) {
|
||||
goto bail_out;
|
||||
}
|
||||
envp = alloc_c_array(env, jenv);
|
||||
if (envp == NULL) {
|
||||
goto bail_out;
|
||||
}
|
||||
|
||||
#if DEBUGIT
|
||||
fprintf(stderr, "command:");
|
||||
|
@ -150,51 +152,52 @@ Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv *env, jobject jobj, jobj
|
|||
fprintf(stderr, "dirpath: %s\n", dirpath);
|
||||
#endif
|
||||
|
||||
pid = exec0(cmd[0], cmd, envp, dirpath, NULL);
|
||||
if (pid < 0) {
|
||||
goto bail_out;
|
||||
}
|
||||
pid = exec0(cmd[0], cmd, envp, dirpath, NULL);
|
||||
if (pid < 0) {
|
||||
goto bail_out;
|
||||
}
|
||||
|
||||
bail_out: (*env)->ReleaseStringUTFChars(env, jdir, dirpath);
|
||||
free_c_array(cmd);
|
||||
free_c_array(envp);
|
||||
return pid;
|
||||
bail_out:
|
||||
(*env)->ReleaseStringUTFChars(env, jdir, dirpath);
|
||||
free_c_array(cmd);
|
||||
free_c_array(envp);
|
||||
return pid;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv *env, jobject jobj, jobjectArray jcmd, jobjectArray jenv,
|
||||
jstring jdir, jobjectArray jchannels) {
|
||||
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
|
||||
char **cmd = NULL;
|
||||
char **envp = NULL;
|
||||
int fd[3];
|
||||
pid_t pid = -1;
|
||||
jclass channelClass = NULL;
|
||||
jmethodID channelConstructor = NULL;
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv *env, jobject jobj, jobjectArray jcmd,
|
||||
jobjectArray jenv, jstring jdir,
|
||||
jobjectArray jchannels) {
|
||||
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
|
||||
char **cmd = NULL;
|
||||
char **envp = NULL;
|
||||
int fd[3];
|
||||
pid_t pid = -1;
|
||||
jclass channelClass = NULL;
|
||||
jmethodID channelConstructor = NULL;
|
||||
|
||||
if (jchannels == NULL) {
|
||||
goto bail_out;
|
||||
}
|
||||
if (jchannels == NULL) {
|
||||
goto bail_out;
|
||||
}
|
||||
|
||||
channelClass = (*env)->FindClass(env, "org/eclipse/cdt/utils/spawner/Spawner$UnixChannel");
|
||||
if (channelClass == 0) {
|
||||
goto bail_out;
|
||||
}
|
||||
channelClass = (*env)->FindClass(env, "org/eclipse/cdt/utils/spawner/Spawner$UnixChannel");
|
||||
if (channelClass == 0) {
|
||||
goto bail_out;
|
||||
}
|
||||
|
||||
channelConstructor = (*env)->GetMethodID(env, channelClass, "<init>", "(I)V");
|
||||
if (channelConstructor == 0) {
|
||||
goto bail_out;
|
||||
}
|
||||
channelConstructor = (*env)->GetMethodID(env, channelClass, "<init>", "(I)V");
|
||||
if (channelConstructor == 0) {
|
||||
goto bail_out;
|
||||
}
|
||||
|
||||
cmd = alloc_c_array(env, jcmd);
|
||||
if (cmd == NULL) {
|
||||
goto bail_out;
|
||||
}
|
||||
cmd = alloc_c_array(env, jcmd);
|
||||
if (cmd == NULL) {
|
||||
goto bail_out;
|
||||
}
|
||||
|
||||
envp = alloc_c_array(env, jenv);
|
||||
if (envp == NULL) {
|
||||
goto bail_out;
|
||||
}
|
||||
envp = alloc_c_array(env, jenv);
|
||||
if (envp == NULL) {
|
||||
goto bail_out;
|
||||
}
|
||||
|
||||
#if DEBUGIT
|
||||
fprintf(stderr, "command:");
|
||||
|
@ -203,20 +206,21 @@ Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv *env, jobject jobj, jobj
|
|||
print_array(envp);
|
||||
fprintf(stderr, "dirpath: %s\n", dirpath);
|
||||
#endif
|
||||
pid = exec0(cmd[0], cmd, envp, dirpath, fd);
|
||||
if (pid < 0) {
|
||||
goto bail_out;
|
||||
}
|
||||
pid = exec0(cmd[0], cmd, envp, dirpath, fd);
|
||||
if (pid < 0) {
|
||||
goto bail_out;
|
||||
}
|
||||
|
||||
for (jsize i = 0; i < 3; i++) {
|
||||
jobject chan = (*env)->NewObject(env, channelClass, channelConstructor, fd[i]);
|
||||
(*env)->SetObjectArrayElement(env, jchannels, i, chan);
|
||||
}
|
||||
for (jsize i = 0; i < 3; i++) {
|
||||
jobject chan = (*env)->NewObject(env, channelClass, channelConstructor, fd[i]);
|
||||
(*env)->SetObjectArrayElement(env, jchannels, i, chan);
|
||||
}
|
||||
|
||||
bail_out: (*env)->ReleaseStringUTFChars(env, jdir, dirpath);
|
||||
free_c_array(cmd);
|
||||
free_c_array(envp);
|
||||
return pid;
|
||||
bail_out:
|
||||
(*env)->ReleaseStringUTFChars(env, jdir, dirpath);
|
||||
free_c_array(cmd);
|
||||
free_c_array(envp);
|
||||
return pid;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -224,48 +228,47 @@ Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv *env, jobject jobj, jobj
|
|||
* Method: raise
|
||||
* Signature: (II)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_Spawner_raise(JNIEnv *env, jobject jobj, jint pid, jint sig) {
|
||||
int status = -1;
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise(JNIEnv *env, jobject jobj, jint pid, jint sig) {
|
||||
int status = -1;
|
||||
|
||||
switch (sig) {
|
||||
case 0: /* NOOP */
|
||||
status = killpg(pid, 0);
|
||||
if (status == -1) {
|
||||
status = kill(pid, 0);
|
||||
}
|
||||
break;
|
||||
switch (sig) {
|
||||
case 0: /* NOOP */
|
||||
status = killpg(pid, 0);
|
||||
if (status == -1) {
|
||||
status = kill(pid, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: /* INTERRUPT */
|
||||
status = killpg(pid, SIGINT);
|
||||
if (status == -1) {
|
||||
status = kill(pid, SIGINT);
|
||||
}
|
||||
break;
|
||||
case 2: /* INTERRUPT */
|
||||
status = killpg(pid, SIGINT);
|
||||
if (status == -1) {
|
||||
status = kill(pid, SIGINT);
|
||||
}
|
||||
break;
|
||||
|
||||
case 9: /* KILL */
|
||||
status = killpg(pid, SIGKILL);
|
||||
if (status == -1) {
|
||||
status = kill(pid, SIGKILL);
|
||||
}
|
||||
break;
|
||||
case 9: /* KILL */
|
||||
status = killpg(pid, SIGKILL);
|
||||
if (status == -1) {
|
||||
status = kill(pid, SIGKILL);
|
||||
}
|
||||
break;
|
||||
|
||||
case 15: /* TERM */
|
||||
status = killpg(pid, SIGTERM);
|
||||
if (status == -1) {
|
||||
status = kill(pid, SIGTERM);
|
||||
}
|
||||
break;
|
||||
case 15: /* TERM */
|
||||
status = killpg(pid, SIGTERM);
|
||||
if (status == -1) {
|
||||
status = kill(pid, SIGTERM);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
status = killpg(pid, sig); /* WHAT ?? */
|
||||
if (status == -1) {
|
||||
status = kill(pid, sig); /* WHAT ?? */
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
status = killpg(pid, sig); /* WHAT ?? */
|
||||
if (status == -1) {
|
||||
status = kill(pid, sig); /* WHAT ?? */
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -273,7 +276,6 @@ Java_org_eclipse_cdt_utils_spawner_Spawner_raise(JNIEnv *env, jobject jobj, jint
|
|||
* Method: waitFor
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor(JNIEnv *env, jobject jobj, jint pid) {
|
||||
return wait0(pid);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor(JNIEnv *env, jobject jobj, jint pid) {
|
||||
return wait0(pid);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -47,7 +47,7 @@ typedef struct winpty_s winpty_t;
|
|||
*
|
||||
* This function creates a new agent process and connects to it.
|
||||
*/
|
||||
WINPTY_API winpty_t* winpty_open(int cols, int rows);
|
||||
WINPTY_API winpty_t *winpty_open(int cols, int rows);
|
||||
|
||||
/*
|
||||
* Start a child process. Either (but not both) of appname and cmdline may
|
||||
|
@ -63,7 +63,7 @@ WINPTY_API winpty_t* winpty_open(int cols, int rows);
|
|||
* Returns 0 on success or a Win32 error code on failure.
|
||||
*/
|
||||
WINPTY_API int winpty_start_process(winpty_t *pc, const wchar_t *appname, const wchar_t *cmdline, const wchar_t *cwd,
|
||||
const wchar_t *env);
|
||||
const wchar_t *env);
|
||||
|
||||
/*
|
||||
* Returns the exit code of the process started with winpty_start_process,
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* raise.c
|
||||
*
|
||||
* This is a part of JNI implementation of spawner
|
||||
* This is a part of JNI implementation of spawner
|
||||
* Includes implementation of JNI methods (see Spawner.java)
|
||||
*******************************************************************************/
|
||||
#include <string.h>
|
||||
|
@ -27,222 +27,224 @@
|
|||
|
||||
void ThrowByName(JNIEnv *env, const char *name, const char *msg);
|
||||
|
||||
#define BUFF_SIZE (1024)
|
||||
#define BUFF_SIZE (1024)
|
||||
|
||||
static HANDLE channelToHandle(JNIEnv *env, jobject channel) {
|
||||
if (channel == 0) {
|
||||
ThrowByName(env, "java/io/IOException", "Invalid channel object");
|
||||
return NULL;
|
||||
}
|
||||
if (channel == 0) {
|
||||
ThrowByName(env, "java/io/IOException", "Invalid channel object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jclass cls = (*env)->GetObjectClass(env, channel);
|
||||
if (cls == NULL) {
|
||||
ThrowByName(env, "java/io/IOException", "Unable to get channel class");
|
||||
return NULL;
|
||||
}
|
||||
jclass cls = (*env)->GetObjectClass(env, channel);
|
||||
if (cls == NULL) {
|
||||
ThrowByName(env, "java/io/IOException", "Unable to get channel class");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jfieldID fid = (*env)->GetFieldID(env, cls, "handle", "J");
|
||||
if (fid == NULL) {
|
||||
ThrowByName(env, "java/io/IOException", "Unable to find handle");
|
||||
return NULL;
|
||||
}
|
||||
jfieldID fid = (*env)->GetFieldID(env, cls, "handle", "J");
|
||||
if (fid == NULL) {
|
||||
ThrowByName(env, "java/io/IOException", "Unable to find handle");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jlong handle = (*env)->GetLongField(env, channel, fid);
|
||||
return (HANDLE) handle;
|
||||
jlong handle = (*env)->GetLongField(env, channel, fid);
|
||||
return (HANDLE)handle;
|
||||
}
|
||||
|
||||
/* Inaccessible static: skipBuffer */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0(JNIEnv *env, jobject proc,
|
||||
jobject channel, jbyteArray buf, jint len) {
|
||||
jbyte tmpBuf[BUFF_SIZE];
|
||||
int nBuffOffset = 0;
|
||||
HANDLE handle = channelToHandle(env, channel);
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0(JNIEnv *env, jobject proc, jobject channel,
|
||||
jbyteArray buf, jint len) {
|
||||
jbyte tmpBuf[BUFF_SIZE];
|
||||
int nBuffOffset = 0;
|
||||
HANDLE handle = channelToHandle(env, channel);
|
||||
#ifdef DEBUG_MONITOR
|
||||
_TCHAR buffer[1000];
|
||||
_TCHAR buffer[1000];
|
||||
#endif
|
||||
OVERLAPPED overlapped;
|
||||
overlapped.Offset = 0;
|
||||
overlapped.OffsetHigh = 0;
|
||||
overlapped.hEvent = CreateEvent(NULL, // no security attribute
|
||||
TRUE, // manual-reset event
|
||||
TRUE, // initial state = signaled
|
||||
NULL); // unnamed event object
|
||||
OVERLAPPED overlapped;
|
||||
overlapped.Offset = 0;
|
||||
overlapped.OffsetHigh = 0;
|
||||
overlapped.hEvent = CreateEvent(NULL, // no security attribute
|
||||
TRUE, // manual-reset event
|
||||
TRUE, // initial state = signaled
|
||||
NULL); // unnamed event object
|
||||
|
||||
if (NULL == overlapped.hEvent) {
|
||||
char *lpMsgBuf;
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
|
||||
GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(wchar_t*) &lpMsgBuf, 0, NULL);
|
||||
if (NULL == overlapped.hEvent) {
|
||||
char *lpMsgBuf;
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
|
||||
GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(wchar_t *)&lpMsgBuf, 0, NULL);
|
||||
|
||||
ThrowByName(env, "java/io/IOException", lpMsgBuf);
|
||||
// Free the buffer.
|
||||
LocalFree(lpMsgBuf);
|
||||
}
|
||||
ThrowByName(env, "java/io/IOException", lpMsgBuf);
|
||||
// Free the buffer.
|
||||
LocalFree(lpMsgBuf);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_MONITOR
|
||||
#ifdef READ_REPORT
|
||||
_stprintf(buffer, _T("Start read %i\n"), fd);
|
||||
OutputDebugStringW(buffer);
|
||||
_stprintf(buffer, _T("Start read %i\n"), fd);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
while (len > nBuffOffset) {
|
||||
DWORD nNumberOfBytesToRead = min(len - nBuffOffset, BUFF_SIZE);
|
||||
DWORD nNumberOfBytesRead;
|
||||
if (0 == ReadFile(handle, tmpBuf, nNumberOfBytesToRead, &nNumberOfBytesRead, &overlapped)) {
|
||||
int err = GetLastError();
|
||||
while (len > nBuffOffset) {
|
||||
DWORD nNumberOfBytesToRead = min(len - nBuffOffset, BUFF_SIZE);
|
||||
DWORD nNumberOfBytesRead;
|
||||
if (0 == ReadFile(handle, tmpBuf, nNumberOfBytesToRead, &nNumberOfBytesRead, &overlapped)) {
|
||||
int err = GetLastError();
|
||||
|
||||
if (err == ERROR_IO_PENDING) {
|
||||
// asynchronous i/o is still in progress
|
||||
// check on the results of the asynchronous read
|
||||
if (GetOverlappedResult(handle, &overlapped, &nNumberOfBytesRead, TRUE)) {
|
||||
err = 0;
|
||||
} else { // if there was a problem ...
|
||||
err = GetLastError();
|
||||
}
|
||||
}
|
||||
if (err == ERROR_BROKEN_PIPE) { // Pipe was closed
|
||||
break;
|
||||
}
|
||||
if (err != 0) {
|
||||
char *lpMsgBuf;
|
||||
if (err == ERROR_IO_PENDING) {
|
||||
// asynchronous i/o is still in progress
|
||||
// check on the results of the asynchronous read
|
||||
if (GetOverlappedResult(handle, &overlapped, &nNumberOfBytesRead, TRUE)) {
|
||||
err = 0;
|
||||
} else { // if there was a problem ...
|
||||
err = GetLastError();
|
||||
}
|
||||
}
|
||||
if (err == ERROR_BROKEN_PIPE) { // Pipe was closed
|
||||
break;
|
||||
}
|
||||
if (err != 0) {
|
||||
char *lpMsgBuf;
|
||||
#ifdef DEBUG_MONITOR
|
||||
_stprintf(buffer, _T("Read failed - %i, error %i\n"), fd, err);
|
||||
OutputDebugStringW(buffer);
|
||||
_stprintf(buffer, _T("Read failed - %i, error %i\n"), fd, err);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
if (err != ERROR_MORE_DATA) { // Otherwise error means just that there are more data than buffer can accept
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(wchar_t*) &lpMsgBuf, 0, NULL);
|
||||
if (err !=
|
||||
ERROR_MORE_DATA) { // Otherwise error means just that there are more data than buffer can accept
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(wchar_t *)&lpMsgBuf, 0, NULL);
|
||||
|
||||
ThrowByName(env, "java/io/IOException", lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
nBuffOffset = 0;
|
||||
break;
|
||||
} else {
|
||||
// buffer overflow?
|
||||
// according to msdn this happens in message read mode only
|
||||
ThrowByName(env, "java/io/IOException", lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
nBuffOffset = 0;
|
||||
break;
|
||||
} else {
|
||||
// buffer overflow?
|
||||
// according to msdn this happens in message read mode only
|
||||
#ifdef DEBUG_MONITOR
|
||||
_stprintf(buffer, _T("Buffer full - %i, bytes read: %i\n"), fd, nNumberOfBytesRead);
|
||||
OutputDebugStringW(buffer);
|
||||
_stprintf(buffer, _T("Buffer full - %i, bytes read: %i\n"), fd, nNumberOfBytesRead);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
// nNumberOfBytesRead can be 0 here for unknown reason (bug 269223)
|
||||
nNumberOfBytesRead = nNumberOfBytesToRead;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nNumberOfBytesRead > 0) {
|
||||
(*env)->SetByteArrayRegion(env, buf, nBuffOffset, nNumberOfBytesRead, tmpBuf);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
nBuffOffset += nNumberOfBytesRead;
|
||||
if (nNumberOfBytesRead != nNumberOfBytesToRead) {
|
||||
break;
|
||||
} else {
|
||||
// Is there data left in the pipe?
|
||||
DWORD bytesAvailable = 0;
|
||||
if (!PeekNamedPipe(handle, NULL, 0, NULL, &bytesAvailable, NULL) || bytesAvailable == 0) {
|
||||
// No bytes left
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
CloseHandle(overlapped.hEvent);
|
||||
// nNumberOfBytesRead can be 0 here for unknown reason (bug 269223)
|
||||
nNumberOfBytesRead = nNumberOfBytesToRead;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nNumberOfBytesRead > 0) {
|
||||
(*env)->SetByteArrayRegion(env, buf, nBuffOffset, nNumberOfBytesRead, tmpBuf);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
nBuffOffset += nNumberOfBytesRead;
|
||||
if (nNumberOfBytesRead != nNumberOfBytesToRead) {
|
||||
break;
|
||||
} else {
|
||||
// Is there data left in the pipe?
|
||||
DWORD bytesAvailable = 0;
|
||||
if (!PeekNamedPipe(handle, NULL, 0, NULL, &bytesAvailable, NULL) || bytesAvailable == 0) {
|
||||
// No bytes left
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
CloseHandle(overlapped.hEvent);
|
||||
#ifdef DEBUG_MONITOR
|
||||
#ifdef READ_REPORT
|
||||
_stprintf(buffer, _T("End read %i - bytes read: %d\n"), fd, nBuffOffset);
|
||||
OutputDebugStringW(buffer);
|
||||
_stprintf(buffer, _T("End read %i - bytes read: %d\n"), fd, nBuffOffset);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
#endif
|
||||
return nBuffOffset; // This is a real full readed length
|
||||
|
||||
return nBuffOffset; // This is a real full readed length
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0(JNIEnv *env, jobject proc,
|
||||
jobject channel) {
|
||||
int rc;
|
||||
HANDLE handle = channelToHandle(env, channel);
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0(JNIEnv *env, jobject proc, jobject channel) {
|
||||
int rc;
|
||||
HANDLE handle = channelToHandle(env, channel);
|
||||
#ifdef DEBUG_MONITOR
|
||||
_TCHAR buffer[1000];
|
||||
_stprintf(buffer, _T("Close %i\n"), fd);
|
||||
OutputDebugStringW(buffer);
|
||||
_TCHAR buffer[1000];
|
||||
_stprintf(buffer, _T("Close %i\n"), fd);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
rc = (CloseHandle(handle) ? 0 : -1);
|
||||
rc = (CloseHandle(handle) ? 0 : -1);
|
||||
#ifdef DEBUG_MONITOR
|
||||
_stprintf(buffer, _T("Closed %i\n"), fd);
|
||||
OutputDebugStringW(buffer);
|
||||
_stprintf(buffer, _T("Closed %i\n"), fd);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
return (rc ? GetLastError() : 0);
|
||||
return (rc ? GetLastError() : 0);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_available0(JNIEnv *env, jobject proc,
|
||||
jobject channel) {
|
||||
DWORD nAvail = 0;
|
||||
HANDLE handle = channelToHandle(env, channel);
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_available0(JNIEnv *env, jobject proc, jobject channel) {
|
||||
DWORD nAvail = 0;
|
||||
HANDLE handle = channelToHandle(env, channel);
|
||||
|
||||
if (0 == PeekNamedPipe(handle, NULL, 0, NULL, &nAvail, NULL)) {
|
||||
// error
|
||||
return 0;
|
||||
}
|
||||
return nAvail;
|
||||
if (0 == PeekNamedPipe(handle, NULL, 0, NULL, &nAvail, NULL)) {
|
||||
// error
|
||||
return 0;
|
||||
}
|
||||
return nAvail;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0(JNIEnv *env, jobject proc,
|
||||
jobject channel, jbyteArray buf, jint len) {
|
||||
jbyte tmpBuf[BUFF_SIZE];
|
||||
int nBuffOffset = 0;
|
||||
HANDLE handle = channelToHandle(env, channel);
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0(JNIEnv *env, jobject proc, jobject channel,
|
||||
jbyteArray buf, jint len) {
|
||||
jbyte tmpBuf[BUFF_SIZE];
|
||||
int nBuffOffset = 0;
|
||||
HANDLE handle = channelToHandle(env, channel);
|
||||
|
||||
while (len > nBuffOffset) {
|
||||
DWORD nNumberOfBytesToWrite = min(len - nBuffOffset, BUFF_SIZE);
|
||||
DWORD nNumberOfBytesWritten;
|
||||
(*env)->GetByteArrayRegion(env, buf, nBuffOffset, nNumberOfBytesToWrite, tmpBuf);
|
||||
if (0 == WriteFile(handle, tmpBuf, nNumberOfBytesToWrite, &nNumberOfBytesWritten, NULL)) {
|
||||
char *lpMsgBuf;
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(wchar_t*) &lpMsgBuf, 0, NULL);
|
||||
while (len > nBuffOffset) {
|
||||
DWORD nNumberOfBytesToWrite = min(len - nBuffOffset, BUFF_SIZE);
|
||||
DWORD nNumberOfBytesWritten;
|
||||
(*env)->GetByteArrayRegion(env, buf, nBuffOffset, nNumberOfBytesToWrite, tmpBuf);
|
||||
if (0 == WriteFile(handle, tmpBuf, nNumberOfBytesToWrite, &nNumberOfBytesWritten, NULL)) {
|
||||
char *lpMsgBuf;
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(wchar_t *)&lpMsgBuf, 0, NULL);
|
||||
|
||||
ThrowByName(env, "java/io/IOException", lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
return 0;
|
||||
}
|
||||
nBuffOffset += nNumberOfBytesWritten;
|
||||
}
|
||||
return 0;
|
||||
ThrowByName(env, "java/io/IOException", lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
return 0;
|
||||
}
|
||||
nBuffOffset += nNumberOfBytesWritten;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0(JNIEnv *env, jobject proc,
|
||||
jobject channel) {
|
||||
int rc;
|
||||
HANDLE handle = channelToHandle(env, channel);
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0(JNIEnv *env, jobject proc, jobject channel) {
|
||||
int rc;
|
||||
HANDLE handle = channelToHandle(env, channel);
|
||||
#ifdef DEBUG_MONITOR
|
||||
_TCHAR buffer[1000];
|
||||
_stprintf(buffer, _T("Close %i\n"), fd);
|
||||
OutputDebugStringW(buffer);
|
||||
_TCHAR buffer[1000];
|
||||
_stprintf(buffer, _T("Close %i\n"), fd);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
FlushFileBuffers(handle);
|
||||
rc = (CloseHandle(handle) ? 0 : -1);
|
||||
FlushFileBuffers(handle);
|
||||
rc = (CloseHandle(handle) ? 0 : -1);
|
||||
#ifdef DEBUG_MONITOR
|
||||
_stprintf(buffer, _T("Closed %i\n"), fd);
|
||||
OutputDebugStringW(buffer);
|
||||
_stprintf(buffer, _T("Closed %i\n"), fd);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
return (rc ? GetLastError() : 0);
|
||||
return (rc ? GetLastError() : 0);
|
||||
}
|
||||
|
|
|
@ -24,358 +24,360 @@
|
|||
#include <assert.h>
|
||||
#include <ctime>
|
||||
|
||||
static std::map<int, winpty_t*> fd2pty;
|
||||
static std::map<int, winpty_t *> fd2pty;
|
||||
static std::map<int, int> fd2rc;
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster(JNIEnv *env, jobject jobj, jboolean console) {
|
||||
jfieldID fid; /* Store the field ID */
|
||||
jstring jstr = NULL;
|
||||
jclass cls;
|
||||
jfieldID fid; /* Store the field ID */
|
||||
jstring jstr = NULL;
|
||||
jclass cls;
|
||||
|
||||
int master = -1;
|
||||
char line[1024];
|
||||
int master = -1;
|
||||
char line[1024];
|
||||
|
||||
line[0] = '\0';
|
||||
line[0] = '\0';
|
||||
|
||||
/* Open new winpty handle */
|
||||
winpty_t *winpty = winpty_open(80, 40);
|
||||
if (winpty == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
/* Open new winpty handle */
|
||||
winpty_t *winpty = winpty_open(80, 40);
|
||||
if (winpty == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Configure console mode */
|
||||
if (console) {
|
||||
winpty_set_console_mode(winpty, 1);
|
||||
}
|
||||
/* Configure console mode */
|
||||
if (console) {
|
||||
winpty_set_console_mode(winpty, 1);
|
||||
}
|
||||
|
||||
/* Generate masterFD based on current system time */
|
||||
srand((unsigned int) time(NULL));
|
||||
master = rand();
|
||||
/* Generate masterFD based on current system time */
|
||||
srand((unsigned int)time(NULL));
|
||||
master = rand();
|
||||
|
||||
/* Make sure masterFD does not exist */
|
||||
while (fd2pty.find(master) != fd2pty.end()) {
|
||||
master++;
|
||||
}
|
||||
/* Make sure masterFD does not exist */
|
||||
while (fd2pty.find(master) != fd2pty.end()) {
|
||||
master++;
|
||||
}
|
||||
|
||||
sprintf(line, "winpty_%i", master);
|
||||
sprintf(line, "winpty_%i", master);
|
||||
|
||||
/* Remember the winpty handle for the generated masterFD */
|
||||
fd2pty.insert(std::pair<int, winpty_t*>(master, winpty));
|
||||
/* Remember the winpty handle for the generated masterFD */
|
||||
fd2pty.insert(std::pair<int, winpty_t *>(master, winpty));
|
||||
|
||||
/* Get a reference to the obj's class */
|
||||
cls = env->GetObjectClass(jobj);
|
||||
/* Get a reference to the obj's class */
|
||||
cls = env->GetObjectClass(jobj);
|
||||
|
||||
/* Set the master fd. */
|
||||
fid = env->GetFieldID(cls, "master", "I");
|
||||
if (fid == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
env->SetIntField(jobj, fid, (jint) master);
|
||||
/* Set the master fd. */
|
||||
fid = env->GetFieldID(cls, "master", "I");
|
||||
if (fid == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
env->SetIntField(jobj, fid, (jint)master);
|
||||
|
||||
/* Create a new String for the slave. */
|
||||
jstr = env->NewStringUTF(line);
|
||||
/* Create a new String for the slave. */
|
||||
jstr = env->NewStringUTF(line);
|
||||
|
||||
return jstr;
|
||||
return jstr;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size(JNIEnv *env, jobject jobj, jint fdm,
|
||||
jint width, jint height) {
|
||||
int fd;
|
||||
std::map<int, winpty_t*>::const_iterator fd2pty_Iter;
|
||||
jint width, jint height) {
|
||||
int fd;
|
||||
std::map<int, winpty_t *>::const_iterator fd2pty_Iter;
|
||||
|
||||
fd = fdm;
|
||||
fd2pty_Iter = fd2pty.find(fd);
|
||||
if (fd2pty_Iter != fd2pty.end()) {
|
||||
winpty_t *winpty = fd2pty_Iter->second;
|
||||
if (winpty != NULL) {
|
||||
return winpty_set_size(winpty, width, height);
|
||||
}
|
||||
}
|
||||
fd = fdm;
|
||||
fd2pty_Iter = fd2pty.find(fd);
|
||||
if (fd2pty_Iter != fd2pty.end()) {
|
||||
winpty_t *winpty = fd2pty_Iter->second;
|
||||
if (winpty != NULL) {
|
||||
return winpty_set_size(winpty, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv *env, jobject jobj, jint jfd,
|
||||
jbyteArray buf, jint buf_len) {
|
||||
DWORD amount = -1;
|
||||
OVERLAPPED over;
|
||||
int fd;
|
||||
std::map<int, winpty_t*>::const_iterator fd2pty_Iter;
|
||||
jbyteArray buf, jint buf_len) {
|
||||
DWORD amount = -1;
|
||||
OVERLAPPED over;
|
||||
int fd;
|
||||
std::map<int, winpty_t *>::const_iterator fd2pty_Iter;
|
||||
|
||||
fd = jfd;
|
||||
fd2pty_Iter = fd2pty.find(fd);
|
||||
if (fd2pty_Iter != fd2pty.end()) {
|
||||
winpty_t *winpty = fd2pty_Iter->second;
|
||||
if (winpty != NULL) {
|
||||
/* Get the pipe handle */
|
||||
HANDLE handle = winpty_get_data_pipe(winpty);
|
||||
fd = jfd;
|
||||
fd2pty_Iter = fd2pty.find(fd);
|
||||
if (fd2pty_Iter != fd2pty.end()) {
|
||||
winpty_t *winpty = fd2pty_Iter->second;
|
||||
if (winpty != NULL) {
|
||||
/* Get the pipe handle */
|
||||
HANDLE handle = winpty_get_data_pipe(winpty);
|
||||
|
||||
memset(&over, 0, sizeof(over));
|
||||
over.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
memset(&over, 0, sizeof(over));
|
||||
over.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
|
||||
char *buffer = new char[buf_len];
|
||||
memset(buffer, 0, sizeof(*buffer));
|
||||
char *buffer = new char[buf_len];
|
||||
memset(buffer, 0, sizeof(*buffer));
|
||||
|
||||
jbyte *data = env->GetByteArrayElements(buf, 0);
|
||||
memset(data, 0, sizeof(*data));
|
||||
jbyte *data = env->GetByteArrayElements(buf, 0);
|
||||
memset(data, 0, sizeof(*data));
|
||||
|
||||
amount = 0;
|
||||
BOOL ret = ReadFile(handle, buffer, buf_len, &amount, &over);
|
||||
if (!ret) {
|
||||
DWORD error = GetLastError();
|
||||
if (error == ERROR_IO_PENDING) {
|
||||
ret = GetOverlappedResult(handle, &over, &amount, TRUE);
|
||||
}
|
||||
}
|
||||
amount = 0;
|
||||
BOOL ret = ReadFile(handle, buffer, buf_len, &amount, &over);
|
||||
if (!ret) {
|
||||
DWORD error = GetLastError();
|
||||
if (error == ERROR_IO_PENDING) {
|
||||
ret = GetOverlappedResult(handle, &over, &amount, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret && amount > 0) {
|
||||
memcpy(data, buffer, amount);
|
||||
}
|
||||
if (ret && amount > 0) {
|
||||
memcpy(data, buffer, amount);
|
||||
}
|
||||
|
||||
if (!ret || amount == 0) {
|
||||
amount = -1;
|
||||
}
|
||||
if (!ret || amount == 0) {
|
||||
amount = -1;
|
||||
}
|
||||
|
||||
if (!ret && fd2pty.find(fd) != fd2pty.end()) {
|
||||
int rc = winpty_get_exit_code(winpty);
|
||||
fd2rc.insert(std::pair<int, int>(fd, rc));
|
||||
}
|
||||
if (!ret && fd2pty.find(fd) != fd2pty.end()) {
|
||||
int rc = winpty_get_exit_code(winpty);
|
||||
fd2rc.insert(std::pair<int, int>(fd, rc));
|
||||
}
|
||||
|
||||
delete[] buffer;
|
||||
env->ReleaseByteArrayElements(buf, data, 0);
|
||||
ResetEvent(over.hEvent);
|
||||
}
|
||||
}
|
||||
delete[] buffer;
|
||||
env->ReleaseByteArrayElements(buf, data, 0);
|
||||
ResetEvent(over.hEvent);
|
||||
}
|
||||
}
|
||||
|
||||
return amount;
|
||||
return amount;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0(JNIEnv *env, jobject jobj, jint jfd) {
|
||||
int fd;
|
||||
std::map<int, winpty_t*>::iterator fd2pty_Iter;
|
||||
int fd;
|
||||
std::map<int, winpty_t *>::iterator fd2pty_Iter;
|
||||
|
||||
fd = jfd;
|
||||
fd2pty_Iter = fd2pty.find(fd);
|
||||
if (fd2pty_Iter != fd2pty.end()) {
|
||||
winpty_t *winpty = fd2pty_Iter->second;
|
||||
fd2pty.erase(fd2pty_Iter);
|
||||
if (winpty != NULL) {
|
||||
winpty_close(winpty);
|
||||
winpty = NULL;
|
||||
}
|
||||
}
|
||||
fd = jfd;
|
||||
fd2pty_Iter = fd2pty.find(fd);
|
||||
if (fd2pty_Iter != fd2pty.end()) {
|
||||
winpty_t *winpty = fd2pty_Iter->second;
|
||||
fd2pty.erase(fd2pty_Iter);
|
||||
if (winpty != NULL) {
|
||||
winpty_close(winpty);
|
||||
winpty = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0(JNIEnv *env, jobject jobj, jint jfd,
|
||||
jbyteArray buf, jint buf_len) {
|
||||
DWORD written = -1;
|
||||
OVERLAPPED over;
|
||||
int fd;
|
||||
std::map<int, winpty_t*>::iterator fd2pty_Iter;
|
||||
jbyteArray buf, jint buf_len) {
|
||||
DWORD written = -1;
|
||||
OVERLAPPED over;
|
||||
int fd;
|
||||
std::map<int, winpty_t *>::iterator fd2pty_Iter;
|
||||
|
||||
fd = jfd;
|
||||
fd2pty_Iter = fd2pty.find(fd);
|
||||
if (fd2pty_Iter != fd2pty.end()) {
|
||||
winpty_t *winpty = fd2pty_Iter->second;
|
||||
if (winpty != NULL) {
|
||||
/* Get the pipe handle */
|
||||
HANDLE handle = winpty_get_data_pipe(winpty);
|
||||
fd = jfd;
|
||||
fd2pty_Iter = fd2pty.find(fd);
|
||||
if (fd2pty_Iter != fd2pty.end()) {
|
||||
winpty_t *winpty = fd2pty_Iter->second;
|
||||
if (winpty != NULL) {
|
||||
/* Get the pipe handle */
|
||||
HANDLE handle = winpty_get_data_pipe(winpty);
|
||||
|
||||
memset(&over, 0, sizeof(over));
|
||||
over.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
memset(&over, 0, sizeof(over));
|
||||
over.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
|
||||
char *buffer = new char[buf_len];
|
||||
memset(buffer, 0, sizeof(*buffer));
|
||||
char *buffer = new char[buf_len];
|
||||
memset(buffer, 0, sizeof(*buffer));
|
||||
|
||||
jbyte *data = env->GetByteArrayElements(buf, 0);
|
||||
memcpy(buffer, data, buf_len);
|
||||
jbyte *data = env->GetByteArrayElements(buf, 0);
|
||||
memcpy(buffer, data, buf_len);
|
||||
|
||||
BOOL ret = WriteFile(handle, buffer, buf_len, &written, &over);
|
||||
env->ReleaseByteArrayElements(buf, data, 0);
|
||||
BOOL ret = WriteFile(handle, buffer, buf_len, &written, &over);
|
||||
env->ReleaseByteArrayElements(buf, data, 0);
|
||||
|
||||
if (!ret && GetLastError() == ERROR_IO_PENDING) {
|
||||
ret = GetOverlappedResult(handle, &over, &written, TRUE);
|
||||
}
|
||||
if (!ret || (int) written != buf_len) {
|
||||
written = -1;
|
||||
}
|
||||
if (!ret && GetLastError() == ERROR_IO_PENDING) {
|
||||
ret = GetOverlappedResult(handle, &over, &written, TRUE);
|
||||
}
|
||||
if (!ret || (int)written != buf_len) {
|
||||
written = -1;
|
||||
}
|
||||
|
||||
delete[] buffer;
|
||||
}
|
||||
}
|
||||
delete[] buffer;
|
||||
}
|
||||
}
|
||||
|
||||
return written;
|
||||
return written;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0(JNIEnv *env, jobject jobj, jint jfd) {
|
||||
int fd;
|
||||
std::map<int, winpty_t*>::iterator fd2pty_Iter;
|
||||
int fd;
|
||||
std::map<int, winpty_t *>::iterator fd2pty_Iter;
|
||||
|
||||
fd = jfd;
|
||||
fd2pty_Iter = fd2pty.find(fd);
|
||||
if (fd2pty_Iter != fd2pty.end()) {
|
||||
winpty_t *winpty = fd2pty_Iter->second;
|
||||
fd2pty.erase(fd2pty_Iter);
|
||||
if (winpty != NULL) {
|
||||
winpty_close(winpty);
|
||||
winpty = NULL;
|
||||
}
|
||||
}
|
||||
fd = jfd;
|
||||
fd2pty_Iter = fd2pty.find(fd);
|
||||
if (fd2pty_Iter != fd2pty.end()) {
|
||||
winpty_t *winpty = fd2pty_Iter->second;
|
||||
fd2pty.erase(fd2pty_Iter);
|
||||
if (winpty != NULL) {
|
||||
winpty_close(winpty);
|
||||
winpty = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert convert slashes to backslashes.
|
||||
*/
|
||||
static std::wstring convertSlashes(const wchar_t *path) {
|
||||
std::wstring ret;
|
||||
std::wstring ret;
|
||||
|
||||
for (int i = 0; path[i] != L'\0'; ++i) {
|
||||
if (path[i] == L'/') {
|
||||
ret.push_back(L'\\');
|
||||
} else {
|
||||
ret.push_back(path[i]);
|
||||
}
|
||||
}
|
||||
for (int i = 0; path[i] != L'\0'; ++i) {
|
||||
if (path[i] == L'/') {
|
||||
ret.push_back(L'\\');
|
||||
} else {
|
||||
ret.push_back(path[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Convert argc/argv into a Win32 command-line following the escaping convention
|
||||
// documented on MSDN. (e.g. see CommandLineToArgvW documentation)
|
||||
static std::wstring argvToCommandLine(const std::vector<std::wstring> &argv) {
|
||||
std::wstring result;
|
||||
for (size_t argIndex = 0; argIndex < argv.size(); ++argIndex) {
|
||||
if (argIndex > 0) {
|
||||
result.push_back(L' ');
|
||||
}
|
||||
const wchar_t *arg = argv[argIndex].c_str();
|
||||
const bool quote = wcschr(arg, L' ') != NULL || wcschr(arg, L'\t') != NULL || *arg == L'\0';
|
||||
if (quote) {
|
||||
result.push_back(L'\"');
|
||||
}
|
||||
int bsCount = 0;
|
||||
for (const wchar_t *p = arg; *p != L'\0'; ++p) {
|
||||
if (*p == L'\\') {
|
||||
bsCount++;
|
||||
} else if (*p == L'\"') {
|
||||
result.append(bsCount * 2 + 1, L'\\');
|
||||
result.push_back(L'\"');
|
||||
bsCount = 0;
|
||||
} else {
|
||||
result.append(bsCount, L'\\');
|
||||
bsCount = 0;
|
||||
result.push_back(*p);
|
||||
}
|
||||
}
|
||||
if (quote) {
|
||||
result.append(bsCount * 2, L'\\');
|
||||
result.push_back(L'\"');
|
||||
} else {
|
||||
result.append(bsCount, L'\\');
|
||||
}
|
||||
}
|
||||
return result;
|
||||
std::wstring result;
|
||||
for (size_t argIndex = 0; argIndex < argv.size(); ++argIndex) {
|
||||
if (argIndex > 0) {
|
||||
result.push_back(L' ');
|
||||
}
|
||||
const wchar_t *arg = argv[argIndex].c_str();
|
||||
const bool quote = wcschr(arg, L' ') != NULL || wcschr(arg, L'\t') != NULL || *arg == L'\0';
|
||||
if (quote) {
|
||||
result.push_back(L'\"');
|
||||
}
|
||||
int bsCount = 0;
|
||||
for (const wchar_t *p = arg; *p != L'\0'; ++p) {
|
||||
if (*p == L'\\') {
|
||||
bsCount++;
|
||||
} else if (*p == L'\"') {
|
||||
result.append(bsCount * 2 + 1, L'\\');
|
||||
result.push_back(L'\"');
|
||||
bsCount = 0;
|
||||
} else {
|
||||
result.append(bsCount, L'\\');
|
||||
bsCount = 0;
|
||||
result.push_back(*p);
|
||||
}
|
||||
}
|
||||
if (quote) {
|
||||
result.append(bsCount * 2, L'\\');
|
||||
result.push_back(L'\"');
|
||||
} else {
|
||||
result.append(bsCount, L'\\');
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_exec2(JNIEnv *env, jobject jobj, jobjectArray jcmd,
|
||||
jobjectArray jenv, jstring jdir, jobjectArray jchannels, jstring jslaveName, jint masterFD, jboolean console) {
|
||||
int fd;
|
||||
std::map<int, winpty_t*>::iterator fd2pty_Iter;
|
||||
jobjectArray jenv, jstring jdir, jobjectArray jchannels,
|
||||
jstring jslaveName, jint masterFD, jboolean console) {
|
||||
int fd;
|
||||
std::map<int, winpty_t *>::iterator fd2pty_Iter;
|
||||
|
||||
const wchar_t *cwdW = (const wchar_t*) env->GetStringChars(jdir, NULL);
|
||||
const char *pts_name = env->GetStringUTFChars(jslaveName, NULL);
|
||||
const wchar_t *cwdW = (const wchar_t *)env->GetStringChars(jdir, NULL);
|
||||
const char *pts_name = env->GetStringUTFChars(jslaveName, NULL);
|
||||
|
||||
int pid = -1;
|
||||
int pid = -1;
|
||||
|
||||
int i;
|
||||
jint argc = env->GetArrayLength(jcmd);
|
||||
jint envc = env->GetArrayLength(jenv);
|
||||
int i;
|
||||
jint argc = env->GetArrayLength(jcmd);
|
||||
jint envc = env->GetArrayLength(jenv);
|
||||
|
||||
if (jchannels == NULL || env->GetArrayLength(jchannels) != 3) {
|
||||
goto bail_out;
|
||||
}
|
||||
if (jchannels == NULL || env->GetArrayLength(jchannels) != 3) {
|
||||
goto bail_out;
|
||||
}
|
||||
|
||||
fd = masterFD;
|
||||
fd2pty_Iter = fd2pty.find(fd);
|
||||
if (fd2pty_Iter != fd2pty.end()) {
|
||||
winpty_t *winpty = fd2pty_Iter->second;
|
||||
if (winpty != NULL) {
|
||||
std::vector < std::wstring > argVector;
|
||||
fd = masterFD;
|
||||
fd2pty_Iter = fd2pty.find(fd);
|
||||
if (fd2pty_Iter != fd2pty.end()) {
|
||||
winpty_t *winpty = fd2pty_Iter->second;
|
||||
if (winpty != NULL) {
|
||||
std::vector<std::wstring> argVector;
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
jstring j_str = (jstring) env->GetObjectArrayElement(jcmd, i);
|
||||
const wchar_t *w_str = (const wchar_t*) env->GetStringChars(j_str, NULL);
|
||||
if (i == 0) {
|
||||
argVector.push_back(convertSlashes(w_str));
|
||||
} else {
|
||||
argVector.push_back(w_str);
|
||||
}
|
||||
env->ReleaseStringChars(j_str, (const jchar*) w_str);
|
||||
env->DeleteLocalRef(j_str);
|
||||
}
|
||||
for (i = 0; i < argc; i++) {
|
||||
jstring j_str = (jstring)env->GetObjectArrayElement(jcmd, i);
|
||||
const wchar_t *w_str = (const wchar_t *)env->GetStringChars(j_str, NULL);
|
||||
if (i == 0) {
|
||||
argVector.push_back(convertSlashes(w_str));
|
||||
} else {
|
||||
argVector.push_back(w_str);
|
||||
}
|
||||
env->ReleaseStringChars(j_str, (const jchar *)w_str);
|
||||
env->DeleteLocalRef(j_str);
|
||||
}
|
||||
|
||||
std::wstring envp;
|
||||
std::wstring envp;
|
||||
|
||||
for (i = 0; i < envc; i++) {
|
||||
jstring j_str = (jstring) env->GetObjectArrayElement(jenv, i);
|
||||
const wchar_t *w_str = (const wchar_t*) env->GetStringChars(j_str, NULL);
|
||||
envp.append(w_str);
|
||||
envp.push_back(L'\0');
|
||||
env->ReleaseStringChars(j_str, (const jchar*) w_str);
|
||||
env->DeleteLocalRef(j_str);
|
||||
}
|
||||
for (i = 0; i < envc; i++) {
|
||||
jstring j_str = (jstring)env->GetObjectArrayElement(jenv, i);
|
||||
const wchar_t *w_str = (const wchar_t *)env->GetStringChars(j_str, NULL);
|
||||
envp.append(w_str);
|
||||
envp.push_back(L'\0');
|
||||
env->ReleaseStringChars(j_str, (const jchar *)w_str);
|
||||
env->DeleteLocalRef(j_str);
|
||||
}
|
||||
|
||||
std::wstring cmdLine = argvToCommandLine(argVector);
|
||||
const wchar_t *cmdLineW = cmdLine.c_str();
|
||||
std::wstring cmdLine = argvToCommandLine(argVector);
|
||||
const wchar_t *cmdLineW = cmdLine.c_str();
|
||||
|
||||
int ret = winpty_start_process(winpty, NULL, cmdLineW, cwdW, envp.c_str());
|
||||
int ret = winpty_start_process(winpty, NULL, cmdLineW, cwdW, envp.c_str());
|
||||
|
||||
if (ret == 0) {
|
||||
// Success. Get the process id.
|
||||
pid = winpty_get_process_id(winpty);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ret == 0) {
|
||||
// Success. Get the process id.
|
||||
pid = winpty_get_process_id(winpty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bail_out: env->ReleaseStringChars(jdir, (const jchar*) cwdW);
|
||||
env->ReleaseStringUTFChars(jslaveName, pts_name);
|
||||
bail_out:
|
||||
env->ReleaseStringChars(jdir, (const jchar *)cwdW);
|
||||
env->ReleaseStringUTFChars(jslaveName, pts_name);
|
||||
|
||||
return pid;
|
||||
return pid;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_waitFor(JNIEnv *env, jobject jobj, jint masterFD, jint pid) {
|
||||
int status = -1;
|
||||
DWORD flags;
|
||||
int status = -1;
|
||||
DWORD flags;
|
||||
|
||||
int fd;
|
||||
std::map<int, winpty_t*>::iterator fd2pty_Iter;
|
||||
std::map<int, int>::iterator fd2rc_Iter;
|
||||
int fd;
|
||||
std::map<int, winpty_t *>::iterator fd2pty_Iter;
|
||||
std::map<int, int>::iterator fd2rc_Iter;
|
||||
|
||||
fd = masterFD;
|
||||
fd2pty_Iter = fd2pty.find(fd);
|
||||
if (fd2pty_Iter != fd2pty.end()) {
|
||||
winpty_t *winpty = fd2pty_Iter->second;
|
||||
if (winpty != NULL) {
|
||||
HANDLE handle = winpty_get_data_pipe(winpty);
|
||||
BOOL success;
|
||||
do {
|
||||
success = GetHandleInformation(handle, &flags);
|
||||
if (success) {
|
||||
Sleep(500);
|
||||
}
|
||||
} while (success);
|
||||
fd = masterFD;
|
||||
fd2pty_Iter = fd2pty.find(fd);
|
||||
if (fd2pty_Iter != fd2pty.end()) {
|
||||
winpty_t *winpty = fd2pty_Iter->second;
|
||||
if (winpty != NULL) {
|
||||
HANDLE handle = winpty_get_data_pipe(winpty);
|
||||
BOOL success;
|
||||
do {
|
||||
success = GetHandleInformation(handle, &flags);
|
||||
if (success) {
|
||||
Sleep(500);
|
||||
}
|
||||
} while (success);
|
||||
|
||||
fd2rc_Iter = fd2rc.find(fd);
|
||||
if (fd2rc_Iter != fd2rc.end()) {
|
||||
status = fd2rc_Iter->second;
|
||||
fd2rc.erase(fd2rc_Iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
fd2rc_Iter = fd2rc.find(fd);
|
||||
if (fd2rc_Iter != fd2rc.end()) {
|
||||
status = fd2rc_Iter->second;
|
||||
fd2rc.erase(fd2rc_Iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -4,42 +4,42 @@
|
|||
#include <assert.h>
|
||||
|
||||
static HMODULE getCurrentModule() {
|
||||
HMODULE module;
|
||||
if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
||||
(LPCTSTR) getCurrentModule, &module)) {
|
||||
assert(false);
|
||||
}
|
||||
return module;
|
||||
HMODULE module;
|
||||
if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
||||
(LPCTSTR)getCurrentModule, &module)) {
|
||||
assert(false);
|
||||
}
|
||||
return module;
|
||||
}
|
||||
|
||||
HMODULE PTYExplicitLoadLibrary(LPCSTR pszModuleName) {
|
||||
if (lstrcmpiA(pszModuleName, "winpty.dll") == 0) {
|
||||
CHAR szPath[MAX_PATH] = "";
|
||||
//_hdllInstance is the HMODULE of *this* module
|
||||
DWORD cchPath = GetModuleFileNameA(getCurrentModule(), szPath, MAX_PATH);
|
||||
while (cchPath > 0) {
|
||||
switch (szPath[cchPath - 1]) {
|
||||
case '\\':
|
||||
case '/':
|
||||
case ':':
|
||||
break;
|
||||
default:
|
||||
--cchPath;
|
||||
continue;
|
||||
}
|
||||
break; //stop searching; found path separator
|
||||
}
|
||||
lstrcpynA(szPath + cchPath, pszModuleName, MAX_PATH - cchPath);
|
||||
return LoadLibraryA(szPath); //call with full path to dependent DLL
|
||||
}
|
||||
return NULL;
|
||||
if (lstrcmpiA(pszModuleName, "winpty.dll") == 0) {
|
||||
CHAR szPath[MAX_PATH] = "";
|
||||
//_hdllInstance is the HMODULE of *this* module
|
||||
DWORD cchPath = GetModuleFileNameA(getCurrentModule(), szPath, MAX_PATH);
|
||||
while (cchPath > 0) {
|
||||
switch (szPath[cchPath - 1]) {
|
||||
case '\\':
|
||||
case '/':
|
||||
case ':':
|
||||
break;
|
||||
default:
|
||||
--cchPath;
|
||||
continue;
|
||||
}
|
||||
break; // stop searching; found path separator
|
||||
}
|
||||
lstrcpynA(szPath + cchPath, pszModuleName, MAX_PATH - cchPath);
|
||||
return LoadLibraryA(szPath); // call with full path to dependent DLL
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FARPROC WINAPI PTYDliNotifyHook(unsigned dliNotify, PDelayLoadInfo pdli) {
|
||||
if (dliNotify == dliNotePreLoadLibrary) {
|
||||
return (FARPROC) PTYExplicitLoadLibrary(pdli->szDll);
|
||||
}
|
||||
return NULL;
|
||||
if (dliNotify == dliNotePreLoadLibrary) {
|
||||
return (FARPROC)PTYExplicitLoadLibrary(pdli->szDll);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* raise.c
|
||||
*
|
||||
* This is a part of JNI implementation of spawner
|
||||
* This is a part of JNI implementation of spawner
|
||||
*******************************************************************************/
|
||||
#include <jni.h>
|
||||
#include <windows.h>
|
||||
|
@ -26,40 +26,38 @@ static HWND consoleHWND;
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// Check if window is a console of process with pid
|
||||
// Arguments:
|
||||
// Arguments:
|
||||
// hwnd - window handler
|
||||
// arg - process PID
|
||||
// Return : TRUE if yes
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
static BOOL CALLBACK
|
||||
find_child_console(HWND hwnd, LPARAM arg) {
|
||||
DWORD process_id;
|
||||
DWORD pid = arg;
|
||||
static BOOL CALLBACK find_child_console(HWND hwnd, LPARAM arg) {
|
||||
DWORD process_id;
|
||||
DWORD pid = arg;
|
||||
|
||||
GetWindowThreadProcessId(hwnd, &process_id);
|
||||
if (process_id == pid) {
|
||||
wchar_t window_class[32];
|
||||
GetWindowThreadProcessId(hwnd, &process_id);
|
||||
if (process_id == pid) {
|
||||
wchar_t window_class[32];
|
||||
|
||||
GetClassName(hwnd, window_class, sizeof(window_class));
|
||||
if (wcscmp(window_class, L"ConsoleWindowClass") == 0) {
|
||||
consoleHWND = hwnd;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
/* keep looking */
|
||||
return TRUE;
|
||||
GetClassName(hwnd, window_class, sizeof(window_class));
|
||||
if (wcscmp(window_class, L"ConsoleWindowClass") == 0) {
|
||||
consoleHWND = hwnd;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
/* keep looking */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Need to declare this Win32 prototype ourselves. _WIN32_WINNT is getting
|
||||
// defined to a Windows NT value, thus we don't get this. Can't assume
|
||||
// defined to a Windows NT value, thus we don't get this. Can't assume
|
||||
// we're running on XP, anyway (or can we by now?)
|
||||
#if (_WIN32_WINNT < 0x0501) || defined(_MSC_VER)
|
||||
typedef BOOL(WINAPI *DebugBreakProcessFunc)
|
||||
(HANDLE);
|
||||
typedef BOOL(WINAPI *DebugBreakProcessFunc)(HANDLE);
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// Called to interrupt a process that we didn't launch (and thus does not share our
|
||||
// Called to interrupt a process that we didn't launch (and thus does not share our
|
||||
// console). Windows XP introduced the function 'DebugBreakProcess', which allows
|
||||
// a process to interrupt another process even if if the two do not share a console.
|
||||
// If we're running on 2000 or earlier, we have to resort to simulating a CTRL-C
|
||||
|
@ -67,111 +65,109 @@ typedef BOOL(WINAPI *DebugBreakProcessFunc)
|
|||
// has its own console. That means, e.g., the process should have been started at
|
||||
// the cmdline with 'start myprogram.exe' instead of 'myprogram.exe'.
|
||||
//
|
||||
// Arguments:
|
||||
// Arguments:
|
||||
// pid - process' pid
|
||||
// Return : 0 if OK or error code
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
int interruptProcess(int pid) {
|
||||
// See if DebugBreakProcess is available (XP and beyond)
|
||||
HMODULE hmod = LoadLibrary(L"Kernel32.dll");
|
||||
if (hmod != NULL) {
|
||||
BOOL success = FALSE;
|
||||
FARPROC procaddr = GetProcAddress(hmod, "DebugBreakProcess");
|
||||
if (procaddr != NULL) {
|
||||
HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD) pid);
|
||||
if (proc != NULL) {
|
||||
typedef BOOL WINAPI( *DebugBreakProcessFunc)
|
||||
(HANDLE);
|
||||
DebugBreakProcessFunc pDebugBreakProcess = (DebugBreakProcessFunc) procaddr;
|
||||
success = (*pDebugBreakProcess)(proc);
|
||||
CloseHandle(proc);
|
||||
}
|
||||
}
|
||||
FreeLibrary(hmod);
|
||||
hmod = NULL;
|
||||
// See if DebugBreakProcess is available (XP and beyond)
|
||||
HMODULE hmod = LoadLibrary(L"Kernel32.dll");
|
||||
if (hmod != NULL) {
|
||||
BOOL success = FALSE;
|
||||
FARPROC procaddr = GetProcAddress(hmod, "DebugBreakProcess");
|
||||
if (procaddr != NULL) {
|
||||
HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid);
|
||||
if (proc != NULL) {
|
||||
typedef BOOL WINAPI (*DebugBreakProcessFunc)(HANDLE);
|
||||
DebugBreakProcessFunc pDebugBreakProcess = (DebugBreakProcessFunc)procaddr;
|
||||
success = (*pDebugBreakProcess)(proc);
|
||||
CloseHandle(proc);
|
||||
}
|
||||
}
|
||||
FreeLibrary(hmod);
|
||||
hmod = NULL;
|
||||
|
||||
if (success) {
|
||||
return 0; // 0 == OK; if not, try old-school way
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
return 0; // 0 == OK; if not, try old-school way
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_MONITOR
|
||||
_TCHAR buffer[1000];
|
||||
#endif
|
||||
int rc = 0;
|
||||
consoleHWND = NULL;
|
||||
int rc = 0;
|
||||
consoleHWND = NULL;
|
||||
|
||||
#ifdef DEBUG_MONITOR
|
||||
_stprintf(buffer, _T("Try to interrupt process %i\n"), pid);
|
||||
OutputDebugStringW(buffer);
|
||||
_stprintf(buffer, _T("Try to interrupt process %i\n"), pid);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
// Find console
|
||||
EnumWindows(find_child_console, (LPARAM) pid);
|
||||
// Find console
|
||||
EnumWindows(find_child_console, (LPARAM)pid);
|
||||
|
||||
if (NULL != consoleHWND) { // Yes, we found out it
|
||||
// We are going to switch focus to console,
|
||||
// send Ctrl-C and then restore focus
|
||||
BYTE control_scan_code = (BYTE) MapVirtualKey(VK_CONTROL, 0);
|
||||
/* Fake Ctrl-C for SIGINT, and Ctrl-Break for SIGQUIT. */
|
||||
BYTE vk_break_code = VK_CANCEL;
|
||||
BYTE break_scan_code = (BYTE) MapVirtualKey(vk_break_code, 0);
|
||||
HWND foreground_window;
|
||||
if (NULL != consoleHWND) { // Yes, we found out it
|
||||
// We are going to switch focus to console,
|
||||
// send Ctrl-C and then restore focus
|
||||
BYTE control_scan_code = (BYTE)MapVirtualKey(VK_CONTROL, 0);
|
||||
/* Fake Ctrl-C for SIGINT, and Ctrl-Break for SIGQUIT. */
|
||||
BYTE vk_break_code = VK_CANCEL;
|
||||
BYTE break_scan_code = (BYTE)MapVirtualKey(vk_break_code, 0);
|
||||
HWND foreground_window;
|
||||
|
||||
foreground_window = GetForegroundWindow();
|
||||
if (foreground_window) {
|
||||
/* NT 5.0, and apparently also Windows 98, will not allow
|
||||
* a Window to be set to foreground directly without the
|
||||
* user's involvement. The workaround is to attach
|
||||
* ourselves to the thread that owns the foreground
|
||||
* window, since that is the only thread that can set the
|
||||
* foreground window.
|
||||
*/
|
||||
DWORD foreground_thread, child_thread;
|
||||
foreground_thread = GetWindowThreadProcessId(foreground_window, NULL);
|
||||
if (foreground_thread == GetCurrentThreadId()
|
||||
|| !AttachThreadInput(GetCurrentThreadId(), foreground_thread, TRUE)) {
|
||||
foreground_thread = 0;
|
||||
}
|
||||
foreground_window = GetForegroundWindow();
|
||||
if (foreground_window) {
|
||||
/* NT 5.0, and apparently also Windows 98, will not allow
|
||||
* a Window to be set to foreground directly without the
|
||||
* user's involvement. The workaround is to attach
|
||||
* ourselves to the thread that owns the foreground
|
||||
* window, since that is the only thread that can set the
|
||||
* foreground window.
|
||||
*/
|
||||
DWORD foreground_thread, child_thread;
|
||||
foreground_thread = GetWindowThreadProcessId(foreground_window, NULL);
|
||||
if (foreground_thread == GetCurrentThreadId() ||
|
||||
!AttachThreadInput(GetCurrentThreadId(), foreground_thread, TRUE)) {
|
||||
foreground_thread = 0;
|
||||
}
|
||||
|
||||
child_thread = GetWindowThreadProcessId(consoleHWND, NULL);
|
||||
if (child_thread == GetCurrentThreadId() || !AttachThreadInput(GetCurrentThreadId(), child_thread, TRUE)) {
|
||||
child_thread = 0;
|
||||
}
|
||||
child_thread = GetWindowThreadProcessId(consoleHWND, NULL);
|
||||
if (child_thread == GetCurrentThreadId() || !AttachThreadInput(GetCurrentThreadId(), child_thread, TRUE)) {
|
||||
child_thread = 0;
|
||||
}
|
||||
|
||||
/* Set the foreground window to the child. */
|
||||
if (SetForegroundWindow(consoleHWND)) {
|
||||
if (0 != break_scan_code) {
|
||||
/* Generate keystrokes as if user had typed Ctrl-Break */
|
||||
keybd_event(VK_CONTROL, control_scan_code, 0, 0);
|
||||
keybd_event(vk_break_code, break_scan_code, KEYEVENTF_EXTENDEDKEY, 0);
|
||||
keybd_event(vk_break_code, break_scan_code, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
|
||||
keybd_event(VK_CONTROL, control_scan_code, KEYEVENTF_KEYUP, 0);
|
||||
}
|
||||
/* Set the foreground window to the child. */
|
||||
if (SetForegroundWindow(consoleHWND)) {
|
||||
if (0 != break_scan_code) {
|
||||
/* Generate keystrokes as if user had typed Ctrl-Break */
|
||||
keybd_event(VK_CONTROL, control_scan_code, 0, 0);
|
||||
keybd_event(vk_break_code, break_scan_code, KEYEVENTF_EXTENDEDKEY, 0);
|
||||
keybd_event(vk_break_code, break_scan_code, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
|
||||
keybd_event(VK_CONTROL, control_scan_code, KEYEVENTF_KEYUP, 0);
|
||||
}
|
||||
|
||||
/* Sleep for a bit to give time for respond */
|
||||
Sleep(100);
|
||||
/* Sleep for a bit to give time for respond */
|
||||
Sleep(100);
|
||||
|
||||
SetForegroundWindow(foreground_window);
|
||||
}
|
||||
/* Detach from the foreground and child threads now that the foreground switching is over. */
|
||||
if (foreground_thread) {
|
||||
AttachThreadInput(GetCurrentThreadId(), foreground_thread, FALSE);
|
||||
}
|
||||
if (child_thread) {
|
||||
AttachThreadInput(GetCurrentThreadId(), child_thread, FALSE);
|
||||
}
|
||||
SetForegroundWindow(foreground_window);
|
||||
}
|
||||
/* Detach from the foreground and child threads now that the foreground switching is over. */
|
||||
if (foreground_thread) {
|
||||
AttachThreadInput(GetCurrentThreadId(), foreground_thread, FALSE);
|
||||
}
|
||||
if (child_thread) {
|
||||
AttachThreadInput(GetCurrentThreadId(), child_thread, FALSE);
|
||||
}
|
||||
#ifdef DEBUG_MONITOR
|
||||
_stprintf(buffer, _T("Sent Ctrl-C & Ctrl-Break to process %i\n"), pid);
|
||||
OutputDebugStringW(buffer);
|
||||
_stprintf(buffer, _T("Sent Ctrl-C & Ctrl-Break to process %i\n"), pid);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_MONITOR
|
||||
} else {
|
||||
_stprintf(buffer, _T("Cannot find console for process %i\n"), pid);
|
||||
OutputDebugStringW(buffer);
|
||||
} else {
|
||||
_stprintf(buffer, _T("Cannot find console for process %i\n"), pid);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* spawner.c
|
||||
*
|
||||
* This is a part of JNI implementation of spawner
|
||||
* This is a part of JNI implementation of spawner
|
||||
*******************************************************************************/
|
||||
|
||||
#include <tchar.h>
|
||||
|
@ -23,32 +23,31 @@
|
|||
|
||||
CRITICAL_SECTION cs;
|
||||
|
||||
wchar_t path[MAX_PATH + 1] = { _T('\0') }; // Directory where spawner.dll is located
|
||||
wchar_t path[MAX_PATH + 1] = {_T('\0')}; // Directory where spawner.dll is located
|
||||
|
||||
#if __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
|
||||
switch (ul_reason_for_call) {
|
||||
case DLL_PROCESS_ATTACH: {
|
||||
wchar_t *p;
|
||||
InitializeCriticalSection(&cs);
|
||||
GetModuleFileNameW(hModule, path, MAX_PATH);
|
||||
p = wcsrchr(path, _T('\\'));
|
||||
if (NULL != p) {
|
||||
*(p + 1) = _T('\0');
|
||||
} else {
|
||||
wcscat(path, L"\\");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
DeleteCriticalSection(&cs);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
BOOL APIENTRY
|
||||
DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
|
||||
switch (ul_reason_for_call) {
|
||||
case DLL_PROCESS_ATTACH: {
|
||||
wchar_t *p;
|
||||
InitializeCriticalSection(&cs);
|
||||
GetModuleFileNameW(hModule, path, MAX_PATH);
|
||||
p = wcsrchr(path, _T('\\'));
|
||||
if (NULL != p) {
|
||||
*(p + 1) = _T('\0');
|
||||
} else {
|
||||
wcscat(path, L"\\");
|
||||
}
|
||||
} break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
DeleteCriticalSection(&cs);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
* Wind River Systems, Inc.
|
||||
* Wind River Systems, Inc.
|
||||
*
|
||||
* starter.cpp
|
||||
*
|
||||
|
@ -26,36 +26,36 @@
|
|||
#include <psapi.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
//#define DEBUG_MONITOR
|
||||
//#define DEBUG_MONITOR
|
||||
#define MAX_CMD_LINE_LENGTH (2049)
|
||||
#define PIPE_NAME_LENGTH 100
|
||||
|
||||
int copyTo(wchar_t *target, const wchar_t *source, int cpyLength, int availSpace);
|
||||
void DisplayErrorMessage();
|
||||
|
||||
//BOOL KillProcessEx(DWORD dwProcessId); // Handle of the process
|
||||
// BOOL KillProcessEx(DWORD dwProcessId); // Handle of the process
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
BOOL WINAPI HandlerRoutine(DWORD dwCtrlType) { // control signal type
|
||||
BOOL ret = TRUE;
|
||||
switch (dwCtrlType) {
|
||||
case CTRL_C_EVENT:
|
||||
break;
|
||||
case CTRL_BREAK_EVENT:
|
||||
break;
|
||||
case CTRL_CLOSE_EVENT:
|
||||
ret = FALSE;
|
||||
break;
|
||||
case CTRL_LOGOFF_EVENT:
|
||||
ret = FALSE;
|
||||
break;
|
||||
case CTRL_SHUTDOWN_EVENT:
|
||||
ret = FALSE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
BOOL ret = TRUE;
|
||||
switch (dwCtrlType) {
|
||||
case CTRL_C_EVENT:
|
||||
break;
|
||||
case CTRL_BREAK_EVENT:
|
||||
break;
|
||||
case CTRL_CLOSE_EVENT:
|
||||
ret = FALSE;
|
||||
break;
|
||||
case CTRL_LOGOFF_EVENT:
|
||||
ret = FALSE;
|
||||
break;
|
||||
case CTRL_SHUTDOWN_EVENT:
|
||||
ret = FALSE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// The default here means we haven't checked yet
|
||||
|
@ -64,387 +64,389 @@ wchar_t *cygwinBin = NULL;
|
|||
bool _isCygwin = true;
|
||||
|
||||
bool isCygwin(HANDLE process) {
|
||||
// Have we checked before?
|
||||
if (cygwinBin != NULL || !_isCygwin) {
|
||||
return _isCygwin;
|
||||
}
|
||||
// Have we checked before?
|
||||
if (cygwinBin != NULL || !_isCygwin) {
|
||||
return _isCygwin;
|
||||
}
|
||||
|
||||
// See if this process loaded cygwin, need a different SIGINT for them
|
||||
HMODULE mods[1024];
|
||||
DWORD needed;
|
||||
if (EnumProcessModules(process, mods, sizeof(mods), &needed)) {
|
||||
int i;
|
||||
needed /= sizeof(HMODULE);
|
||||
for (i = 0; i < needed; ++i) {
|
||||
wchar_t modName[MAX_PATH];
|
||||
if (GetModuleFileNameEx(process, mods[i], modName, MAX_PATH)) {
|
||||
wchar_t *p = wcsrchr(modName, L'\\');
|
||||
if (p) {
|
||||
*p = 0; // Null terminate there for future reference
|
||||
if (!wcscmp(++p, L"cygwin1.dll")) {
|
||||
_isCygwin = true;
|
||||
// Store away the bind dir
|
||||
cygwinBin = wcsdup(modName);
|
||||
return _isCygwin;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// See if this process loaded cygwin, need a different SIGINT for them
|
||||
HMODULE mods[1024];
|
||||
DWORD needed;
|
||||
if (EnumProcessModules(process, mods, sizeof(mods), &needed)) {
|
||||
int i;
|
||||
needed /= sizeof(HMODULE);
|
||||
for (i = 0; i < needed; ++i) {
|
||||
wchar_t modName[MAX_PATH];
|
||||
if (GetModuleFileNameEx(process, mods[i], modName, MAX_PATH)) {
|
||||
wchar_t *p = wcsrchr(modName, L'\\');
|
||||
if (p) {
|
||||
*p = 0; // Null terminate there for future reference
|
||||
if (!wcscmp(++p, L"cygwin1.dll")) {
|
||||
_isCygwin = true;
|
||||
// Store away the bind dir
|
||||
cygwinBin = wcsdup(modName);
|
||||
return _isCygwin;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_isCygwin = false;
|
||||
return _isCygwin;
|
||||
_isCygwin = false;
|
||||
return _isCygwin;
|
||||
}
|
||||
|
||||
bool runCygwinCommand(wchar_t *command) {
|
||||
wchar_t cygcmd[1024];
|
||||
swprintf(cygcmd, sizeof(cygcmd) / sizeof(cygcmd[0]), L"%s\\%s", cygwinBin, command);
|
||||
wchar_t cygcmd[1024];
|
||||
swprintf(cygcmd, sizeof(cygcmd) / sizeof(cygcmd[0]), L"%s\\%s", cygwinBin, command);
|
||||
|
||||
STARTUPINFO si;
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
PROCESS_INFORMATION pi;
|
||||
ZeroMemory(&pi, sizeof(pi));
|
||||
if (CreateProcess(NULL, cygcmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
CloseHandle(pi.hThread);
|
||||
CloseHandle(pi.hProcess);
|
||||
return true;
|
||||
} else if (CreateProcess(NULL, command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
CloseHandle(pi.hThread);
|
||||
CloseHandle(pi.hProcess);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
STARTUPINFO si;
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
PROCESS_INFORMATION pi;
|
||||
ZeroMemory(&pi, sizeof(pi));
|
||||
if (CreateProcess(NULL, cygcmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
CloseHandle(pi.hThread);
|
||||
CloseHandle(pi.hProcess);
|
||||
return true;
|
||||
} else if (CreateProcess(NULL, command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
CloseHandle(pi.hThread);
|
||||
CloseHandle(pi.hProcess);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ensureSize(wchar_t **ptr, int *psize, int requiredLength) {
|
||||
int size = *psize;
|
||||
if (requiredLength > size) {
|
||||
size = 2 * size;
|
||||
if (size < requiredLength) {
|
||||
size = requiredLength;
|
||||
}
|
||||
*ptr = (wchar_t*) realloc(*ptr, size * sizeof(wchar_t));
|
||||
if (NULL == *ptr) {
|
||||
*psize = 0;
|
||||
} else {
|
||||
*psize = size;
|
||||
}
|
||||
}
|
||||
int size = *psize;
|
||||
if (requiredLength > size) {
|
||||
size = 2 * size;
|
||||
if (size < requiredLength) {
|
||||
size = requiredLength;
|
||||
}
|
||||
*ptr = (wchar_t *)realloc(*ptr, size * sizeof(wchar_t));
|
||||
if (NULL == *ptr) {
|
||||
*psize = 0;
|
||||
} else {
|
||||
*psize = size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
int argc;
|
||||
wchar_t **argv = CommandLineToArgvW(GetCommandLine(), &argc);
|
||||
int argc;
|
||||
wchar_t **argv = CommandLineToArgvW(GetCommandLine(), &argc);
|
||||
|
||||
// Make sure that we've been passed the right number of arguments
|
||||
if (argc < 8) {
|
||||
wprintf(L"Usage: %s (four inheritable event handles) (CommandLineToSpawn)\n", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
// Make sure that we've been passed the right number of arguments
|
||||
if (argc < 8) {
|
||||
wprintf(L"Usage: %s (four inheritable event handles) (CommandLineToSpawn)\n", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Construct the full command line
|
||||
int nCmdLineLength = MAX_CMD_LINE_LENGTH;
|
||||
wchar_t *szCmdLine = (wchar_t*) malloc(nCmdLineLength * sizeof(wchar_t));
|
||||
szCmdLine[0] = 0;
|
||||
int nPos = 0;
|
||||
// Construct the full command line
|
||||
int nCmdLineLength = MAX_CMD_LINE_LENGTH;
|
||||
wchar_t *szCmdLine = (wchar_t *)malloc(nCmdLineLength * sizeof(wchar_t));
|
||||
szCmdLine[0] = 0;
|
||||
int nPos = 0;
|
||||
|
||||
for (int i = 8; i < argc; ++i) {
|
||||
int nCpyLen;
|
||||
int len = wcslen(argv[i]);
|
||||
int requiredSize = nPos + len + 2;
|
||||
if (requiredSize > 32 * 1024) {
|
||||
for (int i = 8; i < argc; ++i) {
|
||||
int nCpyLen;
|
||||
int len = wcslen(argv[i]);
|
||||
int requiredSize = nPos + len + 2;
|
||||
if (requiredSize > 32 * 1024) {
|
||||
#ifdef DEBUG_MONITOR
|
||||
OutputDebugStringW(_T("Command line too long!\n"));
|
||||
OutputDebugStringW(_T("Command line too long!\n"));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
ensureSize(&szCmdLine, &nCmdLineLength, requiredSize);
|
||||
if (NULL == szCmdLine) {
|
||||
return 0;
|
||||
}
|
||||
ensureSize(&szCmdLine, &nCmdLineLength, requiredSize);
|
||||
if (NULL == szCmdLine) {
|
||||
#ifdef DEBUG_MONITOR
|
||||
OutputDebugStringW(_T("Not enough memory to build cmd line!\n"));
|
||||
OutputDebugStringW(_T("Not enough memory to build cmd line!\n"));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
if (0 > (nCpyLen = copyTo(szCmdLine + nPos, argv[i], len, nCmdLineLength - nPos))) {
|
||||
return 0;
|
||||
}
|
||||
if (0 > (nCpyLen = copyTo(szCmdLine + nPos, argv[i], len, nCmdLineLength - nPos))) {
|
||||
#ifdef DEBUG_MONITOR
|
||||
OutputDebugStringW(_T("Not enough space to build command line\n"));
|
||||
OutputDebugStringW(_T("Not enough space to build command line\n"));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
nPos += nCpyLen;
|
||||
szCmdLine[nPos] = _T(' ');
|
||||
++nPos;
|
||||
}
|
||||
szCmdLine[nPos] = _T('\0');
|
||||
return 0;
|
||||
}
|
||||
nPos += nCpyLen;
|
||||
szCmdLine[nPos] = _T(' ');
|
||||
++nPos;
|
||||
}
|
||||
szCmdLine[nPos] = _T('\0');
|
||||
|
||||
STARTUPINFOW si = { sizeof(si) };
|
||||
PROCESS_INFORMATION pi = { 0 };
|
||||
DWORD dwExitCode = 0;
|
||||
STARTUPINFOW si = {sizeof(si)};
|
||||
PROCESS_INFORMATION pi = {0};
|
||||
DWORD dwExitCode = 0;
|
||||
#ifdef DEBUG_MONITOR
|
||||
int currentPID = GetCurrentProcessId();
|
||||
wchar_t buffer[MAX_CMD_LINE_LENGTH];
|
||||
int currentPID = GetCurrentProcessId();
|
||||
wchar_t buffer[MAX_CMD_LINE_LENGTH];
|
||||
#endif
|
||||
|
||||
BOOL exitProc = FALSE;
|
||||
HANDLE waitEvent = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[4]);
|
||||
HANDLE h[5];
|
||||
h[0] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[3]); // simulated SIGINT (CTRL-C or Cygwin 'kill -SIGINT')
|
||||
// h[1] we reserve for the process handle
|
||||
h[2] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[5]); // simulated SIGTERM
|
||||
h[3] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[6]); // simulated SIGKILL
|
||||
h[4] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[7]); // CTRL-C, in all cases
|
||||
BOOL exitProc = FALSE;
|
||||
HANDLE waitEvent = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[4]);
|
||||
HANDLE h[5];
|
||||
h[0] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[3]); // simulated SIGINT (CTRL-C or Cygwin 'kill -SIGINT')
|
||||
// h[1] we reserve for the process handle
|
||||
h[2] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[5]); // simulated SIGTERM
|
||||
h[3] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[6]); // simulated SIGKILL
|
||||
h[4] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[7]); // CTRL-C, in all cases
|
||||
|
||||
SetConsoleCtrlHandler(HandlerRoutine, TRUE);
|
||||
SetConsoleCtrlHandler(HandlerRoutine, TRUE);
|
||||
|
||||
int parentPid = wcstol(argv[1], NULL, 10);
|
||||
int nCounter = wcstol(argv[2], NULL, 10);
|
||||
wchar_t inPipeName[PIPE_NAME_LENGTH];
|
||||
wchar_t outPipeName[PIPE_NAME_LENGTH];
|
||||
wchar_t errPipeName[PIPE_NAME_LENGTH];
|
||||
int parentPid = wcstol(argv[1], NULL, 10);
|
||||
int nCounter = wcstol(argv[2], NULL, 10);
|
||||
wchar_t inPipeName[PIPE_NAME_LENGTH];
|
||||
wchar_t outPipeName[PIPE_NAME_LENGTH];
|
||||
wchar_t errPipeName[PIPE_NAME_LENGTH];
|
||||
|
||||
swprintf(inPipeName, sizeof(inPipeName) / sizeof(inPipeName[0]), L"\\\\.\\pipe\\stdin%08i%010i", parentPid,
|
||||
nCounter);
|
||||
swprintf(outPipeName, sizeof(outPipeName) / sizeof(outPipeName[0]), L"\\\\.\\pipe\\stdout%08i%010i", parentPid,
|
||||
nCounter);
|
||||
swprintf(errPipeName, sizeof(errPipeName) / sizeof(errPipeName[0]), L"\\\\.\\pipe\\stderr%08i%010i", parentPid,
|
||||
nCounter);
|
||||
swprintf(inPipeName, sizeof(inPipeName) / sizeof(inPipeName[0]), L"\\\\.\\pipe\\stdin%08i%010i", parentPid,
|
||||
nCounter);
|
||||
swprintf(outPipeName, sizeof(outPipeName) / sizeof(outPipeName[0]), L"\\\\.\\pipe\\stdout%08i%010i", parentPid,
|
||||
nCounter);
|
||||
swprintf(errPipeName, sizeof(errPipeName) / sizeof(errPipeName[0]), L"\\\\.\\pipe\\stderr%08i%010i", parentPid,
|
||||
nCounter);
|
||||
#ifdef DEBUG_MONITOR
|
||||
swprintf(buffer, _T("Pipes: %s, %s, %s\n"), inPipeName, outPipeName, errPipeName);
|
||||
OutputDebugStringW(buffer);
|
||||
swprintf(buffer, _T("Pipes: %s, %s, %s\n"), inPipeName, outPipeName, errPipeName);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
|
||||
HANDLE stdHandles[3];
|
||||
HANDLE stdHandles[3];
|
||||
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
sa.bInheritHandle = TRUE;
|
||||
sa.lpSecurityDescriptor = NULL;
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
sa.bInheritHandle = TRUE;
|
||||
sa.lpSecurityDescriptor = NULL;
|
||||
|
||||
if ((INVALID_HANDLE_VALUE
|
||||
== (stdHandles[0] = CreateFileW(inPipeName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, &sa)))
|
||||
|| (INVALID_HANDLE_VALUE
|
||||
== (stdHandles[1] = CreateFileW(outPipeName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
|
||||
0, &sa)))
|
||||
|| (INVALID_HANDLE_VALUE
|
||||
== (stdHandles[2] = CreateFileW(errPipeName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
|
||||
0, &sa)))) {
|
||||
if ((INVALID_HANDLE_VALUE ==
|
||||
(stdHandles[0] = CreateFileW(inPipeName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, &sa))) ||
|
||||
(INVALID_HANDLE_VALUE ==
|
||||
(stdHandles[1] = CreateFileW(outPipeName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, &sa))) ||
|
||||
(INVALID_HANDLE_VALUE ==
|
||||
(stdHandles[2] = CreateFileW(errPipeName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, &sa)))) {
|
||||
#ifdef DEBUG_MONITOR
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Failed to open pipe %i, %i, %i: %i\n"), stdHandles[0], stdHandles[1], stdHandles[2], GetLastError());
|
||||
OutputDebugStringW(buffer);
|
||||
swprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), _T("Failed to open pipe %i, %i, %i: %i\n"), stdHandles[0],
|
||||
stdHandles[1], stdHandles[2], GetLastError());
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
CloseHandle(stdHandles[0]);
|
||||
CloseHandle(stdHandles[1]);
|
||||
CloseHandle(stdHandles[2]);
|
||||
return -1;
|
||||
}
|
||||
SetHandleInformation(stdHandles[0], HANDLE_FLAG_INHERIT, TRUE);
|
||||
SetHandleInformation(stdHandles[1], HANDLE_FLAG_INHERIT, TRUE);
|
||||
SetHandleInformation(stdHandles[2], HANDLE_FLAG_INHERIT, TRUE);
|
||||
CloseHandle(stdHandles[0]);
|
||||
CloseHandle(stdHandles[1]);
|
||||
CloseHandle(stdHandles[2]);
|
||||
return -1;
|
||||
}
|
||||
SetHandleInformation(stdHandles[0], HANDLE_FLAG_INHERIT, TRUE);
|
||||
SetHandleInformation(stdHandles[1], HANDLE_FLAG_INHERIT, TRUE);
|
||||
SetHandleInformation(stdHandles[2], HANDLE_FLAG_INHERIT, TRUE);
|
||||
|
||||
if (!SetStdHandle(STD_INPUT_HANDLE, stdHandles[0]) || !SetStdHandle(STD_OUTPUT_HANDLE, stdHandles[1])
|
||||
|| !SetStdHandle(STD_ERROR_HANDLE, stdHandles[2])) {
|
||||
if (!SetStdHandle(STD_INPUT_HANDLE, stdHandles[0]) || !SetStdHandle(STD_OUTPUT_HANDLE, stdHandles[1]) ||
|
||||
!SetStdHandle(STD_ERROR_HANDLE, stdHandles[2])) {
|
||||
#ifdef DEBUG_MONITOR
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Failed to reassign standard streams: %i\n"), GetLastError());
|
||||
OutputDebugStringW(buffer);
|
||||
swprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), _T("Failed to reassign standard streams: %i\n"),
|
||||
GetLastError());
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
CloseHandle(stdHandles[0]);
|
||||
CloseHandle(stdHandles[1]);
|
||||
CloseHandle(stdHandles[2]);
|
||||
return -1;
|
||||
}
|
||||
CloseHandle(stdHandles[0]);
|
||||
CloseHandle(stdHandles[1]);
|
||||
CloseHandle(stdHandles[2]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_MONITOR_DETAILS
|
||||
wchar_t * lpvEnv = GetEnvironmentStringsW();
|
||||
wchar_t *lpvEnv = GetEnvironmentStringsW();
|
||||
|
||||
// If the returned pointer is NULL, exit.
|
||||
if (lpvEnv == NULL) {
|
||||
OutputDebugStringW(_T("Cannot Read Environment\n"));
|
||||
} else {
|
||||
// Variable strings are separated by NULL byte, and the block is
|
||||
// terminated by a NULL byte.
|
||||
// If the returned pointer is NULL, exit.
|
||||
if (lpvEnv == NULL) {
|
||||
OutputDebugStringW(_T("Cannot Read Environment\n"));
|
||||
} else {
|
||||
// Variable strings are separated by NULL byte, and the block is
|
||||
// terminated by a NULL byte.
|
||||
|
||||
OutputDebugStringW(_T("Starter: Environment\n"));
|
||||
for (wchar_t * lpszVariable = (wchar_t *) lpvEnv; *lpszVariable; lpszVariable += wcslen(lpszVariable) + 1) {
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("%s\n"), lpszVariable);
|
||||
OutputDebugStringW(buffer);
|
||||
}
|
||||
OutputDebugStringW(_T("Starter: Environment\n"));
|
||||
for (wchar_t *lpszVariable = (wchar_t *)lpvEnv; *lpszVariable; lpszVariable += wcslen(lpszVariable) + 1) {
|
||||
swprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), _T("%s\n"), lpszVariable);
|
||||
OutputDebugStringW(buffer);
|
||||
}
|
||||
|
||||
FreeEnvironmentStringsW(lpvEnv);
|
||||
}
|
||||
FreeEnvironmentStringsW(lpvEnv);
|
||||
}
|
||||
#endif
|
||||
#ifdef DEBUG_MONITOR
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Starting: %s\n"), szCmdLine);
|
||||
OutputDebugStringW(buffer);
|
||||
swprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), _T("Starting: %s\n"), szCmdLine);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
// Create job object
|
||||
HANDLE hJob = CreateJobObject(NULL, NULL);
|
||||
if (hJob != NULL) {
|
||||
// Configure job to
|
||||
// - terminate all associated processes when the last handle to it is closed
|
||||
// - allow child processes to break away from the job.
|
||||
JOBOBJECT_EXTENDED_LIMIT_INFORMATION jobInfo;
|
||||
ZeroMemory(&jobInfo, sizeof(jobInfo));
|
||||
jobInfo.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | JOB_OBJECT_LIMIT_BREAKAWAY_OK;
|
||||
if (!SetInformationJobObject(hJob, JobObjectExtendedLimitInformation, &jobInfo, sizeof(jobInfo))) {
|
||||
// Create job object
|
||||
HANDLE hJob = CreateJobObject(NULL, NULL);
|
||||
if (hJob != NULL) {
|
||||
// Configure job to
|
||||
// - terminate all associated processes when the last handle to it is closed
|
||||
// - allow child processes to break away from the job.
|
||||
JOBOBJECT_EXTENDED_LIMIT_INFORMATION jobInfo;
|
||||
ZeroMemory(&jobInfo, sizeof(jobInfo));
|
||||
jobInfo.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | JOB_OBJECT_LIMIT_BREAKAWAY_OK;
|
||||
if (!SetInformationJobObject(hJob, JobObjectExtendedLimitInformation, &jobInfo, sizeof(jobInfo))) {
|
||||
#ifdef DEBUG_MONITOR
|
||||
OutputDebugStringW(_T("Cannot set job information\n"));
|
||||
DisplayErrorMessage();
|
||||
OutputDebugStringW(_T("Cannot set job information\n"));
|
||||
DisplayErrorMessage();
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
#ifdef DEBUG_MONITOR
|
||||
OutputDebugStringW(_T("Cannot create job object\n"));
|
||||
DisplayErrorMessage();
|
||||
OutputDebugStringW(_T("Cannot create job object\n"));
|
||||
DisplayErrorMessage();
|
||||
#endif
|
||||
}
|
||||
// Spawn the other processes as part of this Process Group
|
||||
// If this process is already part of a job, the flag CREATE_BREAKAWAY_FROM_JOB
|
||||
// makes the child process detach from the job, such that we can assign it
|
||||
// to our own job object.
|
||||
BOOL f = CreateProcessW(NULL, szCmdLine, NULL, NULL, TRUE, CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, &si, &pi);
|
||||
// If breaking away from job is not permitted, retry without breakaway flag
|
||||
if (!f) {
|
||||
f = CreateProcessW(NULL, szCmdLine, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
|
||||
}
|
||||
}
|
||||
// Spawn the other processes as part of this Process Group
|
||||
// If this process is already part of a job, the flag CREATE_BREAKAWAY_FROM_JOB
|
||||
// makes the child process detach from the job, such that we can assign it
|
||||
// to our own job object.
|
||||
BOOL f = CreateProcessW(NULL, szCmdLine, NULL, NULL, TRUE, CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, &si, &pi);
|
||||
// If breaking away from job is not permitted, retry without breakaway flag
|
||||
if (!f) {
|
||||
f = CreateProcessW(NULL, szCmdLine, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
|
||||
}
|
||||
|
||||
// We don't need them any more
|
||||
CloseHandle(stdHandles[0]);
|
||||
CloseHandle(stdHandles[1]);
|
||||
CloseHandle(stdHandles[2]);
|
||||
// We don't need them any more
|
||||
CloseHandle(stdHandles[0]);
|
||||
CloseHandle(stdHandles[1]);
|
||||
CloseHandle(stdHandles[2]);
|
||||
|
||||
if (f) {
|
||||
if (f) {
|
||||
#ifdef DEBUG_MONITOR
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Process %i started\n"), pi.dwProcessId);
|
||||
OutputDebugStringW(buffer);
|
||||
swprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), _T("Process %i started\n"), pi.dwProcessId);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
SetEvent(waitEvent); // Means that process has been spawned
|
||||
CloseHandle(pi.hThread);
|
||||
h[1] = pi.hProcess;
|
||||
SetEvent(waitEvent); // Means that process has been spawned
|
||||
CloseHandle(pi.hThread);
|
||||
h[1] = pi.hProcess;
|
||||
|
||||
if (NULL != hJob) {
|
||||
if (!AssignProcessToJobObject(hJob, pi.hProcess)) {
|
||||
if (NULL != hJob) {
|
||||
if (!AssignProcessToJobObject(hJob, pi.hProcess)) {
|
||||
#ifdef DEBUG_MONITOR
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Cannot assign process %i to a job\n"), pi.dwProcessId);
|
||||
OutputDebugStringW(buffer);
|
||||
DisplayErrorMessage();
|
||||
swprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), _T("Cannot assign process %i to a job\n"),
|
||||
pi.dwProcessId);
|
||||
OutputDebugStringW(buffer);
|
||||
DisplayErrorMessage();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (!exitProc) {
|
||||
// Wait for the spawned-process to die or for the event
|
||||
// indicating that the processes should be forcibly killed.
|
||||
DWORD event = WaitForMultipleObjects(5, h, FALSE, INFINITE);
|
||||
switch (event) {
|
||||
case WAIT_OBJECT_0 + 0: // SIGINT
|
||||
case WAIT_OBJECT_0 + 4: // CTRL-C
|
||||
while (!exitProc) {
|
||||
// Wait for the spawned-process to die or for the event
|
||||
// indicating that the processes should be forcibly killed.
|
||||
DWORD event = WaitForMultipleObjects(5, h, FALSE, INFINITE);
|
||||
switch (event) {
|
||||
case WAIT_OBJECT_0 + 0: // SIGINT
|
||||
case WAIT_OBJECT_0 + 4: // CTRL-C
|
||||
#ifdef DEBUG_MONITOR
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("starter (PID %i) received CTRL-C event\n"), currentPID);
|
||||
OutputDebugStringW(buffer);
|
||||
swprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), _T("starter (PID %i) received CTRL-C event\n"),
|
||||
currentPID);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
if ((event == (WAIT_OBJECT_0 + 0)) && isCygwin(h[1])) {
|
||||
// Need to issue a kill command
|
||||
wchar_t kill[1024];
|
||||
swprintf(kill, sizeof(kill) / sizeof(kill[0]), L"kill -SIGINT %d", pi.dwProcessId);
|
||||
if (!runCygwinCommand(kill)) {
|
||||
// fall back to console event
|
||||
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
|
||||
}
|
||||
} else {
|
||||
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
|
||||
}
|
||||
if ((event == (WAIT_OBJECT_0 + 0)) && isCygwin(h[1])) {
|
||||
// Need to issue a kill command
|
||||
wchar_t kill[1024];
|
||||
swprintf(kill, sizeof(kill) / sizeof(kill[0]), L"kill -SIGINT %d", pi.dwProcessId);
|
||||
if (!runCygwinCommand(kill)) {
|
||||
// fall back to console event
|
||||
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
|
||||
}
|
||||
} else {
|
||||
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
|
||||
}
|
||||
|
||||
SetEvent(waitEvent);
|
||||
break;
|
||||
SetEvent(waitEvent);
|
||||
break;
|
||||
|
||||
case WAIT_OBJECT_0 + 1: // App terminated normally
|
||||
// Make it's exit code our exit code
|
||||
case WAIT_OBJECT_0 + 1: // App terminated normally
|
||||
// Make it's exit code our exit code
|
||||
#ifdef DEBUG_MONITOR
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("starter: launched process has been terminated(PID %i)\n"),
|
||||
pi.dwProcessId);
|
||||
OutputDebugStringW(buffer);
|
||||
swprintf(buffer, sizeof(buffer) / sizeof(buffer[0]),
|
||||
_T("starter: launched process has been terminated(PID %i)\n"), pi.dwProcessId);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
GetExitCodeProcess(pi.hProcess, &dwExitCode);
|
||||
exitProc = TRUE;
|
||||
break;
|
||||
GetExitCodeProcess(pi.hProcess, &dwExitCode);
|
||||
exitProc = TRUE;
|
||||
break;
|
||||
|
||||
// Terminate and Kill behavior differ only for cygwin processes, where
|
||||
// we use the cygwin 'kill' command. We send a SIGKILL in one case,
|
||||
// SIGTERM in the other. For non-cygwin processes, both requests
|
||||
// are treated exactly the same
|
||||
case WAIT_OBJECT_0 + 2: // TERM
|
||||
case WAIT_OBJECT_0 + 3: // KILL
|
||||
{
|
||||
const wchar_t *signal = (event == WAIT_OBJECT_0 + 2) ? L"TERM" : L"KILL";
|
||||
// Terminate and Kill behavior differ only for cygwin processes, where
|
||||
// we use the cygwin 'kill' command. We send a SIGKILL in one case,
|
||||
// SIGTERM in the other. For non-cygwin processes, both requests
|
||||
// are treated exactly the same
|
||||
case WAIT_OBJECT_0 + 2: // TERM
|
||||
case WAIT_OBJECT_0 + 3: // KILL
|
||||
{
|
||||
const wchar_t *signal = (event == WAIT_OBJECT_0 + 2) ? L"TERM" : L"KILL";
|
||||
#ifdef DEBUG_MONITOR
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("starter received %s event (PID %i)\n"), signal, currentPID);
|
||||
OutputDebugStringW(buffer);
|
||||
swprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), _T("starter received %s event (PID %i)\n"), signal,
|
||||
currentPID);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
if (isCygwin(h[1])) {
|
||||
// Need to issue a kill command
|
||||
wchar_t kill[1024];
|
||||
swprintf(kill, sizeof(kill) / sizeof(kill[0]), L"kill -%s %d", signal, pi.dwProcessId);
|
||||
if (!runCygwinCommand(kill)) {
|
||||
// fall back to console event
|
||||
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
|
||||
}
|
||||
} else {
|
||||
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
|
||||
}
|
||||
if (isCygwin(h[1])) {
|
||||
// Need to issue a kill command
|
||||
wchar_t kill[1024];
|
||||
swprintf(kill, sizeof(kill) / sizeof(kill[0]), L"kill -%s %d", signal, pi.dwProcessId);
|
||||
if (!runCygwinCommand(kill)) {
|
||||
// fall back to console event
|
||||
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
|
||||
}
|
||||
} else {
|
||||
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
|
||||
}
|
||||
|
||||
SetEvent(waitEvent);
|
||||
SetEvent(waitEvent);
|
||||
|
||||
if (NULL != hJob) {
|
||||
if (!TerminateJobObject(hJob, (DWORD) - 1)) {
|
||||
if (NULL != hJob) {
|
||||
if (!TerminateJobObject(hJob, (DWORD)-1)) {
|
||||
#ifdef DEBUG_MONITOR
|
||||
OutputDebugStringW(_T("Cannot terminate job\n"));
|
||||
DisplayErrorMessage();
|
||||
OutputDebugStringW(_T("Cannot terminate job\n"));
|
||||
DisplayErrorMessage();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Note that we keep trucking until the child process terminates (case WAIT_OBJECT_0 + 1)
|
||||
break;
|
||||
}
|
||||
// Note that we keep trucking until the child process terminates (case WAIT_OBJECT_0 + 1)
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
// Unexpected code
|
||||
default:
|
||||
// Unexpected code
|
||||
#ifdef DEBUG_MONITOR
|
||||
DisplayErrorMessage();
|
||||
DisplayErrorMessage();
|
||||
#endif
|
||||
exitProc = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
exitProc = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#ifdef DEBUG_MONITOR
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Cannot start: %s\n"), szCmdLine);
|
||||
OutputDebugStringW(buffer);
|
||||
swprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), _T("Cannot start: %s\n"), szCmdLine);
|
||||
OutputDebugStringW(buffer);
|
||||
|
||||
DisplayErrorMessage();
|
||||
DisplayErrorMessage();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
free(szCmdLine);
|
||||
free(szCmdLine);
|
||||
|
||||
CloseHandle(waitEvent);
|
||||
CloseHandle(h[0]);
|
||||
CloseHandle(h[1]);
|
||||
CloseHandle(h[2]);
|
||||
CloseHandle(h[3]);
|
||||
CloseHandle(h[4]);
|
||||
CloseHandle(waitEvent);
|
||||
CloseHandle(h[0]);
|
||||
CloseHandle(h[1]);
|
||||
CloseHandle(h[2]);
|
||||
CloseHandle(h[3]);
|
||||
CloseHandle(h[4]);
|
||||
|
||||
return dwExitCode;
|
||||
return dwExitCode;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// Use this utility program to process correctly quotation marks in the command line
|
||||
// Arguments:
|
||||
// Arguments:
|
||||
// target - string to copy to
|
||||
// source - string to copy from
|
||||
// cpyLength - copy length
|
||||
|
@ -452,75 +454,75 @@ int main() {
|
|||
// Return :number of bytes used in target, or -1 in case of error
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
int copyTo(wchar_t *target, const wchar_t *source, int cpyLength, int availSpace) {
|
||||
BOOL bSlash = FALSE;
|
||||
int i = 0, j = 0;
|
||||
BOOL bSlash = FALSE;
|
||||
int i = 0, j = 0;
|
||||
|
||||
#define QUOTATION_DO 0
|
||||
#define QUOTATION_DO 0
|
||||
#define QUOTATION_DONE 1
|
||||
#define QUOTATION_NONE 2
|
||||
|
||||
int nQuotationMode = 0;
|
||||
if (availSpace <= cpyLength) { // = to reserve space for '\0'
|
||||
return -1;
|
||||
}
|
||||
int nQuotationMode = 0;
|
||||
if (availSpace <= cpyLength) { // = to reserve space for '\0'
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((_T('\"') == *source) && (_T('\"') == *(source + cpyLength - 1))) {
|
||||
// Already done
|
||||
nQuotationMode = QUOTATION_DONE;
|
||||
} else if (wcschr(source, _T(' ')) == NULL) {
|
||||
// No reason to quotate term becase it doesn't have embedded spaces
|
||||
nQuotationMode = QUOTATION_NONE;
|
||||
} else {
|
||||
// Needs to be quotated
|
||||
nQuotationMode = QUOTATION_DO;
|
||||
*target = _T('\"');
|
||||
++j;
|
||||
}
|
||||
if ((_T('\"') == *source) && (_T('\"') == *(source + cpyLength - 1))) {
|
||||
// Already done
|
||||
nQuotationMode = QUOTATION_DONE;
|
||||
} else if (wcschr(source, _T(' ')) == NULL) {
|
||||
// No reason to quotate term becase it doesn't have embedded spaces
|
||||
nQuotationMode = QUOTATION_NONE;
|
||||
} else {
|
||||
// Needs to be quotated
|
||||
nQuotationMode = QUOTATION_DO;
|
||||
*target = _T('\"');
|
||||
++j;
|
||||
}
|
||||
|
||||
for (; i < cpyLength; ++i, ++j) {
|
||||
if (source[i] == _T('\\')) {
|
||||
bSlash = TRUE;
|
||||
} else {
|
||||
// Don't escape embracing quotation marks
|
||||
if ((source[i] == _T('\"'))
|
||||
&& !((nQuotationMode == QUOTATION_DONE) && ((i == 0) || (i == (cpyLength - 1))))) {
|
||||
if (!bSlash) {
|
||||
if (j == availSpace) {
|
||||
return -1;
|
||||
}
|
||||
target[j] = _T('\\');
|
||||
++j;
|
||||
}
|
||||
bSlash = FALSE;
|
||||
} else {
|
||||
bSlash = FALSE;
|
||||
}
|
||||
}
|
||||
for (; i < cpyLength; ++i, ++j) {
|
||||
if (source[i] == _T('\\')) {
|
||||
bSlash = TRUE;
|
||||
} else {
|
||||
// Don't escape embracing quotation marks
|
||||
if ((source[i] == _T('\"')) &&
|
||||
!((nQuotationMode == QUOTATION_DONE) && ((i == 0) || (i == (cpyLength - 1))))) {
|
||||
if (!bSlash) {
|
||||
if (j == availSpace) {
|
||||
return -1;
|
||||
}
|
||||
target[j] = _T('\\');
|
||||
++j;
|
||||
}
|
||||
bSlash = FALSE;
|
||||
} else {
|
||||
bSlash = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (j == availSpace) {
|
||||
return -1;
|
||||
}
|
||||
target[j] = source[i];
|
||||
}
|
||||
if (j == availSpace) {
|
||||
return -1;
|
||||
}
|
||||
target[j] = source[i];
|
||||
}
|
||||
|
||||
if (nQuotationMode == QUOTATION_DO) {
|
||||
if (j == availSpace) {
|
||||
return -1;
|
||||
}
|
||||
target[j] = _T('\"');
|
||||
++j;
|
||||
}
|
||||
return j;
|
||||
if (nQuotationMode == QUOTATION_DO) {
|
||||
if (j == availSpace) {
|
||||
return -1;
|
||||
}
|
||||
target[j] = _T('\"');
|
||||
++j;
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
void DisplayErrorMessage() {
|
||||
wchar_t *lpMsgBuf;
|
||||
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
|
||||
GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(wchar_t*) &lpMsgBuf, 0, NULL);
|
||||
OutputDebugStringW(lpMsgBuf);
|
||||
// Free the buffer.
|
||||
LocalFree(lpMsgBuf);
|
||||
wchar_t *lpMsgBuf;
|
||||
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
|
||||
GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(wchar_t *)&lpMsgBuf, 0, NULL);
|
||||
OutputDebugStringW(lpMsgBuf);
|
||||
// Free the buffer.
|
||||
LocalFree(lpMsgBuf);
|
||||
}
|
||||
|
||||
//////////////////////////////// End of File //////////////////////////////////
|
||||
|
|
|
@ -1,192 +1,5 @@
|
|||
#Wed Jun 06 11:37:01 EDT 2007
|
||||
eclipse.preferences.version=1
|
||||
indexer/indexerId=org.eclipse.cdt.core.nullindexer
|
||||
indexerId=org.eclipse.cdt.core.nullindexer
|
||||
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
|
||||
org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_assignment=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_base_clause_in_type_declaration=80
|
||||
org.eclipse.cdt.core.formatter.alignment_for_binary_expression=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_compact_if=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_conditional_expression=34
|
||||
org.eclipse.cdt.core.formatter.alignment_for_conditional_expression_chain=18
|
||||
org.eclipse.cdt.core.formatter.alignment_for_constructor_initializer_list=0
|
||||
org.eclipse.cdt.core.formatter.alignment_for_declarator_list=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_enumerator_list=48
|
||||
org.eclipse.cdt.core.formatter.alignment_for_expression_list=0
|
||||
org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_lambda_expression=20
|
||||
org.eclipse.cdt.core.formatter.alignment_for_member_access=0
|
||||
org.eclipse.cdt.core.formatter.alignment_for_overloaded_left_shift_chain=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_array_initializer=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_block=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_block_in_case=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_linkage_declaration=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_method_declaration=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_namespace_declaration=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_switch=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_type_declaration=end_of_line
|
||||
org.eclipse.cdt.core.formatter.comment.line_up_line_comment_in_blocks_on_first_column=false
|
||||
org.eclipse.cdt.core.formatter.comment.min_distance_between_code_and_line_comment=1
|
||||
org.eclipse.cdt.core.formatter.comment.never_indent_line_comments_on_first_column=true
|
||||
org.eclipse.cdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=true
|
||||
org.eclipse.cdt.core.formatter.comment_formatter_off_tag=@formatter\:off
|
||||
org.eclipse.cdt.core.formatter.comment_formatter_on_tag=@formatter\:on
|
||||
org.eclipse.cdt.core.formatter.compact_else_if=true
|
||||
org.eclipse.cdt.core.formatter.continuation_indentation=2
|
||||
org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer=2
|
||||
org.eclipse.cdt.core.formatter.format_block_comment=true
|
||||
org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line=false
|
||||
org.eclipse.cdt.core.formatter.format_header_comment=true
|
||||
org.eclipse.cdt.core.formatter.format_line_comment=true
|
||||
org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header=false
|
||||
org.eclipse.cdt.core.formatter.indent_access_specifier_extra_spaces=0
|
||||
org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier=true
|
||||
org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_linkage=false
|
||||
org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_namespace_header=false
|
||||
org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases=true
|
||||
org.eclipse.cdt.core.formatter.indent_declaration_compare_to_template_header=false
|
||||
org.eclipse.cdt.core.formatter.indent_empty_lines=false
|
||||
org.eclipse.cdt.core.formatter.indent_label_compare_to_statements=true
|
||||
org.eclipse.cdt.core.formatter.indent_statements_compare_to_block=true
|
||||
org.eclipse.cdt.core.formatter.indent_statements_compare_to_body=true
|
||||
org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||
org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch=false
|
||||
org.eclipse.cdt.core.formatter.indentation.size=4
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_after_colon_in_constructor_initializer_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_after_label=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_after_template_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_colon_in_constructor_initializer_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_assignment_operator=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_binary_operator=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_arguments=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_parameters=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_base_clause=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_base_types=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_declarator_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_expression_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_structured_binding_name_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_arguments=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_parameters=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_lambda_return=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_exception_specification=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_structured_binding_name_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_pointer_in_declarator_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_pointer_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_postfix_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_prefix_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_unary_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_binary_operator=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_exception_specification=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_structured_binding_name_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_base_clause=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_base_types=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_declarator_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_expression_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_structured_binding_name_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_lambda_return=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_linkage_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_namespace_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_exception_specification=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_structured_binding_name_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_pointer_in_declarator_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_pointer_in_method_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_prefix_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_ref_qualifier_in_structured_binding=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_semicolon=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_unary_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_brackets=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_exception_specification=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
|
||||
org.eclipse.cdt.core.formatter.join_wrapped_lines=true
|
||||
org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line=false
|
||||
org.eclipse.cdt.core.formatter.keep_empty_array_initializer_on_one_line=false
|
||||
org.eclipse.cdt.core.formatter.keep_imple_if_on_one_line=false
|
||||
org.eclipse.cdt.core.formatter.keep_then_statement_on_same_line=false
|
||||
org.eclipse.cdt.core.formatter.lineSplit=120
|
||||
org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve=1
|
||||
org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line=true
|
||||
org.eclipse.cdt.core.formatter.tabulation.char=tab
|
||||
org.eclipse.cdt.core.formatter.tabulation.size=4
|
||||
org.eclipse.cdt.core.formatter.use_comment_formatter_tag=true
|
||||
org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
formatter_profile=_Unmanaged profile 'CDT'
|
||||
formatter_settings_version=1
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,189 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_assignment=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_base_clause_in_type_declaration=80
|
||||
org.eclipse.cdt.core.formatter.alignment_for_binary_expression=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_compact_if=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_conditional_expression=34
|
||||
org.eclipse.cdt.core.formatter.alignment_for_conditional_expression_chain=18
|
||||
org.eclipse.cdt.core.formatter.alignment_for_constructor_initializer_list=0
|
||||
org.eclipse.cdt.core.formatter.alignment_for_declarator_list=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_enumerator_list=48
|
||||
org.eclipse.cdt.core.formatter.alignment_for_expression_list=0
|
||||
org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_lambda_expression=20
|
||||
org.eclipse.cdt.core.formatter.alignment_for_member_access=0
|
||||
org.eclipse.cdt.core.formatter.alignment_for_overloaded_left_shift_chain=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_array_initializer=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_block=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_block_in_case=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_linkage_declaration=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_method_declaration=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_namespace_declaration=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_switch=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_type_declaration=end_of_line
|
||||
org.eclipse.cdt.core.formatter.comment.line_up_line_comment_in_blocks_on_first_column=false
|
||||
org.eclipse.cdt.core.formatter.comment.min_distance_between_code_and_line_comment=1
|
||||
org.eclipse.cdt.core.formatter.comment.never_indent_line_comments_on_first_column=true
|
||||
org.eclipse.cdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=true
|
||||
org.eclipse.cdt.core.formatter.comment_formatter_off_tag=@formatter\:off
|
||||
org.eclipse.cdt.core.formatter.comment_formatter_on_tag=@formatter\:on
|
||||
org.eclipse.cdt.core.formatter.compact_else_if=true
|
||||
org.eclipse.cdt.core.formatter.continuation_indentation=2
|
||||
org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer=2
|
||||
org.eclipse.cdt.core.formatter.format_block_comment=true
|
||||
org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line=false
|
||||
org.eclipse.cdt.core.formatter.format_header_comment=true
|
||||
org.eclipse.cdt.core.formatter.format_line_comment=true
|
||||
org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header=false
|
||||
org.eclipse.cdt.core.formatter.indent_access_specifier_extra_spaces=0
|
||||
org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier=true
|
||||
org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_linkage=false
|
||||
org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_namespace_header=false
|
||||
org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases=true
|
||||
org.eclipse.cdt.core.formatter.indent_declaration_compare_to_template_header=false
|
||||
org.eclipse.cdt.core.formatter.indent_empty_lines=false
|
||||
org.eclipse.cdt.core.formatter.indent_label_compare_to_statements=true
|
||||
org.eclipse.cdt.core.formatter.indent_statements_compare_to_block=true
|
||||
org.eclipse.cdt.core.formatter.indent_statements_compare_to_body=true
|
||||
org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||
org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch=false
|
||||
org.eclipse.cdt.core.formatter.indentation.size=4
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_after_colon_in_constructor_initializer_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_after_label=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_after_template_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_colon_in_constructor_initializer_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_assignment_operator=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_binary_operator=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_arguments=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_parameters=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_base_clause=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_base_types=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_declarator_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_expression_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_structured_binding_name_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_arguments=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_parameters=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_lambda_return=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_exception_specification=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_structured_binding_name_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_pointer_in_declarator_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_pointer_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_postfix_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_prefix_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_unary_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_binary_operator=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_exception_specification=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_structured_binding_name_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_base_clause=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_base_types=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_declarator_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_expression_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_structured_binding_name_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_lambda_return=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_linkage_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_namespace_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_exception_specification=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_structured_binding_name_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_pointer_in_declarator_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_pointer_in_method_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_prefix_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_ref_qualifier_in_structured_binding=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_semicolon=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_unary_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_brackets=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_exception_specification=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
|
||||
org.eclipse.cdt.core.formatter.join_wrapped_lines=true
|
||||
org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line=false
|
||||
org.eclipse.cdt.core.formatter.keep_empty_array_initializer_on_one_line=false
|
||||
org.eclipse.cdt.core.formatter.keep_imple_if_on_one_line=false
|
||||
org.eclipse.cdt.core.formatter.keep_then_statement_on_same_line=false
|
||||
org.eclipse.cdt.core.formatter.lineSplit=120
|
||||
org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve=1
|
||||
org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line=true
|
||||
org.eclipse.cdt.core.formatter.tabulation.char=tab
|
||||
org.eclipse.cdt.core.formatter.tabulation.size=4
|
||||
org.eclipse.cdt.core.formatter.use_comment_formatter_tag=true
|
||||
org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
|
@ -1,3 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
formatter_profile=_Unmanaged profile 'CDT'
|
||||
formatter_settings_version=1
|
|
@ -1,189 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_assignment=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_base_clause_in_type_declaration=80
|
||||
org.eclipse.cdt.core.formatter.alignment_for_binary_expression=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_compact_if=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_conditional_expression=34
|
||||
org.eclipse.cdt.core.formatter.alignment_for_conditional_expression_chain=18
|
||||
org.eclipse.cdt.core.formatter.alignment_for_constructor_initializer_list=0
|
||||
org.eclipse.cdt.core.formatter.alignment_for_declarator_list=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_enumerator_list=48
|
||||
org.eclipse.cdt.core.formatter.alignment_for_expression_list=0
|
||||
org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_lambda_expression=20
|
||||
org.eclipse.cdt.core.formatter.alignment_for_member_access=0
|
||||
org.eclipse.cdt.core.formatter.alignment_for_overloaded_left_shift_chain=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration=16
|
||||
org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_array_initializer=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_block=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_block_in_case=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_linkage_declaration=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_method_declaration=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_namespace_declaration=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_switch=end_of_line
|
||||
org.eclipse.cdt.core.formatter.brace_position_for_type_declaration=end_of_line
|
||||
org.eclipse.cdt.core.formatter.comment.line_up_line_comment_in_blocks_on_first_column=false
|
||||
org.eclipse.cdt.core.formatter.comment.min_distance_between_code_and_line_comment=1
|
||||
org.eclipse.cdt.core.formatter.comment.never_indent_line_comments_on_first_column=true
|
||||
org.eclipse.cdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=true
|
||||
org.eclipse.cdt.core.formatter.comment_formatter_off_tag=@formatter\:off
|
||||
org.eclipse.cdt.core.formatter.comment_formatter_on_tag=@formatter\:on
|
||||
org.eclipse.cdt.core.formatter.compact_else_if=true
|
||||
org.eclipse.cdt.core.formatter.continuation_indentation=2
|
||||
org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer=2
|
||||
org.eclipse.cdt.core.formatter.format_block_comment=true
|
||||
org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line=false
|
||||
org.eclipse.cdt.core.formatter.format_header_comment=true
|
||||
org.eclipse.cdt.core.formatter.format_line_comment=true
|
||||
org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header=false
|
||||
org.eclipse.cdt.core.formatter.indent_access_specifier_extra_spaces=0
|
||||
org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier=true
|
||||
org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_linkage=false
|
||||
org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_namespace_header=false
|
||||
org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases=true
|
||||
org.eclipse.cdt.core.formatter.indent_declaration_compare_to_template_header=false
|
||||
org.eclipse.cdt.core.formatter.indent_empty_lines=false
|
||||
org.eclipse.cdt.core.formatter.indent_label_compare_to_statements=true
|
||||
org.eclipse.cdt.core.formatter.indent_statements_compare_to_block=true
|
||||
org.eclipse.cdt.core.formatter.indent_statements_compare_to_body=true
|
||||
org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||
org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch=false
|
||||
org.eclipse.cdt.core.formatter.indentation.size=4
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_after_colon_in_constructor_initializer_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_after_label=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_after_template_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_colon_in_constructor_initializer_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_assignment_operator=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_binary_operator=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_arguments=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_parameters=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_base_clause=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_base_types=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_declarator_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_expression_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_structured_binding_name_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_arguments=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_parameters=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_lambda_return=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_exception_specification=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_opening_structured_binding_name_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_pointer_in_declarator_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_pointer_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_postfix_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_prefix_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_after_unary_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_binary_operator=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_exception_specification=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_closing_structured_binding_name_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_base_clause=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_base_types=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_declarator_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_expression_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_structured_binding_name_list=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_lambda_return=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_arguments=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_parameters=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_linkage_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_namespace_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_exception_specification=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_opening_structured_binding_name_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_pointer_in_declarator_list=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_pointer_in_method_declaration=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_prefix_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_ref_qualifier_in_structured_binding=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_semicolon=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_before_unary_operator=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_brackets=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_exception_specification=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
|
||||
org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
|
||||
org.eclipse.cdt.core.formatter.join_wrapped_lines=true
|
||||
org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line=false
|
||||
org.eclipse.cdt.core.formatter.keep_empty_array_initializer_on_one_line=false
|
||||
org.eclipse.cdt.core.formatter.keep_imple_if_on_one_line=false
|
||||
org.eclipse.cdt.core.formatter.keep_then_statement_on_same_line=false
|
||||
org.eclipse.cdt.core.formatter.lineSplit=120
|
||||
org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve=1
|
||||
org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line=true
|
||||
org.eclipse.cdt.core.formatter.tabulation.char=tab
|
||||
org.eclipse.cdt.core.formatter.tabulation.size=4
|
||||
org.eclipse.cdt.core.formatter.use_comment_formatter_tag=true
|
||||
org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
|
@ -1,3 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
formatter_profile=_Unmanaged profile 'CDT'
|
||||
formatter_settings_version=1
|
|
@ -12,56 +12,50 @@ extern "C" {
|
|||
* Method: open0
|
||||
* Signature: (Ljava/lang/String;IIII)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_eclipse_cdt_serial_SerialPort_open0
|
||||
(JNIEnv *, jobject, jstring, jint, jint, jint, jint);
|
||||
JNIEXPORT jlong JNICALL Java_org_eclipse_cdt_serial_SerialPort_open0(JNIEnv *, jobject, jstring, jint, jint, jint,
|
||||
jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_serial_SerialPort
|
||||
* Method: close0
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_eclipse_cdt_serial_SerialPort_close0
|
||||
(JNIEnv *, jobject, jlong);
|
||||
JNIEXPORT void JNICALL Java_org_eclipse_cdt_serial_SerialPort_close0(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_serial_SerialPort
|
||||
* Method: read1
|
||||
* Signature: (J[BII)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_serial_SerialPort_read1
|
||||
(JNIEnv *, jobject, jlong, jbyteArray, jint, jint);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_serial_SerialPort_read1(JNIEnv *, jobject, jlong, jbyteArray, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_serial_SerialPort
|
||||
* Method: available0
|
||||
* Signature: (J)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_serial_SerialPort_available0
|
||||
(JNIEnv *, jobject, jlong);
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_serial_SerialPort_available0(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_serial_SerialPort
|
||||
* Method: write0
|
||||
* Signature: (JI)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_eclipse_cdt_serial_SerialPort_write0
|
||||
(JNIEnv *, jobject, jlong, jint);
|
||||
JNIEXPORT void JNICALL Java_org_eclipse_cdt_serial_SerialPort_write0(JNIEnv *, jobject, jlong, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_serial_SerialPort
|
||||
* Method: write1
|
||||
* Signature: (J[BII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_eclipse_cdt_serial_SerialPort_write1
|
||||
(JNIEnv *, jobject, jlong, jbyteArray, jint, jint);
|
||||
JNIEXPORT void JNICALL Java_org_eclipse_cdt_serial_SerialPort_write1(JNIEnv *, jobject, jlong, jbyteArray, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_serial_SerialPort
|
||||
* Method: getPortName
|
||||
* Signature: (I)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_serial_SerialPort_getPortName
|
||||
(JNIEnv *, jclass, jint);
|
||||
JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_serial_SerialPort_getPortName(JNIEnv *, jclass, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include <jni.h>
|
||||
#include <org_eclipse_cdt_serial_SerialPort.h>
|
||||
|
||||
#define FUNC(x) Java_org_eclipse_cdt_serial_SerialPort_ ## x
|
||||
#define FUNC(x) Java_org_eclipse_cdt_serial_SerialPort_##x
|
||||
|
||||
/**
|
||||
* Use this method to throw an exception when open fails after the OS open
|
||||
|
@ -51,515 +51,507 @@ static void closeAndthrowIOException(int fd, JNIEnv *env, const char *msg) {
|
|||
#else
|
||||
static void closeAndthrowIOException(HANDLE handle, JNIEnv *env, const char *msg) {
|
||||
#endif
|
||||
char buff[256];
|
||||
char buff[256];
|
||||
#ifndef __MINGW32__
|
||||
sprintf(buff, "%s: %s", msg, strerror(errno));
|
||||
close(fd);
|
||||
sprintf(buff, "%s: %s", msg, strerror(errno));
|
||||
close(fd);
|
||||
#else
|
||||
sprintf_s(buff, sizeof(buff), "%s (%d)", msg, GetLastError());
|
||||
CloseHandle(handle);
|
||||
sprintf_s(buff, sizeof(buff), "%s (%d)", msg, GetLastError());
|
||||
CloseHandle(handle);
|
||||
#endif
|
||||
jclass cls = (*env)->FindClass(env, "java/io/IOException");
|
||||
(*env)->ThrowNew(env, cls, buff);
|
||||
jclass cls = (*env)->FindClass(env, "java/io/IOException");
|
||||
(*env)->ThrowNew(env, cls, buff);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void throwIOException(JNIEnv *env, const char *msg) {
|
||||
char buff[256];
|
||||
char buff[256];
|
||||
#ifndef __MINGW32__
|
||||
sprintf(buff, "%s: %s", msg, strerror(errno));
|
||||
sprintf(buff, "%s: %s", msg, strerror(errno));
|
||||
#else
|
||||
sprintf_s(buff, sizeof(buff), "%s (%d)", msg, GetLastError());
|
||||
sprintf_s(buff, sizeof(buff), "%s (%d)", msg, GetLastError());
|
||||
#endif
|
||||
jclass cls = (*env)->FindClass(env, "java/io/IOException");
|
||||
(*env)->ThrowNew(env, cls, buff);
|
||||
jclass cls = (*env)->FindClass(env, "java/io/IOException");
|
||||
(*env)->ThrowNew(env, cls, buff);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL FUNC(open0)(JNIEnv *env, jobject jobj, jstring portName, jint baudRate, jint byteSize,
|
||||
jint parity, jint stopBits) {
|
||||
jint parity, jint stopBits) {
|
||||
#ifndef __MINGW32__
|
||||
const char *cportName = (*env)->GetStringUTFChars(env, portName, NULL);
|
||||
int fd = open(cportName, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
if (fd < 0) {
|
||||
char msg[256];
|
||||
sprintf(msg, "Error opening %s", cportName);
|
||||
(*env)->ReleaseStringUTFChars(env, portName, cportName);
|
||||
throwIOException(env, msg);
|
||||
return fd;
|
||||
}
|
||||
(*env)->ReleaseStringUTFChars(env, portName, cportName);
|
||||
const char *cportName = (*env)->GetStringUTFChars(env, portName, NULL);
|
||||
int fd = open(cportName, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
if (fd < 0) {
|
||||
char msg[256];
|
||||
sprintf(msg, "Error opening %s", cportName);
|
||||
(*env)->ReleaseStringUTFChars(env, portName, cportName);
|
||||
throwIOException(env, msg);
|
||||
return fd;
|
||||
}
|
||||
(*env)->ReleaseStringUTFChars(env, portName, cportName);
|
||||
|
||||
// Turn off all flags
|
||||
fcntl(fd, F_SETFL, 0);
|
||||
// Turn off all flags
|
||||
fcntl(fd, F_SETFL, 0);
|
||||
|
||||
struct termios options;
|
||||
tcgetattr(fd, &options);
|
||||
options.c_cflag |= (CLOCAL | CREAD);
|
||||
struct termios options;
|
||||
tcgetattr(fd, &options);
|
||||
options.c_cflag |= (CLOCAL | CREAD);
|
||||
|
||||
#ifndef __APPLE__
|
||||
speed_t baud;
|
||||
switch (baudRate) {
|
||||
case 110:
|
||||
baud = B110;
|
||||
break;
|
||||
case 300:
|
||||
baud = B300;
|
||||
break;
|
||||
case 600:
|
||||
baud = B600;
|
||||
break;
|
||||
case 1200:
|
||||
baud = B1200;
|
||||
break;
|
||||
case 2400:
|
||||
baud = B2400;
|
||||
break;
|
||||
case 4800:
|
||||
baud = B4800;
|
||||
break;
|
||||
case 9600:
|
||||
baud = B9600;
|
||||
break;
|
||||
case 19200:
|
||||
baud = B19200;
|
||||
break;
|
||||
case 38400:
|
||||
baud = B38400;
|
||||
break;
|
||||
case 57600:
|
||||
baud = B57600;
|
||||
break;
|
||||
case 115200:
|
||||
baud = B115200;
|
||||
break;
|
||||
case 230400:
|
||||
baud = B230400;
|
||||
break;
|
||||
case 460800:
|
||||
baud = B460800;
|
||||
break;
|
||||
case 500000:
|
||||
baud = B500000;
|
||||
break;
|
||||
case 576000:
|
||||
baud = B576000;
|
||||
break;
|
||||
case 921600:
|
||||
baud = B921600;
|
||||
break;
|
||||
case 1000000:
|
||||
baud = B1000000;
|
||||
break;
|
||||
case 1152000:
|
||||
baud = B1152000;
|
||||
break;
|
||||
case 1500000:
|
||||
baud = B1500000;
|
||||
break;
|
||||
case 2000000:
|
||||
baud = B2000000;
|
||||
break;
|
||||
case 2500000:
|
||||
baud = B2500000;
|
||||
break;
|
||||
case 3000000:
|
||||
baud = B3000000;
|
||||
break;
|
||||
case 3500000:
|
||||
baud = B3500000;
|
||||
break;
|
||||
case 4000000:
|
||||
baud = B4000000;
|
||||
break;
|
||||
default:
|
||||
baud = B0;
|
||||
break;
|
||||
}
|
||||
speed_t baud;
|
||||
switch (baudRate) {
|
||||
case 110:
|
||||
baud = B110;
|
||||
break;
|
||||
case 300:
|
||||
baud = B300;
|
||||
break;
|
||||
case 600:
|
||||
baud = B600;
|
||||
break;
|
||||
case 1200:
|
||||
baud = B1200;
|
||||
break;
|
||||
case 2400:
|
||||
baud = B2400;
|
||||
break;
|
||||
case 4800:
|
||||
baud = B4800;
|
||||
break;
|
||||
case 9600:
|
||||
baud = B9600;
|
||||
break;
|
||||
case 19200:
|
||||
baud = B19200;
|
||||
break;
|
||||
case 38400:
|
||||
baud = B38400;
|
||||
break;
|
||||
case 57600:
|
||||
baud = B57600;
|
||||
break;
|
||||
case 115200:
|
||||
baud = B115200;
|
||||
break;
|
||||
case 230400:
|
||||
baud = B230400;
|
||||
break;
|
||||
case 460800:
|
||||
baud = B460800;
|
||||
break;
|
||||
case 500000:
|
||||
baud = B500000;
|
||||
break;
|
||||
case 576000:
|
||||
baud = B576000;
|
||||
break;
|
||||
case 921600:
|
||||
baud = B921600;
|
||||
break;
|
||||
case 1000000:
|
||||
baud = B1000000;
|
||||
break;
|
||||
case 1152000:
|
||||
baud = B1152000;
|
||||
break;
|
||||
case 1500000:
|
||||
baud = B1500000;
|
||||
break;
|
||||
case 2000000:
|
||||
baud = B2000000;
|
||||
break;
|
||||
case 2500000:
|
||||
baud = B2500000;
|
||||
break;
|
||||
case 3000000:
|
||||
baud = B3000000;
|
||||
break;
|
||||
case 3500000:
|
||||
baud = B3500000;
|
||||
break;
|
||||
case 4000000:
|
||||
baud = B4000000;
|
||||
break;
|
||||
default:
|
||||
baud = B0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (baud == B0) {
|
||||
// Use custom linux baud rates if possible: https://bugs.eclipse.org/bugs/show_bug.cgi?id=543122#c8
|
||||
struct serial_struct serial_options;
|
||||
options.c_cflag |= B38400;
|
||||
if (baud == B0) {
|
||||
// Use custom linux baud rates if possible: https://bugs.eclipse.org/bugs/show_bug.cgi?id=543122#c8
|
||||
struct serial_struct serial_options;
|
||||
options.c_cflag |= B38400;
|
||||
|
||||
if (ioctl(fd, TIOCGSERIAL, &serial_options) != 0) {
|
||||
closeAndthrowIOException(fd, env, "Failed to use custom baud rate. Error using TIOCGSERIAL");
|
||||
return -1;
|
||||
}
|
||||
serial_options.custom_divisor = serial_options.baud_base / baudRate;
|
||||
if (serial_options.custom_divisor == 0) {
|
||||
serial_options.custom_divisor = 1;
|
||||
}
|
||||
if (ioctl(fd, TIOCGSERIAL, &serial_options) != 0) {
|
||||
closeAndthrowIOException(fd, env, "Failed to use custom baud rate. Error using TIOCGSERIAL");
|
||||
return -1;
|
||||
}
|
||||
serial_options.custom_divisor = serial_options.baud_base / baudRate;
|
||||
if (serial_options.custom_divisor == 0) {
|
||||
serial_options.custom_divisor = 1;
|
||||
}
|
||||
|
||||
serial_options.flags &= ~ASYNC_SPD_MASK;
|
||||
serial_options.flags |= ASYNC_SPD_CUST;
|
||||
serial_options.flags &= ~ASYNC_SPD_MASK;
|
||||
serial_options.flags |= ASYNC_SPD_CUST;
|
||||
|
||||
if (ioctl(fd, TIOCSSERIAL, &serial_options) != 0) {
|
||||
closeAndthrowIOException(fd, env, "Failed to use custom baud rate. Error using TIOCSSERIAL");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
// Set baud rate
|
||||
cfsetispeed(&options, baud);
|
||||
cfsetospeed(&options, baud);
|
||||
}
|
||||
if (ioctl(fd, TIOCSSERIAL, &serial_options) != 0) {
|
||||
closeAndthrowIOException(fd, env, "Failed to use custom baud rate. Error using TIOCSSERIAL");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
// Set baud rate
|
||||
cfsetispeed(&options, baud);
|
||||
cfsetospeed(&options, baud);
|
||||
}
|
||||
|
||||
#else
|
||||
// On OSX speed_t is simply the baud rate: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/cfsetispeed.3.html
|
||||
cfsetispeed(&options, baudRate);
|
||||
cfsetospeed(&options, baudRate);
|
||||
// On OSX speed_t is simply the baud rate:
|
||||
// https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/cfsetispeed.3.html
|
||||
cfsetispeed(&options, baudRate);
|
||||
cfsetospeed(&options, baudRate);
|
||||
#endif
|
||||
|
||||
// set data size
|
||||
options.c_cflag &= ~CSIZE;
|
||||
switch (byteSize) {
|
||||
case 5:
|
||||
options.c_cflag |= CS5;
|
||||
break;
|
||||
case 6:
|
||||
options.c_cflag |= CS6;
|
||||
break;
|
||||
case 7:
|
||||
options.c_cflag |= CS7;
|
||||
break;
|
||||
case 8:
|
||||
options.c_cflag |= CS8;
|
||||
break;
|
||||
// set data size
|
||||
options.c_cflag &= ~CSIZE;
|
||||
switch (byteSize) {
|
||||
case 5:
|
||||
options.c_cflag |= CS5;
|
||||
break;
|
||||
case 6:
|
||||
options.c_cflag |= CS6;
|
||||
break;
|
||||
case 7:
|
||||
options.c_cflag |= CS7;
|
||||
break;
|
||||
case 8:
|
||||
options.c_cflag |= CS8;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
// set parity
|
||||
switch (parity) {
|
||||
case 0: // None
|
||||
options.c_cflag &= ~PARENB;
|
||||
break;
|
||||
case 1: // Even
|
||||
options.c_cflag |= PARENB;
|
||||
options.c_cflag &= ~PARODD;
|
||||
break;
|
||||
case 2: // Odd
|
||||
options.c_cflag |= (PARENB | PARODD);
|
||||
break;
|
||||
}
|
||||
|
||||
// set parity
|
||||
switch (parity) {
|
||||
case 0: // None
|
||||
options.c_cflag &= ~PARENB;
|
||||
break;
|
||||
case 1: // Even
|
||||
options.c_cflag |= PARENB;
|
||||
options.c_cflag &= ~PARODD;
|
||||
break;
|
||||
case 2: // Odd
|
||||
options.c_cflag |= (PARENB | PARODD);
|
||||
break;
|
||||
}
|
||||
switch (stopBits) {
|
||||
case 0: // 1
|
||||
options.c_cflag &= ~CSTOPB;
|
||||
break;
|
||||
case 1: // 2
|
||||
options.c_cflag |= CSTOPB;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (stopBits) {
|
||||
case 0: // 1
|
||||
options.c_cflag &= ~CSTOPB;
|
||||
break;
|
||||
case 1: // 2
|
||||
options.c_cflag |= CSTOPB;
|
||||
break;
|
||||
}
|
||||
// raw input
|
||||
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
|
||||
|
||||
// raw input
|
||||
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
|
||||
// ignore parity
|
||||
options.c_iflag |= IGNPAR;
|
||||
|
||||
// ignore parity
|
||||
options.c_iflag |= IGNPAR;
|
||||
// turn off those bits in the input flag that fiddle with CR and NL
|
||||
options.c_iflag &= ~(ICRNL | INLCR | IGNCR);
|
||||
|
||||
// turn off those bits in the input flag that fiddle with CR and NL
|
||||
options.c_iflag &= ~(ICRNL | INLCR | IGNCR);
|
||||
options.c_cc[VMIN] = 0; // min chars to read
|
||||
options.c_cc[VTIME] = 2; // 10ths second timeout
|
||||
|
||||
options.c_cc[VMIN] = 0; // min chars to read
|
||||
options.c_cc[VTIME] = 2; // 10ths second timeout
|
||||
tcflush(fd, TCIFLUSH);
|
||||
tcsetattr(fd, TCSANOW, &options);
|
||||
|
||||
tcflush(fd, TCIFLUSH);
|
||||
tcsetattr(fd, TCSANOW, &options);
|
||||
|
||||
return fd;
|
||||
return fd;
|
||||
#else // __MINGW32__
|
||||
const wchar_t * cportName = (const wchar_t *)(*env)->GetStringChars(env, portName, NULL);
|
||||
HANDLE handle = CreateFile(cportName,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_OVERLAPPED,
|
||||
NULL);
|
||||
(*env)->ReleaseStringChars(env, portName, cportName);
|
||||
const wchar_t *cportName = (const wchar_t *)(*env)->GetStringChars(env, portName, NULL);
|
||||
HANDLE handle =
|
||||
CreateFile(cportName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
|
||||
(*env)->ReleaseStringChars(env, portName, cportName);
|
||||
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
char msg[256];
|
||||
const char * name = (*env)->GetStringUTFChars(env, portName, NULL);
|
||||
sprintf_s(msg, sizeof(msg), "Error opening %s", name);
|
||||
(*env)->ReleaseStringUTFChars(env, portName, name);
|
||||
throwIOException(env, msg);
|
||||
return -1;
|
||||
}
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
char msg[256];
|
||||
const char *name = (*env)->GetStringUTFChars(env, portName, NULL);
|
||||
sprintf_s(msg, sizeof(msg), "Error opening %s", name);
|
||||
(*env)->ReleaseStringUTFChars(env, portName, name);
|
||||
throwIOException(env, msg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
DCB dcb = { 0 };
|
||||
DCB dcb = {0};
|
||||
|
||||
if (!GetCommState(handle, &dcb)) {
|
||||
closeAndthrowIOException(handle, env, "Error getting DCB");
|
||||
return -1;
|
||||
}
|
||||
if (!GetCommState(handle, &dcb)) {
|
||||
closeAndthrowIOException(handle, env, "Error getting DCB");
|
||||
return -1;
|
||||
}
|
||||
|
||||
dcb.BaudRate = baudRate;
|
||||
dcb.ByteSize = (BYTE)byteSize;
|
||||
dcb.BaudRate = baudRate;
|
||||
dcb.ByteSize = (BYTE)byteSize;
|
||||
|
||||
switch (parity) {
|
||||
case 0: // None
|
||||
dcb.fParity = FALSE;
|
||||
dcb.Parity = NOPARITY;
|
||||
break;
|
||||
case 1: // Even
|
||||
dcb.fParity = TRUE;
|
||||
dcb.Parity = EVENPARITY;
|
||||
break;
|
||||
case 2: // Odd
|
||||
dcb.fParity = TRUE;
|
||||
dcb.Parity = ODDPARITY;
|
||||
break;
|
||||
}
|
||||
switch (parity) {
|
||||
case 0: // None
|
||||
dcb.fParity = FALSE;
|
||||
dcb.Parity = NOPARITY;
|
||||
break;
|
||||
case 1: // Even
|
||||
dcb.fParity = TRUE;
|
||||
dcb.Parity = EVENPARITY;
|
||||
break;
|
||||
case 2: // Odd
|
||||
dcb.fParity = TRUE;
|
||||
dcb.Parity = ODDPARITY;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (stopBits) {
|
||||
case 0:
|
||||
dcb.StopBits = ONESTOPBIT;
|
||||
break;
|
||||
case 1:
|
||||
dcb.StopBits = TWOSTOPBITS;
|
||||
break;
|
||||
}
|
||||
switch (stopBits) {
|
||||
case 0:
|
||||
dcb.StopBits = ONESTOPBIT;
|
||||
break;
|
||||
case 1:
|
||||
dcb.StopBits = TWOSTOPBITS;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!SetCommState(handle, &dcb)) {
|
||||
closeAndthrowIOException(handle, env, "Error setting DCB");
|
||||
return -1;
|
||||
}
|
||||
if (!SetCommState(handle, &dcb)) {
|
||||
closeAndthrowIOException(handle, env, "Error setting DCB");
|
||||
return -1;
|
||||
}
|
||||
|
||||
COMMTIMEOUTS timeouts = { 0 };
|
||||
timeouts.ReadIntervalTimeout = MAXDWORD;
|
||||
timeouts.ReadTotalTimeoutMultiplier = MAXDWORD;
|
||||
timeouts.ReadTotalTimeoutConstant = 200;
|
||||
if (!SetCommTimeouts(handle, &timeouts)) {
|
||||
closeAndthrowIOException(handle, env, "Error setting timeouts");
|
||||
return -1;
|
||||
}
|
||||
COMMTIMEOUTS timeouts = {0};
|
||||
timeouts.ReadIntervalTimeout = MAXDWORD;
|
||||
timeouts.ReadTotalTimeoutMultiplier = MAXDWORD;
|
||||
timeouts.ReadTotalTimeoutConstant = 200;
|
||||
if (!SetCommTimeouts(handle, &timeouts)) {
|
||||
closeAndthrowIOException(handle, env, "Error setting timeouts");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef _WIN64
|
||||
return (jlong)handle;
|
||||
return (jlong)handle;
|
||||
#else
|
||||
return (jlong)(unsigned)handle;
|
||||
return (jlong)(unsigned)handle;
|
||||
#endif
|
||||
#endif // __MINGW32__
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL FUNC(close0)
|
||||
(JNIEnv *env, jobject jobj, jlong handle) {
|
||||
JNIEXPORT void JNICALL FUNC(close0)(JNIEnv *env, jobject jobj, jlong handle) {
|
||||
#ifndef __MINGW32__
|
||||
close(handle);
|
||||
close(handle);
|
||||
#else
|
||||
#ifdef _WIN64
|
||||
CloseHandle((HANDLE)handle);
|
||||
CloseHandle((HANDLE)handle);
|
||||
#else
|
||||
CloseHandle((HANDLE)(unsigned)handle);
|
||||
CloseHandle((HANDLE)(unsigned)handle);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL FUNC(available0)(JNIEnv *env, jobject jobj, jlong jhandle) {
|
||||
#ifndef __MINGW32__
|
||||
int result = 0;
|
||||
if (ioctl(jhandle, FIONREAD, &result) < 0) {
|
||||
throwIOException(env, "Error calling ioctl");
|
||||
return 0;
|
||||
}
|
||||
return result;
|
||||
int result = 0;
|
||||
if (ioctl(jhandle, FIONREAD, &result) < 0) {
|
||||
throwIOException(env, "Error calling ioctl");
|
||||
return 0;
|
||||
}
|
||||
return result;
|
||||
#else
|
||||
COMSTAT stat;
|
||||
DWORD errCode;
|
||||
COMSTAT stat;
|
||||
DWORD errCode;
|
||||
#ifdef _WIN64
|
||||
HANDLE handle = (HANDLE)jhandle;
|
||||
HANDLE handle = (HANDLE)jhandle;
|
||||
#else
|
||||
HANDLE handle = (HANDLE)(unsigned)jhandle;
|
||||
HANDLE handle = (HANDLE)(unsigned)jhandle;
|
||||
#endif
|
||||
|
||||
if (ClearCommError(handle, &errCode, &stat) == 0) {
|
||||
throwIOException(env, "Error calling ClearCommError");
|
||||
return -1;
|
||||
}
|
||||
return (int)stat.cbInQue;
|
||||
if (ClearCommError(handle, &errCode, &stat) == 0) {
|
||||
throwIOException(env, "Error calling ClearCommError");
|
||||
return -1;
|
||||
}
|
||||
return (int)stat.cbInQue;
|
||||
#endif
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL FUNC(read1)(JNIEnv *env, jobject jobj, jlong jhandle, jbyteArray bytes, jint offset, jint size) {
|
||||
#ifndef __MINGW32__
|
||||
jbyte buff[256];
|
||||
int n = size < sizeof(buff) ? size : sizeof(buff);
|
||||
n = read(jhandle, buff, n);
|
||||
if (n > 0) {
|
||||
(*env)->SetByteArrayRegion(env, bytes, offset, n, buff);
|
||||
}
|
||||
return n;
|
||||
jbyte buff[256];
|
||||
int n = size < sizeof(buff) ? size : sizeof(buff);
|
||||
n = read(jhandle, buff, n);
|
||||
if (n > 0) {
|
||||
(*env)->SetByteArrayRegion(env, bytes, offset, n, buff);
|
||||
}
|
||||
return n;
|
||||
#else
|
||||
OVERLAPPED olp = { 0 };
|
||||
OVERLAPPED olp = {0};
|
||||
|
||||
olp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
if (olp.hEvent == NULL) {
|
||||
throwIOException(env, "Error creating event");
|
||||
return -1;
|
||||
}
|
||||
olp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
if (olp.hEvent == NULL) {
|
||||
throwIOException(env, "Error creating event");
|
||||
return -1;
|
||||
}
|
||||
|
||||
char buff[256];
|
||||
DWORD nread = sizeof(buff) < size ? sizeof(buff) : size;
|
||||
char buff[256];
|
||||
DWORD nread = sizeof(buff) < size ? sizeof(buff) : size;
|
||||
#ifdef _WIN64
|
||||
HANDLE handle = (HANDLE)jhandle;
|
||||
HANDLE handle = (HANDLE)jhandle;
|
||||
#else
|
||||
HANDLE handle = (HANDLE)(unsigned)jhandle;
|
||||
HANDLE handle = (HANDLE)(unsigned)jhandle;
|
||||
#endif
|
||||
|
||||
if (!ReadFile(handle, buff, sizeof(buff), &nread, &olp)) {
|
||||
if (GetLastError() != ERROR_IO_PENDING) {
|
||||
throwIOException(env, "Error reading from port");
|
||||
CloseHandle(olp.hEvent);
|
||||
return -1;
|
||||
} else {
|
||||
switch (WaitForSingleObject(olp.hEvent, INFINITE)) {
|
||||
case WAIT_OBJECT_0:
|
||||
if (!GetOverlappedResult(handle, &olp, &nread, FALSE)) {
|
||||
if (GetLastError() != ERROR_OPERATION_ABORTED) {
|
||||
throwIOException(env, "Error waiting for read");
|
||||
}
|
||||
CloseHandle(olp.hEvent);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ReadFile(handle, buff, sizeof(buff), &nread, &olp)) {
|
||||
if (GetLastError() != ERROR_IO_PENDING) {
|
||||
throwIOException(env, "Error reading from port");
|
||||
CloseHandle(olp.hEvent);
|
||||
return -1;
|
||||
} else {
|
||||
switch (WaitForSingleObject(olp.hEvent, INFINITE)) {
|
||||
case WAIT_OBJECT_0:
|
||||
if (!GetOverlappedResult(handle, &olp, &nread, FALSE)) {
|
||||
if (GetLastError() != ERROR_OPERATION_ABORTED) {
|
||||
throwIOException(env, "Error waiting for read");
|
||||
}
|
||||
CloseHandle(olp.hEvent);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nread > 0) {
|
||||
(*env)->SetByteArrayRegion(env, bytes, offset, nread, (jbyte *)buff);
|
||||
}
|
||||
CloseHandle(olp.hEvent);
|
||||
return nread;
|
||||
if (nread > 0) {
|
||||
(*env)->SetByteArrayRegion(env, bytes, offset, nread, (jbyte *)buff);
|
||||
}
|
||||
CloseHandle(olp.hEvent);
|
||||
return nread;
|
||||
#endif
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL FUNC(write0)
|
||||
(JNIEnv *env, jobject jobj, jlong jhandle, jint b) {
|
||||
JNIEXPORT void JNICALL FUNC(write0)(JNIEnv *env, jobject jobj, jlong jhandle, jint b) {
|
||||
#ifndef __MINGW32__
|
||||
char buff = b;
|
||||
write(jhandle, &buff, 1);
|
||||
char buff = b;
|
||||
write(jhandle, &buff, 1);
|
||||
#else
|
||||
OVERLAPPED olp = { 0 };
|
||||
OVERLAPPED olp = {0};
|
||||
|
||||
olp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
if (olp.hEvent == NULL) {
|
||||
throwIOException(env, "Error creating event");
|
||||
return;
|
||||
}
|
||||
olp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
if (olp.hEvent == NULL) {
|
||||
throwIOException(env, "Error creating event");
|
||||
return;
|
||||
}
|
||||
|
||||
char buff = (char)b;
|
||||
DWORD nwritten;
|
||||
char buff = (char)b;
|
||||
DWORD nwritten;
|
||||
#ifdef _WIN64
|
||||
HANDLE handle = (HANDLE)jhandle;
|
||||
HANDLE handle = (HANDLE)jhandle;
|
||||
#else
|
||||
HANDLE handle = (HANDLE)(unsigned)jhandle;
|
||||
HANDLE handle = (HANDLE)(unsigned)jhandle;
|
||||
#endif
|
||||
|
||||
if (!WriteFile(handle, &buff, sizeof(buff), &nwritten, &olp)) {
|
||||
if (GetLastError() != ERROR_IO_PENDING) {
|
||||
throwIOException(env, "Error writing to port");
|
||||
}
|
||||
else {
|
||||
switch (WaitForSingleObject(olp.hEvent, INFINITE)) {
|
||||
case WAIT_OBJECT_0:
|
||||
if (!GetOverlappedResult(handle, &olp, &nwritten, FALSE)) {
|
||||
throwIOException(env, "Error waiting for write");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!WriteFile(handle, &buff, sizeof(buff), &nwritten, &olp)) {
|
||||
if (GetLastError() != ERROR_IO_PENDING) {
|
||||
throwIOException(env, "Error writing to port");
|
||||
} else {
|
||||
switch (WaitForSingleObject(olp.hEvent, INFINITE)) {
|
||||
case WAIT_OBJECT_0:
|
||||
if (!GetOverlappedResult(handle, &olp, &nwritten, FALSE)) {
|
||||
throwIOException(env, "Error waiting for write");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle(olp.hEvent);
|
||||
CloseHandle(olp.hEvent);
|
||||
#endif
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL FUNC(write1)(JNIEnv *env, jobject jobj, jlong jhandle, jbyteArray bytes, jint offset, jint size) {
|
||||
JNIEXPORT void JNICALL FUNC(write1)(JNIEnv *env, jobject jobj, jlong jhandle, jbyteArray bytes, jint offset,
|
||||
jint size) {
|
||||
#ifndef __MINGW32__
|
||||
while (size > 0) {
|
||||
jbyte buff[256];
|
||||
int n = size < sizeof(buff) ? size : sizeof(buff);
|
||||
(*env)->GetByteArrayRegion(env, bytes, offset, n, buff);
|
||||
n = write(jhandle, buff, n);
|
||||
if (n < 0) {
|
||||
return;
|
||||
}
|
||||
size -= n;
|
||||
offset += n;
|
||||
}
|
||||
while (size > 0) {
|
||||
jbyte buff[256];
|
||||
int n = size < sizeof(buff) ? size : sizeof(buff);
|
||||
(*env)->GetByteArrayRegion(env, bytes, offset, n, buff);
|
||||
n = write(jhandle, buff, n);
|
||||
if (n < 0) {
|
||||
return;
|
||||
}
|
||||
size -= n;
|
||||
offset += n;
|
||||
}
|
||||
#else
|
||||
OVERLAPPED olp = { 0 };
|
||||
OVERLAPPED olp = {0};
|
||||
|
||||
olp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
if (olp.hEvent == NULL) {
|
||||
throwIOException(env, "Error creating event");
|
||||
return;
|
||||
}
|
||||
olp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
if (olp.hEvent == NULL) {
|
||||
throwIOException(env, "Error creating event");
|
||||
return;
|
||||
}
|
||||
|
||||
while (size > 0) {
|
||||
char buff[256];
|
||||
DWORD nwritten = sizeof(buff) < size ? sizeof(buff) : size;
|
||||
(*env)->GetByteArrayRegion(env, bytes, offset, nwritten, (jbyte *)buff);
|
||||
while (size > 0) {
|
||||
char buff[256];
|
||||
DWORD nwritten = sizeof(buff) < size ? sizeof(buff) : size;
|
||||
(*env)->GetByteArrayRegion(env, bytes, offset, nwritten, (jbyte *)buff);
|
||||
#ifdef _WIN64
|
||||
HANDLE handle = (HANDLE)jhandle;
|
||||
HANDLE handle = (HANDLE)jhandle;
|
||||
#else
|
||||
HANDLE handle = (HANDLE)(unsigned)jhandle;
|
||||
HANDLE handle = (HANDLE)(unsigned)jhandle;
|
||||
#endif
|
||||
|
||||
if (!WriteFile(handle, buff, nwritten, &nwritten, &olp)) {
|
||||
if (GetLastError() != ERROR_IO_PENDING) {
|
||||
throwIOException(env, "Error writing to port");
|
||||
return;
|
||||
} else {
|
||||
switch (WaitForSingleObject(olp.hEvent, INFINITE)) {
|
||||
case WAIT_OBJECT_0:
|
||||
if (!GetOverlappedResult(handle, &olp, &nwritten, FALSE)) {
|
||||
throwIOException(env, "Error waiting for write");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
size -= nwritten;
|
||||
offset += nwritten;
|
||||
}
|
||||
if (!WriteFile(handle, buff, nwritten, &nwritten, &olp)) {
|
||||
if (GetLastError() != ERROR_IO_PENDING) {
|
||||
throwIOException(env, "Error writing to port");
|
||||
return;
|
||||
} else {
|
||||
switch (WaitForSingleObject(olp.hEvent, INFINITE)) {
|
||||
case WAIT_OBJECT_0:
|
||||
if (!GetOverlappedResult(handle, &olp, &nwritten, FALSE)) {
|
||||
throwIOException(env, "Error waiting for write");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
size -= nwritten;
|
||||
offset += nwritten;
|
||||
}
|
||||
|
||||
CloseHandle(olp.hEvent);
|
||||
CloseHandle(olp.hEvent);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __MINGW32__
|
||||
JNIEXPORT jstring FUNC(getPortName)(JNIEnv *env, jclass cls, jint i)
|
||||
{
|
||||
HKEY key;
|
||||
JNIEXPORT jstring FUNC(getPortName)(JNIEnv *env, jclass cls, jint i) {
|
||||
HKEY key;
|
||||
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"HARDWARE\\DEVICEMAP\\SERIALCOMM", 0, KEY_READ, &key) != ERROR_SUCCESS) {
|
||||
// There are none
|
||||
return NULL;
|
||||
}
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"HARDWARE\\DEVICEMAP\\SERIALCOMM", 0, KEY_READ, &key) != ERROR_SUCCESS) {
|
||||
// There are none
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wchar_t name[256];
|
||||
DWORD len = sizeof(name);
|
||||
LONG rc = RegEnumValue(key, (DWORD)i, name, &len, NULL, NULL, NULL, NULL);
|
||||
if (rc != ERROR_SUCCESS) {
|
||||
if (rc != ERROR_NO_MORE_ITEMS) {
|
||||
throwIOException(env, "Can not enum value");
|
||||
}
|
||||
RegCloseKey(key);
|
||||
return NULL;
|
||||
}
|
||||
wchar_t name[256];
|
||||
DWORD len = sizeof(name);
|
||||
LONG rc = RegEnumValue(key, (DWORD)i, name, &len, NULL, NULL, NULL, NULL);
|
||||
if (rc != ERROR_SUCCESS) {
|
||||
if (rc != ERROR_NO_MORE_ITEMS) {
|
||||
throwIOException(env, "Can not enum value");
|
||||
}
|
||||
RegCloseKey(key);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wchar_t value[256];
|
||||
DWORD type;
|
||||
len = sizeof(value);
|
||||
if (RegQueryValueEx(key, name, NULL, &type, (BYTE *)value, &len) != ERROR_SUCCESS) {
|
||||
throwIOException(env, "Can not query value");
|
||||
RegCloseKey(key);
|
||||
return NULL;
|
||||
}
|
||||
wchar_t value[256];
|
||||
DWORD type;
|
||||
len = sizeof(value);
|
||||
if (RegQueryValueEx(key, name, NULL, &type, (BYTE *)value, &len) != ERROR_SUCCESS) {
|
||||
throwIOException(env, "Can not query value");
|
||||
RegCloseKey(key);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jstring result = (*env)->NewString(env, (jchar *)value, (jsize) wcslen(value));
|
||||
RegCloseKey(key);
|
||||
return result;
|
||||
jstring result = (*env)->NewString(env, (jchar *)value, (jsize)wcslen(value));
|
||||
RegCloseKey(key);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
|
Binary file not shown.
|
@ -88,24 +88,6 @@ git ls-files -- \*\*/.project ":!$COREPROJECT/.project" | while read i ; do
|
|||
else
|
||||
rm -f $d/.settings/org.eclipse.pde*.prefs
|
||||
fi
|
||||
|
||||
# CDT (native code)
|
||||
if [[ $natures == *"org.eclipse.cdt.core.cnature"* ]]; then
|
||||
cp $COREPROJECT/.settings/org.eclipse.cdt.*.prefs $d/.settings
|
||||
if echo $i | grep -E '\.tests?[/\.]' > /dev/null; then
|
||||
# Disable indexer for test plugins
|
||||
sed -i '
|
||||
/^eclipse.preferences.version/ {
|
||||
p # Print line
|
||||
i indexer/indexerId=org.eclipse.cdt.core.nullindexer
|
||||
i indexerId=org.eclipse.cdt.core.nullindexer
|
||||
i instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
|
||||
d # Already printed
|
||||
}' $d/.settings/org.eclipse.cdt.core.prefs
|
||||
fi
|
||||
else
|
||||
rm -f $d/.settings/org.eclipse.cdt.*.prefs
|
||||
fi
|
||||
done
|
||||
|
||||
##
|
||||
|
|
|
@ -23,14 +23,9 @@ for p in native/org.eclipse.cdt.native.serial core/org.eclipse.cdt.core.native;
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Disabled until https://bugs.eclipse.org/bugs/show_bug.cgi?id=568137 is resolved
|
||||
# # Need to apply format after header files are generated
|
||||
# tmpws=$(mktemp -d)
|
||||
# ${ECLIPSE:-~/buildtools/eclipse-cpp-2020-09/eclipse} \
|
||||
# -consolelog -nosplash -application org.eclipse.cdt.core.CodeFormatter \
|
||||
# -config $p/.settings/org.eclipse.cdt.core.prefs \
|
||||
# $p/native_src -verbose -data $tmpws
|
||||
# rm -rf $tmpws
|
||||
# Need to apply format after header files are generated
|
||||
echo "Applying enforcing formatting rules to $p native source files"
|
||||
clang-format -i --style=file $(git ls-files $p/native_src/\*\*/\*.{c,cpp,cc,h,hh,hpp})
|
||||
|
||||
echo "Rebuilding $p natives to make sure they match source"
|
||||
logfile=make-natives-${p//\//-}.log
|
||||
|
|
Loading…
Add table
Reference in a new issue