Explorar o código

ncd: NCDConfig: rename NCDConfig_interfaces to NCDConfig_processes

ambrop7 %!s(int64=14) %!d(string=hai) anos
pai
achega
a849bca889

+ 3 - 3
examples/ncd_parser_test.c

@@ -41,14 +41,14 @@ int main (int argc, char **argv)
     }
     
     // parse
-    struct NCDConfig_interfaces *ast;
+    struct NCDConfig_processes *ast;
     if (!NCDConfigParser_Parse(argv[1], strlen(argv[1]), &ast)) {
         DEBUG("NCDConfigParser_Parse failed");
         return 1;
     }
     
     // print
-    struct NCDConfig_interfaces *iface = ast;
+    struct NCDConfig_processes *iface = ast;
     while (iface) {
         printf("process %s\n", iface->name);
         
@@ -95,7 +95,7 @@ int main (int argc, char **argv)
         iface = iface->next;
     }
     
-    NCDConfig_free_interfaces(ast);
+    NCDConfig_free_processes(ast);
     
     return 0;
 }

+ 17 - 17
generated/NCDConfigParser_parse.c

@@ -16,7 +16,7 @@
 struct parser_out {
     int out_of_memory;
     int syntax_error;
-    struct NCDConfig_interfaces *ast;
+    struct NCDConfig_processes *ast;
 };
 
 #line 23 "NCDConfigParser_parse.c"
@@ -78,10 +78,10 @@ typedef union {
   ParseTOKENTYPE yy0;
   struct NCDConfig_arguments * yy8;
   char * yy9;
-  struct NCDConfig_interfaces * yy18;
   int yy20;
   struct NCDConfig_statements * yy38;
   struct NCDConfig_strings * yy40;
+  struct NCDConfig_processes * yy41;
 } YYMINORTYPE;
 #ifndef YYSTACKDEPTH
 #define YYSTACKDEPTH 0
@@ -288,7 +288,7 @@ static const char *const yyTokenName[] = {
   "$",             "NAME",          "CURLY_OPEN",    "CURLY_CLOSE", 
   "ROUND_OPEN",    "ROUND_CLOSE",   "SEMICOLON",     "ARROW",       
   "DOT",           "STRING",        "COMMA",         "PROCESS",     
-  "TEMPLATE",      "error",         "interfaces",    "statements",  
+  "TEMPLATE",      "error",         "processes",     "statements",  
   "statement_names",  "statement_args_maybe",  "statement_args",  "name_maybe",  
   "process_or_template",  "input",       
 };
@@ -298,9 +298,9 @@ static const char *const yyTokenName[] = {
 /* For tracing reduce actions, the names of all rules are required.
 */
 static const char *const yyRuleName[] = {
- /*   0 */ "input ::= interfaces",
- /*   1 */ "interfaces ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE",
- /*   2 */ "interfaces ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE interfaces",
+ /*   0 */ "input ::= processes",
+ /*   1 */ "processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE",
+ /*   2 */ "processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE processes",
  /*   3 */ "statements ::= statement_names ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON",
  /*   4 */ "statements ::= statement_names ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON statements",
  /*   5 */ "statements ::= statement_names ARROW statement_names ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON",
@@ -414,10 +414,10 @@ static void yy_destructor(
 #line 415 "NCDConfigParser_parse.c"
 }
       break;
-    case 14: /* interfaces */
+    case 14: /* processes */
 {
 #line 53 "NCDConfigParser_parse.y"
- NCDConfig_free_interfaces((yypminor->yy18)); 
+ NCDConfig_free_processes((yypminor->yy41)); 
 #line 422 "NCDConfigParser_parse.c"
 }
       break;
@@ -755,22 +755,22 @@ static void yy_reduce(
   **  #line <lineno> <thisfile>
   **     break;
   */
-      case 0: /* input ::= interfaces */
+      case 0: /* input ::= processes */
 #line 73 "NCDConfigParser_parse.y"
 {
-    parser_out->ast = yymsp[0].minor.yy18;
+    parser_out->ast = yymsp[0].minor.yy41;
 
-    if (!yymsp[0].minor.yy18) {
+    if (!yymsp[0].minor.yy41) {
         parser_out->out_of_memory = 1;
     }
 }
 #line 768 "NCDConfigParser_parse.c"
         break;
-      case 1: /* interfaces ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE */
+      case 1: /* processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE */
 #line 81 "NCDConfigParser_parse.y"
 {
-    yygotominor.yy18 = NCDConfig_make_interfaces(yymsp[-4].minor.yy20, yymsp[-3].minor.yy0, yymsp[-1].minor.yy38, 0, NULL);
-    if (!yygotominor.yy18) {
+    yygotominor.yy41 = NCDConfig_make_processes(yymsp[-4].minor.yy20, yymsp[-3].minor.yy0, yymsp[-1].minor.yy38, 0, NULL);
+    if (!yygotominor.yy41) {
         parser_out->out_of_memory = 1;
     }
   yy_destructor(yypParser,2,&yymsp[-2].minor);
@@ -778,11 +778,11 @@ static void yy_reduce(
 }
 #line 780 "NCDConfigParser_parse.c"
         break;
-      case 2: /* interfaces ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE interfaces */
+      case 2: /* processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE processes */
 #line 88 "NCDConfigParser_parse.y"
 {
-    yygotominor.yy18 = NCDConfig_make_interfaces(yymsp[-5].minor.yy20, yymsp[-4].minor.yy0, yymsp[-2].minor.yy38, 1, yymsp[0].minor.yy18);
-    if (!yygotominor.yy18) {
+    yygotominor.yy41 = NCDConfig_make_processes(yymsp[-5].minor.yy20, yymsp[-4].minor.yy0, yymsp[-2].minor.yy38, 1, yymsp[0].minor.yy41);
+    if (!yygotominor.yy41) {
         parser_out->out_of_memory = 1;
     }
   yy_destructor(yypParser,2,&yymsp[-3].minor);

+ 20 - 20
generated/NCDConfigParser_parse.out

@@ -1,13 +1,13 @@
 State 0:
-          input ::= * interfaces
-          interfaces ::= * process_or_template NAME CURLY_OPEN statements CURLY_CLOSE
-          interfaces ::= * process_or_template NAME CURLY_OPEN statements CURLY_CLOSE interfaces
+          input ::= * processes
+          processes ::= * process_or_template NAME CURLY_OPEN statements CURLY_CLOSE
+          processes ::= * process_or_template NAME CURLY_OPEN statements CURLY_CLOSE processes
           process_or_template ::= * PROCESS
           process_or_template ::= * TEMPLATE
 
                        PROCESS shift  27
                       TEMPLATE shift  28
-                    interfaces shift  14
+                     processes shift  14
            process_or_template shift  15
                          input accept
 
@@ -50,16 +50,16 @@ State 2:
                      {default} reduce 9
 
 State 3:
-          interfaces ::= * process_or_template NAME CURLY_OPEN statements CURLY_CLOSE
-      (1) interfaces ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE *
-          interfaces ::= * process_or_template NAME CURLY_OPEN statements CURLY_CLOSE interfaces
-          interfaces ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE * interfaces
+          processes ::= * process_or_template NAME CURLY_OPEN statements CURLY_CLOSE
+      (1) processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE *
+          processes ::= * process_or_template NAME CURLY_OPEN statements CURLY_CLOSE processes
+          processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE * processes
           process_or_template ::= * PROCESS
           process_or_template ::= * TEMPLATE
 
                        PROCESS shift  27
                       TEMPLATE shift  28
-                    interfaces shift  26
+                     processes shift  26
            process_or_template shift  15
                      {default} reduce 1
 
@@ -92,8 +92,8 @@ State 5:
                 statement_args shift  33
 
 State 6:
-          interfaces ::= process_or_template NAME CURLY_OPEN * statements CURLY_CLOSE
-          interfaces ::= process_or_template NAME CURLY_OPEN * statements CURLY_CLOSE interfaces
+          processes ::= process_or_template NAME CURLY_OPEN * statements CURLY_CLOSE
+          processes ::= process_or_template NAME CURLY_OPEN * statements CURLY_CLOSE processes
           statements ::= * statement_names ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON
           statements ::= * statement_names ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON statements
           statements ::= * statement_names ARROW statement_names ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON
@@ -182,25 +182,25 @@ State 13:
                          ARROW shift  11
 
 State 14:
-      (0) input ::= interfaces *
+      (0) input ::= processes *
 
                              $ reduce 0
 
 State 15:
-          interfaces ::= process_or_template * NAME CURLY_OPEN statements CURLY_CLOSE
-          interfaces ::= process_or_template * NAME CURLY_OPEN statements CURLY_CLOSE interfaces
+          processes ::= process_or_template * NAME CURLY_OPEN statements CURLY_CLOSE
+          processes ::= process_or_template * NAME CURLY_OPEN statements CURLY_CLOSE processes
 
                           NAME shift  16
 
 State 16:
-          interfaces ::= process_or_template NAME * CURLY_OPEN statements CURLY_CLOSE
-          interfaces ::= process_or_template NAME * CURLY_OPEN statements CURLY_CLOSE interfaces
+          processes ::= process_or_template NAME * CURLY_OPEN statements CURLY_CLOSE
+          processes ::= process_or_template NAME * CURLY_OPEN statements CURLY_CLOSE processes
 
                     CURLY_OPEN shift  6
 
 State 17:
-          interfaces ::= process_or_template NAME CURLY_OPEN statements * CURLY_CLOSE
-          interfaces ::= process_or_template NAME CURLY_OPEN statements * CURLY_CLOSE interfaces
+          processes ::= process_or_template NAME CURLY_OPEN statements * CURLY_CLOSE
+          processes ::= process_or_template NAME CURLY_OPEN statements * CURLY_CLOSE processes
 
                    CURLY_CLOSE shift  3
 
@@ -256,7 +256,7 @@ State 25:
                      SEMICOLON shift  8
 
 State 26:
-      (2) interfaces ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE interfaces *
+      (2) processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE processes *
 
                      {default} reduce 2
 
@@ -321,7 +321,7 @@ Symbols:
    11: PROCESS
    12: TEMPLATE
    13: error:
-   14: interfaces: PROCESS TEMPLATE
+   14: processes: PROCESS TEMPLATE
    15: statements: NAME
    16: statement_names: NAME
    17: statement_args_maybe: <lambda> NAME STRING

+ 8 - 8
generated/NCDConfigParser_parse.y

@@ -31,7 +31,7 @@
 struct parser_out {
     int out_of_memory;
     int syntax_error;
-    struct NCDConfig_interfaces *ast;
+    struct NCDConfig_processes *ast;
 };
 
 }
@@ -42,7 +42,7 @@ struct parser_out {
 
 %token_destructor { free($$); }
 
-%type interfaces {struct NCDConfig_interfaces *}
+%type processes {struct NCDConfig_processes *}
 %type statements {struct NCDConfig_statements *}
 %type statement_names {struct NCDConfig_strings *}
 %type statement_args_maybe {struct NCDConfig_arguments *}
@@ -50,7 +50,7 @@ struct parser_out {
 %type name_maybe {char *}
 %type process_or_template {int}
 
-%destructor interfaces { NCDConfig_free_interfaces($$); }
+%destructor processes { NCDConfig_free_processes($$); }
 %destructor statements { NCDConfig_free_statements($$); }
 %destructor statement_names { NCDConfig_free_strings($$); }
 %destructor statement_args_maybe { NCDConfig_free_arguments($$); }
@@ -70,7 +70,7 @@ struct parser_out {
     }
 }
 
-input ::= interfaces(A). {
+input ::= processes(A). {
     parser_out->ast = A;
 
     if (!A) {
@@ -78,15 +78,15 @@ input ::= interfaces(A). {
     }
 }
 
-interfaces(R) ::= process_or_template(T) NAME(A) CURLY_OPEN statements(B) CURLY_CLOSE. {
-    R = NCDConfig_make_interfaces(T, A, B, 0, NULL);
+processes(R) ::= process_or_template(T) NAME(A) CURLY_OPEN statements(B) CURLY_CLOSE. {
+    R = NCDConfig_make_processes(T, A, B, 0, NULL);
     if (!R) {
         parser_out->out_of_memory = 1;
     }
 }
 
-interfaces(R) ::= process_or_template(T) NAME(A) CURLY_OPEN statements(B) CURLY_CLOSE interfaces(N). {
-    R = NCDConfig_make_interfaces(T, A, B, 1, N);
+processes(R) ::= process_or_template(T) NAME(A) CURLY_OPEN statements(B) CURLY_CLOSE processes(N). {
+    R = NCDConfig_make_processes(T, A, B, 1, N);
     if (!R) {
         parser_out->out_of_memory = 1;
     }

+ 5 - 5
ncd/NCDConfig.c

@@ -28,7 +28,7 @@
 
 #include <ncd/NCDConfig.h>
 
-void NCDConfig_free_interfaces (struct NCDConfig_interfaces *v)
+void NCDConfig_free_processes (struct NCDConfig_processes *v)
 {
     if (!v) {
         return;
@@ -36,7 +36,7 @@ void NCDConfig_free_interfaces (struct NCDConfig_interfaces *v)
     
     free(v->name);
     NCDConfig_free_statements(v->statements);
-    NCDConfig_free_interfaces(v->next);
+    NCDConfig_free_processes(v->next);
     
     free(v);
 }
@@ -90,13 +90,13 @@ void NCDConfig_free_strings (struct NCDConfig_strings *v)
     free(v);
 }
 
-struct NCDConfig_interfaces * NCDConfig_make_interfaces (int is_template, char *name, struct NCDConfig_statements *statements, int need_next, struct NCDConfig_interfaces *next)
+struct NCDConfig_processes * NCDConfig_make_processes (int is_template, char *name, struct NCDConfig_statements *statements, int need_next, struct NCDConfig_processes *next)
 {
     if (!name || !statements || (need_next && !next)) {
         goto fail;
     }
     
-    struct NCDConfig_interfaces *v = malloc(sizeof(*v));
+    struct NCDConfig_processes *v = malloc(sizeof(*v));
     if (!v) {
         goto fail;
     }
@@ -111,7 +111,7 @@ struct NCDConfig_interfaces * NCDConfig_make_interfaces (int is_template, char *
 fail:
     free(name);
     NCDConfig_free_statements(statements);
-    NCDConfig_free_interfaces(next);
+    NCDConfig_free_processes(next);
     return NULL;
 }
 

+ 5 - 5
ncd/NCDConfig.h

@@ -23,16 +23,16 @@
 #ifndef BADVPN_NCDCONFIG_NCDCONFIG_H
 #define BADVPN_NCDCONFIG_NCDCONFIG_H
 
-struct NCDConfig_interfaces;
+struct NCDConfig_processes;
 struct NCDConfig_statements;
 struct NCDConfig_arguments;
 struct NCDConfig_strings;
 
-struct NCDConfig_interfaces {
+struct NCDConfig_processes {
     int is_template;
     char *name;
     struct NCDConfig_statements *statements;
-    struct NCDConfig_interfaces *next;
+    struct NCDConfig_processes *next;
 };
 
 struct NCDConfig_statements {
@@ -60,11 +60,11 @@ struct NCDConfig_strings {
     struct NCDConfig_strings *next;
 };
 
-void NCDConfig_free_interfaces (struct NCDConfig_interfaces *v);
+void NCDConfig_free_processes (struct NCDConfig_processes *v);
 void NCDConfig_free_statements (struct NCDConfig_statements *v);
 void NCDConfig_free_arguments (struct NCDConfig_arguments *v);
 void NCDConfig_free_strings (struct NCDConfig_strings *v);
-struct NCDConfig_interfaces * NCDConfig_make_interfaces (int is_template, char *name, struct NCDConfig_statements *statements, int have_next, struct NCDConfig_interfaces *next);
+struct NCDConfig_processes * NCDConfig_make_processes (int is_template, char *name, struct NCDConfig_statements *statements, int have_next, struct NCDConfig_processes *next);
 struct NCDConfig_statements * NCDConfig_make_statements (struct NCDConfig_strings *objname, struct NCDConfig_strings *names, struct NCDConfig_arguments *args, char *name, struct NCDConfig_statements *next);
 struct NCDConfig_arguments * NCDConfig_make_arguments_string (char *str, struct NCDConfig_arguments *next);
 struct NCDConfig_arguments * NCDConfig_make_arguments_var (struct NCDConfig_strings *var, struct NCDConfig_arguments *next);

+ 2 - 2
ncd/NCDConfigParser.c

@@ -139,7 +139,7 @@ static int tokenizer_output (void *user, int token, char *value, size_t position
     return 1;
 }
 
-int NCDConfigParser_Parse (char *config, size_t config_len, struct NCDConfig_interfaces **out_ast)
+int NCDConfigParser_Parse (char *config, size_t config_len, struct NCDConfig_processes **out_ast)
 {
     struct parser_state state;
     
@@ -158,7 +158,7 @@ int NCDConfigParser_Parse (char *config, size_t config_len, struct NCDConfig_int
     
     if (state.error) {
         ParseFree(state.parser, free);
-        NCDConfig_free_interfaces(state.out.ast);
+        NCDConfig_free_processes(state.out.ast);
         return 0;
     }
     

+ 1 - 1
ncd/NCDConfigParser.h

@@ -27,6 +27,6 @@
 
 #include <ncd/NCDConfig.h>
 
-int NCDConfigParser_Parse (char *config, size_t config_len, struct NCDConfig_interfaces **out_ast);
+int NCDConfigParser_Parse (char *config, size_t config_len, struct NCDConfig_processes **out_ast);
 
 #endif

+ 8 - 8
ncd/NCDConfigParser_parse.y

@@ -31,7 +31,7 @@
 struct parser_out {
     int out_of_memory;
     int syntax_error;
-    struct NCDConfig_interfaces *ast;
+    struct NCDConfig_processes *ast;
 };
 
 }
@@ -42,7 +42,7 @@ struct parser_out {
 
 %token_destructor { free($$); }
 
-%type interfaces {struct NCDConfig_interfaces *}
+%type processes {struct NCDConfig_processes *}
 %type statements {struct NCDConfig_statements *}
 %type statement_names {struct NCDConfig_strings *}
 %type statement_args_maybe {struct NCDConfig_arguments *}
@@ -50,7 +50,7 @@ struct parser_out {
 %type name_maybe {char *}
 %type process_or_template {int}
 
-%destructor interfaces { NCDConfig_free_interfaces($$); }
+%destructor processes { NCDConfig_free_processes($$); }
 %destructor statements { NCDConfig_free_statements($$); }
 %destructor statement_names { NCDConfig_free_strings($$); }
 %destructor statement_args_maybe { NCDConfig_free_arguments($$); }
@@ -70,7 +70,7 @@ struct parser_out {
     }
 }
 
-input ::= interfaces(A). {
+input ::= processes(A). {
     parser_out->ast = A;
 
     if (!A) {
@@ -78,15 +78,15 @@ input ::= interfaces(A). {
     }
 }
 
-interfaces(R) ::= process_or_template(T) NAME(A) CURLY_OPEN statements(B) CURLY_CLOSE. {
-    R = NCDConfig_make_interfaces(T, A, B, 0, NULL);
+processes(R) ::= process_or_template(T) NAME(A) CURLY_OPEN statements(B) CURLY_CLOSE. {
+    R = NCDConfig_make_processes(T, A, B, 0, NULL);
     if (!R) {
         parser_out->out_of_memory = 1;
     }
 }
 
-interfaces(R) ::= process_or_template(T) NAME(A) CURLY_OPEN statements(B) CURLY_CLOSE interfaces(N). {
-    R = NCDConfig_make_interfaces(T, A, B, 1, N);
+processes(R) ::= process_or_template(T) NAME(A) CURLY_OPEN statements(B) CURLY_CLOSE processes(N). {
+    R = NCDConfig_make_processes(T, A, B, 1, N);
     if (!R) {
         parser_out->out_of_memory = 1;
     }

+ 6 - 6
ncd/ncd.c

@@ -138,7 +138,7 @@ BProcessManager manager;
 NCDUdevManager umanager;
 
 // config AST
-struct NCDConfig_interfaces *config_ast;
+struct NCDConfig_processes *config_ast;
 
 // processes
 LinkedList2 processes;
@@ -151,7 +151,7 @@ static const struct NCDModule * find_module (const char *name);
 static int statement_init (struct statement *s, struct NCDConfig_statements *conf);
 static void statement_free (struct statement *s);
 static void statement_free_args (struct statement *s);
-static int process_new (struct NCDConfig_interfaces *conf, NCDModuleProcess *module_process, NCDValue args);
+static int process_new (struct NCDConfig_processes *conf, NCDModuleProcess *module_process, NCDValue args);
 static void process_free (struct process *p);
 static void process_start_terminating (struct process *p);
 static void process_free_statements (struct process *p);
@@ -306,7 +306,7 @@ int main (int argc, char **argv)
     LinkedList2_Init(&processes);
     
     // init processes
-    struct NCDConfig_interfaces *conf = config_ast;
+    struct NCDConfig_processes *conf = config_ast;
     while (conf) {
         if (!conf->is_template) {
             NCDValue args;
@@ -334,7 +334,7 @@ fail5:
         num_inited_modules--;
     }
     // free configuration
-    NCDConfig_free_interfaces(config_ast);
+    NCDConfig_free_processes(config_ast);
 fail3:
     // remove signal handler
     BSignal_Finish();
@@ -671,7 +671,7 @@ void statement_free_args (struct statement *s)
     }
 }
 
-int process_new (struct NCDConfig_interfaces *conf, NCDModuleProcess *module_process, NCDValue args)
+int process_new (struct NCDConfig_processes *conf, NCDModuleProcess *module_process, NCDValue args)
 {
     ASSERT(NCDValue_Type(&args) == NCDVALUE_LIST)
     
@@ -1443,7 +1443,7 @@ int process_statement_instance_func_initprocess (struct process_statement *ps, N
     ASSERT(NCDValue_Type(&args) == NCDVALUE_LIST)
     
     // find template
-    struct NCDConfig_interfaces *conf = config_ast;
+    struct NCDConfig_processes *conf = config_ast;
     while (conf) {
         if (conf->is_template && !strcmp(conf->name, template_name)) {
             break;