/src/wrappers/glib/library/utilities/glib_shell_related_utilities.e

http://github.com/tybor/Liberty · Specman e · 120 lines · 2 code · 33 blank · 85 comment · 0 complexity · 2d17d1f1c2dea414abe670503a14abcb MD5 · raw file

  1. deferred class GLIB_SHELL_RELATED_UTILITIES
  2. -- Shell-related Utilities
  3. -- Shell-related Utilities -- shell-like commandline handling.
  4. -- Synopsis
  5. -- #include <glib.h>
  6. -- enum GShellError;
  7. -- #define G_SHELL_ERROR
  8. -- gboolean g_shell_parse_argv (const gchar *command_line,
  9. -- gint *argcp,
  10. -- gchar ***argvp,
  11. -- GError **error);
  12. -- gchar* g_shell_quote (const gchar *unquoted_string);
  13. -- gchar* g_shell_unquote (const gchar *quoted_string,
  14. -- GError **error);
  15. -- Description
  16. -- Details
  17. -- enum GShellError
  18. -- typedef enum
  19. -- {
  20. -- /* mismatched or otherwise mangled quoting */
  21. -- G_SHELL_ERROR_BAD_QUOTING,
  22. -- /* string to be parsed was empty */
  23. -- G_SHELL_ERROR_EMPTY_STRING,
  24. -- G_SHELL_ERROR_FAILED
  25. -- } GShellError;
  26. -- Error codes returned by shell functions.
  27. -- G_SHELL_ERROR_BAD_QUOTING Mismatched or otherwise mangled quoting.
  28. -- G_SHELL_ERROR_EMPTY_STRING String to be parsed was empty.
  29. -- G_SHELL_ERROR_FAILED Some other error.
  30. -- ---------------------------------------------------------------------------------
  31. -- G_SHELL_ERROR
  32. -- #define G_SHELL_ERROR g_shell_error_quark ()
  33. -- Error domain for shell functions. Errors in this domain will be from the
  34. -- GShellError enumeration. See GError for information on error domains.
  35. -- ---------------------------------------------------------------------------------
  36. -- g_shell_parse_argv ()
  37. -- gboolean g_shell_parse_argv (const gchar *command_line,
  38. -- gint *argcp,
  39. -- gchar ***argvp,
  40. -- GError **error);
  41. -- Parses a command line into an argument vector, in much the same way the shell
  42. -- would, but without many of the expansions the shell would perform (variable
  43. -- expansion, globs, operators, filename expansion, etc. are not supported). The
  44. -- results are defined to be the same as those you would get from a UNIX98 /bin/sh,
  45. -- as long as the input contains none of the unsupported shell expansions. If the
  46. -- input does contain such expansions, they are passed through literally. Possible
  47. -- errors are those from the G_SHELL_ERROR domain. Free the returned vector with
  48. -- g_strfreev().
  49. -- command_line : command line to parse
  50. -- argcp : return location for number of args
  51. -- argvp : return location for array of args
  52. -- error : return location for error
  53. -- Returns : TRUE on success, FALSE if error set
  54. -- ---------------------------------------------------------------------------------
  55. -- g_shell_quote ()
  56. -- gchar* g_shell_quote (const gchar *unquoted_string);
  57. -- Quotes a string so that the shell (/bin/sh) will interpret the quoted string to
  58. -- mean unquoted_string. If you pass a filename to the shell, for example, you
  59. -- should first quote it with this function. The return value must be freed with
  60. -- g_free(). The quoting style used is undefined (single or double quotes may be
  61. -- used).
  62. -- unquoted_string : a literal string
  63. -- Returns : quoted string
  64. -- ---------------------------------------------------------------------------------
  65. -- g_shell_unquote ()
  66. -- gchar* g_shell_unquote (const gchar *quoted_string,
  67. -- GError **error);
  68. -- Unquotes a string as the shell (/bin/sh) would. Only handles quotes; if a string
  69. -- contains file globs, arithmetic operators, variables, backticks, redirections, or
  70. -- other special-to-the-shell features, the result will be different from the result
  71. -- a real shell would produce (the variables, backticks, etc. will be passed through
  72. -- literally instead of being expanded). This function is guaranteed to succeed if
  73. -- applied to the result of g_shell_quote(). If it fails, it returns NULL and sets
  74. -- the error. The quoted_string need not actually contain quoted or escaped text;
  75. -- g_shell_unquote() simply goes through the string and unquotes/unescapes anything
  76. -- that the shell would. Both single and double quotes are handled, as are escapes
  77. -- including escaped newlines. The return value must be freed with g_free().
  78. -- Possible errors are in the G_SHELL_ERROR domain.
  79. -- Shell quoting rules are a bit strange. Single quotes preserve the literal string
  80. -- exactly. escape sequences are not allowed; not even \' - if you want a ' in the
  81. -- quoted text, you have to do something like 'foo'\''bar'. Double quotes allow $,
  82. -- `, ", \, and newline to be escaped with backslash. Otherwise double quotes
  83. -- preserve things literally.
  84. -- quoted_string : shell-quoted string
  85. -- error : error return location or NULL
  86. -- Returns : an unquoted string
  87. end -- class GLIB_SHELL_RELATED_UTILITIES