1 /* 2 * Copyright (C) 2005-2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <stdio.h> 20 21 /* 22 * The opaque context 23 */ 24 typedef struct android_logcat_context_internal* android_logcat_context; 25 26 /* Creates a context associated with this logcat instance 27 * 28 * Returns a pointer to the context, or a NULL on error. 29 */ 30 android_logcat_context create_android_logcat(); 31 32 /* Collects and outputs the logcat data to output and error file descriptors 33 * 34 * Will block, performed in-thread and in-process 35 * 36 * The output file descriptor variable, if greater than or equal to 0, is 37 * where the output (ie: stdout) will be sent. The file descriptor is closed 38 * on android_logcat_destroy which terminates the instance, or when an -f flag 39 * (output redirect to a file) is present in the command. The error file 40 * descriptor variable, if greater than or equal to 0, is where the error 41 * stream (ie: stderr) will be sent, also closed on android_logcat_destroy. 42 * The error file descriptor can be set to equal to the output file descriptor, 43 * which will mix output and error stream content, and will defer closure of 44 * the file descriptor on -f flag redirection. Negative values for the file 45 * descriptors will use stdout and stderr FILE references respectively 46 * internally, and will not close the references as noted above. 47 * 48 * Return value is 0 for success, non-zero for errors. 49 */ 50 int android_logcat_run_command(android_logcat_context ctx, int output, int error, int argc, 51 char* const* argv, char* const* envp); 52 53 /* Finished with context 54 * 55 * Kill the command thread ASAP (if any), and free up all associated resources. 56 * 57 * Return value is the result of the android_logcat_run_command, or 58 * non-zero for any errors. 59 */ 60 int android_logcat_destroy(android_logcat_context* ctx); 61