logcat.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #pragma once
  17. #include <stdio.h>
  18. /*
  19. * The opaque context
  20. */
  21. typedef struct android_logcat_context_internal* android_logcat_context;
  22. /* Creates a context associated with this logcat instance
  23. *
  24. * Returns a pointer to the context, or a NULL on error.
  25. */
  26. android_logcat_context create_android_logcat();
  27. /* Collects and outputs the logcat data to output and error file descriptors
  28. *
  29. * Will block, performed in-thread and in-process
  30. *
  31. * The output file descriptor variable, if greater than or equal to 0, is
  32. * where the output (ie: stdout) will be sent. The file descriptor is closed
  33. * on android_logcat_destroy which terminates the instance, or when an -f flag
  34. * (output redirect to a file) is present in the command. The error file
  35. * descriptor variable, if greater than or equal to 0, is where the error
  36. * stream (ie: stderr) will be sent, also closed on android_logcat_destroy.
  37. * The error file descriptor can be set to equal to the output file descriptor,
  38. * which will mix output and error stream content, and will defer closure of
  39. * the file descriptor on -f flag redirection. Negative values for the file
  40. * descriptors will use stdout and stderr FILE references respectively
  41. * internally, and will not close the references as noted above.
  42. *
  43. * Return value is 0 for success, non-zero for errors.
  44. */
  45. int android_logcat_run_command(android_logcat_context ctx, int output, int error, int argc,
  46. char* const* argv, char* const* envp);
  47. /* Finished with context
  48. *
  49. * Kill the command thread ASAP (if any), and free up all associated resources.
  50. *
  51. * Return value is the result of the android_logcat_run_command, or
  52. * non-zero for any errors.
  53. */
  54. int android_logcat_destroy(android_logcat_context* ctx);