1 /*
2 * yumrepo.c
3 *
4 * Copyright (c) 2016, Masatake YAMATO <yamato@redhat.com>
5 * Copyright (c) 2016, Red Hat, K.K.
6 *
7 * This source code is released for free distribution under the terms of the
8 * GNU General Public License version 2 or (at your option) any later version.
9 *
10 * This module contains functions for generating tags for yum repo file
11 *
12 */
13
14 /*
15 * INCLUDE FILES
16 */
17 #include "general.h" /* must always come first */
18
19 #include "entry.h"
20 #include "iniconf.h"
21 #include "kind.h"
22 #include "parse.h"
23 #include "read.h"
24 #include "routines.h"
25 #include <string.h>
26
27 /*
28 * DATA DEFINITIONS
29 */
30 typedef enum {
31 K_REPO_ID,
32 } yumRepoKind;
33
34 static kindDefinition YumRepoKinds [] = {
35 { true, 'r', "repoid", "repository id" },
36 };
37
38
newDataCallback(iniconfSubparser * s CTAGS_ATTR_UNUSED,const char * section,const char * key,const char * value)39 static void newDataCallback (iniconfSubparser *s CTAGS_ATTR_UNUSED,
40 const char *section, const char *key, const char *value)
41 {
42 tagEntryInfo e;
43
44 if (section && key == NULL && value == NULL)
45 {
46 initTagEntry (&e, section, K_REPO_ID);
47 makeTagEntry (&e);
48 }
49 }
50
findYumRepoTags(void)51 static void findYumRepoTags (void)
52 {
53 scheduleRunningBaseparser (0);
54 }
55
YumRepoParser(void)56 extern parserDefinition* YumRepoParser (void)
57 {
58 static const char *const extensions [] = { "repo", NULL };
59 static iniconfSubparser yumRepoSubparser = {
60 .subparser = {
61 .direction = SUBPARSER_SUB_RUNS_BASE,
62 },
63 .newDataNotify = newDataCallback,
64 };
65 static parserDependency dependencies [] = {
66 [0] = { DEPTYPE_SUBPARSER, "Iniconf", &yumRepoSubparser },
67 };
68
69 parserDefinition* const def = parserNew ("YumRepo");
70
71 def->dependencies = dependencies;
72 def->dependencyCount = ARRAY_SIZE(dependencies);
73 def->kindTable = YumRepoKinds;
74 def->kindCount = ARRAY_SIZE (YumRepoKinds);
75 def->extensions = extensions;
76 def->parser = findYumRepoTags;
77
78 return def;
79 }
80