mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
tools/: removing -compprep and -complete
Original commit message from CVS: * tools/Makefile.am: * tools/gst-complete.1.in: * tools/gst-complete.c: * tools/gst-compprep.1.in: * tools/gst-compprep.c: removing -compprep and -complete
This commit is contained in:
parent
3ea45adb90
commit
37d00e42f8
6 changed files with 10 additions and 463 deletions
|
@ -1,3 +1,12 @@
|
|||
2005-11-29 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* tools/Makefile.am:
|
||||
* tools/gst-complete.1.in:
|
||||
* tools/gst-complete.c:
|
||||
* tools/gst-compprep.1.in:
|
||||
* tools/gst-compprep.c:
|
||||
removing -compprep and -complete
|
||||
|
||||
2005-11-29 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* gst/gstevent.c: (gst_event_new_new_segment),
|
||||
|
|
|
@ -4,10 +4,8 @@ if GST_DISABLE_LOADSAVE
|
|||
GST_LOADSAVE_SRC =
|
||||
GST_LOADSAVE_SRC_V =
|
||||
else
|
||||
GST_LOADSAVE_SRC = gst-complete gst-compprep gst-xmllaunch
|
||||
GST_LOADSAVE_SRC = gst-xmllaunch
|
||||
GST_LOADSAVE_SRC_V = \
|
||||
gst-complete-@GST_MAJORMINOR@ \
|
||||
gst-compprep-@GST_MAJORMINOR@ \
|
||||
gst-xmllaunch-@GST_MAJORMINOR@
|
||||
endif
|
||||
|
||||
|
@ -33,12 +31,6 @@ bin_SCRIPTS = gst-feedback-@GST_MAJORMINOR@
|
|||
|
||||
# make sure each versioned tool has the right source file and flags
|
||||
if !GST_DISABLE_LOADSAVE
|
||||
gst_complete_@GST_MAJORMINOR@_SOURCES = gst-complete.c
|
||||
gst_complete_@GST_MAJORMINOR@_CFLAGS = $(GST_OBJ_CFLAGS)
|
||||
gst_complete_@GST_MAJORMINOR@_LDFLAGS = $(GST_OBJ_LIBS)
|
||||
gst_compprep_@GST_MAJORMINOR@_SOURCES = gst-compprep.c
|
||||
gst_compprep_@GST_MAJORMINOR@_CFLAGS = $(GST_OBJ_CFLAGS)
|
||||
gst_compprep_@GST_MAJORMINOR@_LDFLAGS = $(GST_OBJ_LIBS)
|
||||
gst_xmllaunch_@GST_MAJORMINOR@_SOURCES = gst-launch.c
|
||||
gst_xmllaunch_@GST_MAJORMINOR@_CFLAGS = $(GST_OBJ_CFLAGS)
|
||||
gst_xmllaunch_@GST_MAJORMINOR@_LDFLAGS = $(GST_OBJ_LIBS)
|
||||
|
@ -65,8 +57,6 @@ gst-feedback-@GST_MAJORMINOR@: gst-feedback-m.m
|
|||
|
||||
# make sure each unversioned tool comes from gst-run.c
|
||||
if !GST_DISABLE_LOADSAVE
|
||||
gst_complete_SOURCES = gst-run.c
|
||||
gst_compprep_SOURCES = gst-run.c
|
||||
gst_xmllaunch_SOURCES = gst-run.c
|
||||
endif
|
||||
gst_feedback_SOURCES = gst-run.c
|
||||
|
@ -87,8 +77,6 @@ if GST_DISABLE_LOADSAVE
|
|||
GST_LOADSAVE_MAN=
|
||||
else
|
||||
GST_LOADSAVE_MAN = \
|
||||
gst-complete-@GST_MAJORMINOR@.1 \
|
||||
gst-compprep-@GST_MAJORMINOR@.1 \
|
||||
gst-xmllaunch-@GST_MAJORMINOR@.1
|
||||
endif
|
||||
|
||||
|
@ -110,8 +98,6 @@ noinst_SCRIPTS = gst-indent
|
|||
|
||||
EXTRA_DIST = \
|
||||
$(noinst_SCRIPTS) \
|
||||
gst-complete.1.in \
|
||||
gst-compprep.1.in \
|
||||
gst-feedback.1.in \
|
||||
gst-inspect.1.in \
|
||||
gst-launch.1.in \
|
||||
|
@ -123,8 +109,6 @@ EXTRA_DIST = \
|
|||
|
||||
%-@GST_MAJORMINOR@.1: %.1.in
|
||||
sed \
|
||||
-e s,gst-complete,gst-complete-@GST_MAJORMINOR@,g \
|
||||
-e s,gst-compprep,gst-compprep-@GST_MAJORMINOR@,g \
|
||||
-e s,gst-feedback,gst-feedback-@GST_MAJORMINOR@,g \
|
||||
-e s,gst-inspect,gst-inspect-@GST_MAJORMINOR@,g \
|
||||
-e s,gst-launch,gst-launch-@GST_MAJORMINOR@,g \
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
.TH GStreamer 1 "June 2001"
|
||||
.SH NAME
|
||||
gst\-complete - do bash completion for gst\-launch command\-lines
|
||||
.SH SYNOPSIS
|
||||
.B complete -C gst\-complete gst\-launch
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
\fIgst\-complete\fP is a utility enabling bash to provide
|
||||
context sensitive tab completion for \fIgst\-launch\fP command\-lines.
|
||||
.
|
||||
See the man page for \fIgst\-launch\fP for the syntax of \fIgst\-launch\fP
|
||||
command\-lines.
|
||||
.
|
||||
You must have a version of bash which supports programmable completion.
|
||||
Versions of bash which support this provide the \fIcomplete\fP builtin
|
||||
command.
|
||||
.
|
||||
.SH USAGE
|
||||
Generate the registry of available plugins by running
|
||||
\fIgst\-compprep\fP.
|
||||
.
|
||||
In your .bash_profile or other appropriate place, run
|
||||
.TP 8
|
||||
.B complete -C gst\-complete gst\-launch
|
||||
.SH SEE ALSO
|
||||
.BR gst\-compprep (1),
|
||||
.BR gst\-launch (1),
|
||||
.BR gst\-register (1),
|
||||
.BR gst\-inspect (1),
|
||||
.SH AUTHOR
|
||||
The GStreamer team at http://gstreamer.net/
|
|
@ -1,254 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <locale.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar *name;
|
||||
GSList *srcpads;
|
||||
GSList *sinkpads;
|
||||
GSList *srcpadtemplates;
|
||||
GSList *sinkpadtemplates;
|
||||
GSList *arguments;
|
||||
}
|
||||
comp_element;
|
||||
|
||||
enum
|
||||
{
|
||||
ARG_INT,
|
||||
ARG_FILENAME,
|
||||
ARG_ENUM
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar *name;
|
||||
int type;
|
||||
GSList *enums;
|
||||
}
|
||||
comp_argument;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gint value;
|
||||
gchar *nick;
|
||||
}
|
||||
enum_value;
|
||||
|
||||
|
||||
void
|
||||
print_match_list (gchar * prefix, int len, GSList * wordlist)
|
||||
{
|
||||
GSList *words = wordlist;
|
||||
|
||||
while (words) {
|
||||
if (!len || !strncmp ((gchar *) (words->data), prefix, len))
|
||||
printf ("%s\n", (gchar *) (words->data));
|
||||
words = g_slist_next (words);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
match_element (comp_element * element, gchar * name)
|
||||
{
|
||||
return strcmp (element->name, name);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
xmlDocPtr doc;
|
||||
xmlNodePtr rootnode, elementnode, propnode, argnode;
|
||||
GList *element_list = NULL;
|
||||
comp_element *element;
|
||||
GSList *element_names = NULL;
|
||||
comp_argument *argument;
|
||||
enum_value *option;
|
||||
|
||||
gchar *prev_word;
|
||||
gchar *partial_word;
|
||||
int partial_len;
|
||||
GList *elements;
|
||||
GSList *pads;
|
||||
int num_pads;
|
||||
GSList *args;
|
||||
gchar *word;
|
||||
GSList *words = NULL;
|
||||
|
||||
struct stat stat_buf;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
if (argc < 4) {
|
||||
fprintf (stderr, "gst-complete called with invalid arguments\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
prev_word = argv[3];
|
||||
partial_word = argv[2];
|
||||
|
||||
partial_len = strlen (partial_word);
|
||||
|
||||
/***** Loading the completion information from the registry *****/
|
||||
|
||||
if (stat (GST_CACHE_DIR "/compreg.xml", &stat_buf) == 0) {
|
||||
doc = xmlParseFile (GST_CACHE_DIR "/compreg.xml");
|
||||
} else {
|
||||
exit (1);
|
||||
}
|
||||
rootnode = doc->xmlRootNode;
|
||||
|
||||
elementnode = rootnode->xmlChildrenNode;
|
||||
while (elementnode) {
|
||||
if (!strcmp ((char *) elementnode->name, "element")) {
|
||||
element = g_new0 (comp_element, 1);
|
||||
propnode = elementnode->xmlChildrenNode;
|
||||
while (propnode) {
|
||||
|
||||
if (!strcmp ((char *) propnode->name, "name")) {
|
||||
element->name = (gchar *) xmlNodeGetContent (propnode);
|
||||
/* fprintf(stderr,element->name); */
|
||||
} else if (!strcmp ((char *) propnode->name, "srcpad")) {
|
||||
element->srcpads =
|
||||
g_slist_prepend (element->srcpads, xmlNodeGetContent (propnode));
|
||||
/* fprintf(stderr,"."); */
|
||||
} else if (!strcmp ((char *) propnode->name, "sinkpad")) {
|
||||
element->sinkpads =
|
||||
g_slist_prepend (element->sinkpads, xmlNodeGetContent (propnode));
|
||||
} else if (!strcmp ((char *) propnode->name, "srcpadtemplate")) {
|
||||
element->srcpadtemplates =
|
||||
g_slist_prepend (element->srcpadtemplates,
|
||||
xmlNodeGetContent (propnode));
|
||||
/* fprintf(stderr,"."); */
|
||||
} else if (!strcmp ((char *) propnode->name, "sinkpad")) {
|
||||
element->sinkpadtemplates =
|
||||
g_slist_prepend (element->sinkpadtemplates,
|
||||
xmlNodeGetContent (propnode));
|
||||
} else if (!strcmp ((char *) propnode->name, "argument")) {
|
||||
argument = g_new0 (comp_argument, 1);
|
||||
argument->name = (gchar *) xmlNodeGetContent (propnode);
|
||||
argument->type = ARG_INT;
|
||||
|
||||
/* walk through the values data */
|
||||
argnode = propnode->xmlChildrenNode;
|
||||
while (argnode) {
|
||||
if (!strcmp ((char *) argnode->name, "filename")) {
|
||||
argument->type = ARG_FILENAME;
|
||||
} else if (!strcmp ((char *) argnode->name, "option")) {
|
||||
argument->type = ARG_ENUM;
|
||||
option = g_new0 (enum_value, 1);
|
||||
if (sscanf ((char *) xmlNodeGetContent (argnode), "%d",
|
||||
&option->value) != 1) {
|
||||
g_warning ("Could not read option");
|
||||
g_free (option);
|
||||
} else {
|
||||
argument->enums = g_slist_prepend (argument->enums, option);
|
||||
}
|
||||
}
|
||||
argnode = argnode->next;
|
||||
}
|
||||
|
||||
element->arguments = g_slist_prepend (element->arguments, argument);
|
||||
}
|
||||
|
||||
propnode = propnode->next;
|
||||
}
|
||||
element_list = g_list_prepend (element_list, element);
|
||||
element_names = g_slist_prepend (element_names, element->name);
|
||||
}
|
||||
elementnode = elementnode->next;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***** Completion *****/
|
||||
|
||||
/* The bulk of the work is in deciding exactly which words are an option. */
|
||||
|
||||
/* if we're right at the beginning, with -launch in the first word */
|
||||
if (strstr (prev_word, "-launch")) {
|
||||
/* print out only elements with no sink pad or padtemplate */
|
||||
elements = element_list;
|
||||
while (elements) {
|
||||
element = (comp_element *) (elements->data);
|
||||
if (!element->sinkpads && !element->sinkpadtemplates)
|
||||
words = g_slist_prepend (words, element->name);
|
||||
elements = g_list_next (elements);
|
||||
}
|
||||
}
|
||||
|
||||
/* if the previous word is a connection */
|
||||
if (strchr (prev_word, '!')) {
|
||||
/* print out oly elements with a sink pad or template */
|
||||
elements = element_list;
|
||||
while (elements) {
|
||||
element = (comp_element *) (elements->data);
|
||||
if (element->sinkpads || element->sinkpadtemplates)
|
||||
words = g_slist_prepend (words, element->name);
|
||||
elements = g_list_next (elements);
|
||||
}
|
||||
}
|
||||
|
||||
/* if the partial word is an argument, and it's an enum */
|
||||
if (strchr (prev_word, '=')) {
|
||||
fprintf (stderr, "it's an arg, but dunno what element yet\n");
|
||||
}
|
||||
|
||||
/* if the previous word is an element, we need to list both pads and arguments */
|
||||
if ((elements =
|
||||
g_list_find_custom (element_list, prev_word,
|
||||
(GCompareFunc) match_element))) {
|
||||
element = elements->data;
|
||||
/* zero the numpads list so we can count them */
|
||||
num_pads = 0;
|
||||
|
||||
/* pads */
|
||||
pads = element->srcpads;
|
||||
while (pads) {
|
||||
num_pads++;
|
||||
words =
|
||||
g_slist_prepend (words, g_strdup_printf ("%s!",
|
||||
(gchar *) (pads->data)));
|
||||
pads = g_slist_next (pads);
|
||||
}
|
||||
|
||||
/* padtemplates */
|
||||
pads = element->srcpadtemplates;
|
||||
while (pads) {
|
||||
num_pads++;
|
||||
word = g_strdup_printf ("%s!", (gchar *) (pads->data));
|
||||
if (!g_slist_find_custom (words, word, (GCompareFunc) strcmp))
|
||||
words = g_slist_prepend (words, word);
|
||||
pads = g_slist_next (pads);
|
||||
}
|
||||
|
||||
/* if there is only one pad, add '!' to the list of completions */
|
||||
if (num_pads == 1) {
|
||||
words = g_slist_prepend (words, "!");
|
||||
}
|
||||
|
||||
/* arguments */
|
||||
args = element->arguments;
|
||||
while (args) {
|
||||
argument = (comp_argument *) (args->data);
|
||||
word = strstr (argument->name, "::") + 2;
|
||||
words = g_slist_prepend (words, g_strdup_printf ("%s=", word));
|
||||
words = g_slist_prepend (words, g_strdup_printf ("%s=...", word));
|
||||
args = g_slist_next (args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* The easy part is ouptuting the correct list of possibilities. */
|
||||
print_match_list (partial_word, partial_len, words);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
.TH "gst-compprep" "1" "0.2.0" "Richard Boulton" "GStreamer"
|
||||
.SH "NAME"
|
||||
gst\-compprep \- create the registry for gst\-complete
|
||||
.SH "SYNOPSIS"
|
||||
gst\-compprep
|
||||
.SH "DESCRIPTION"
|
||||
.LP
|
||||
\fIgst\-compprep\fR builds a registry of GStreamer elements and their
|
||||
features that is used by \fIgst\-complete\fR to perform context-sensitive
|
||||
tab completion of \fIgst\-launch\fR command lines.
|
||||
.LP
|
||||
By default, the registry is stored in /etc/gstreamer/compreg.xml
|
||||
.SH "USAGE"
|
||||
Whenever the available gstreamer plugins are modified, the registry should
|
||||
be regenerated by running \fIgst\-compprep\fP as root.
|
||||
.SH "FILES"
|
||||
.TP 8
|
||||
/etc/gstreamer/compreg.xml
|
||||
Registry generated by \fIgst\-compprep\fP and used by \fIgst\-complete\fP.
|
||||
.SH "SEE ALSO"
|
||||
.BR gst\-complete (1),
|
||||
.BR gst\-launch (1),
|
||||
.BR gst\-register (1),
|
||||
.BR gst\-inspect (1),
|
||||
.SH "AUTHOR"
|
||||
The GStreamer team at http://gstreamer.net/
|
|
@ -1,135 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (debug_compprep);
|
||||
#define GST_CAT_DEFAULT debug_compprep
|
||||
#define GST_COMPREG_FILE (GST_CACHE_DIR "/compreg.xml")
|
||||
|
||||
#ifdef HAVE_LIBXML2
|
||||
#if LIBXML_VERSION >= 20600
|
||||
void
|
||||
handle_xmlerror (void *userData, xmlErrorPtr error)
|
||||
{
|
||||
g_print ("Error writing the completion registry: %s, %s\n", GST_COMPREG_FILE,
|
||||
error->message);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
xmlDocPtr doc;
|
||||
xmlNodePtr factorynode, padnode, argnode, optionnode;
|
||||
GList *element_factories, *padtemplates, *g;
|
||||
const GList *pads;
|
||||
GstElement *element;
|
||||
GstPad *pad;
|
||||
GstStaticPadTemplate *padtemplate;
|
||||
GParamSpec **property_specs;
|
||||
guint num_properties, i;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
gst_init (&argc, &argv);
|
||||
GST_DEBUG_CATEGORY_INIT (debug_compprep, "compprep", GST_DEBUG_BOLD,
|
||||
"gst-compprep application");
|
||||
|
||||
doc = xmlNewDoc ((xmlChar *) "1.0");
|
||||
doc->xmlRootNode = xmlNewDocNode (doc, NULL,
|
||||
(xmlChar *) "GST-CompletionRegistry", NULL);
|
||||
|
||||
element_factories =
|
||||
gst_registry_get_feature_list (gst_registry_get_default (),
|
||||
GST_TYPE_ELEMENT_FACTORY);
|
||||
for (g = element_factories; g; g = g_list_next (g)) {
|
||||
GstElementFactory *factory;
|
||||
|
||||
factory = GST_ELEMENT_FACTORY (g->data);
|
||||
|
||||
factorynode = xmlNewChild (doc->xmlRootNode, NULL, (xmlChar *) "element",
|
||||
NULL);
|
||||
xmlNewChild (factorynode, NULL, (xmlChar *) "name",
|
||||
(xmlChar *) GST_PLUGIN_FEATURE_NAME (factory));
|
||||
|
||||
element = gst_element_factory_create (factory, NULL);
|
||||
GST_DEBUG ("adding factory %s", GST_PLUGIN_FEATURE_NAME (factory));
|
||||
if (element == NULL) {
|
||||
GST_ERROR ("couldn't construct element from factory %s\n",
|
||||
gst_object_get_name (GST_OBJECT (factory)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* write out the padtemplates */
|
||||
padtemplates = factory->staticpadtemplates;
|
||||
while (padtemplates) {
|
||||
padtemplate = (GstStaticPadTemplate *) (padtemplates->data);
|
||||
padtemplates = g_list_next (padtemplates);
|
||||
|
||||
if (padtemplate->direction == GST_PAD_SRC)
|
||||
padnode =
|
||||
xmlNewChild (factorynode, NULL, (xmlChar *) "srcpadtemplate",
|
||||
(xmlChar *) padtemplate->name_template);
|
||||
else if (padtemplate->direction == GST_PAD_SINK)
|
||||
padnode =
|
||||
xmlNewChild (factorynode, NULL, (xmlChar *) "sinkpadtemplate",
|
||||
(xmlChar *) padtemplate->name_template);
|
||||
}
|
||||
|
||||
pads = element->pads;
|
||||
while (pads) {
|
||||
pad = (GstPad *) (pads->data);
|
||||
pads = g_list_next (pads);
|
||||
|
||||
if (GST_PAD_DIRECTION (pad) == GST_PAD_SRC)
|
||||
padnode = xmlNewChild (factorynode, NULL, (xmlChar *) "srcpad",
|
||||
(xmlChar *) GST_PAD_NAME (pad));
|
||||
else if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK)
|
||||
padnode = xmlNewChild (factorynode, NULL, (xmlChar *) "sinkpad",
|
||||
(xmlChar *) GST_PAD_NAME (pad));
|
||||
}
|
||||
|
||||
/* write out the args */
|
||||
property_specs =
|
||||
g_object_class_list_properties (G_OBJECT_GET_CLASS (element),
|
||||
&num_properties);
|
||||
for (i = 0; i < num_properties; i++) {
|
||||
GParamSpec *param = property_specs[i];
|
||||
|
||||
argnode = xmlNewChild (factorynode, NULL, (xmlChar *) "argument",
|
||||
(xmlChar *) param->name);
|
||||
if (G_IS_PARAM_SPEC_ENUM (param) == G_TYPE_ENUM) {
|
||||
GEnumValue *values;
|
||||
gint j;
|
||||
|
||||
values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
|
||||
for (j = 0; values[j].value_name; j++) {
|
||||
gchar *value = g_strdup_printf ("%d", values[j].value);
|
||||
|
||||
optionnode = xmlNewChild (argnode, NULL, (xmlChar *) "option",
|
||||
(xmlChar *) value);
|
||||
xmlNewChild (optionnode, NULL, (xmlChar *) "value_nick",
|
||||
(xmlChar *) values[j].value_nick);
|
||||
g_free (value);
|
||||
}
|
||||
}
|
||||
g_free (property_specs);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBXML2
|
||||
#if LIBXML_VERSION >= 20600
|
||||
xmlSetStructuredErrorFunc (NULL, handle_xmlerror);
|
||||
#endif
|
||||
xmlSaveFormatFile (GST_COMPREG_FILE, doc, 1);
|
||||
#else
|
||||
xmlSaveFile (GST_COMPREG_FILE, doc);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue