Parcourir la source

Exclude private data from cliconf headers. Add needed methods for cliconf structures.

git-svn-id: https://klish.googlecode.com/svn/trunk@114 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev il y a 13 ans
Parent
commit
5b5012735f
7 fichiers modifiés avec 55 ajouts et 38 suppressions
  1. 6 5
      bin/confd.c
  2. 0 1
      cliconf/buf.h
  3. 0 2
      cliconf/conf.h
  4. 0 2
      cliconf/net.h
  5. 1 0
      cliconf/net/net.c
  6. 4 3
      cliconf/query.h
  7. 44 25
      cliconf/query/query.c

+ 6 - 5
bin/confd.c

@@ -225,22 +225,23 @@ static char * process_query(int sock, cliconf_t * conf, char *str)
 	switch (query__get_op(query)) {
 
 	case QUERY_OP_SET:
-		if (cliconf_find_conf(iconf, query->line, 0)) {
+		if (cliconf_find_conf(iconf, query__get_line(query), 0)) {
 			ret = QUERY_OP_OK;
 			break;
 		}
-		cliconf_del_pattern(iconf, query->pattern);
-		tmpconf = cliconf_new_conf(iconf, query->line, query->priority);
+		cliconf_del_pattern(iconf, query__get_pattern(query));
+		tmpconf = cliconf_new_conf(iconf, 
+			query__get_line(query), query__get_priority(query));
 		if (!tmpconf) {
 			ret = QUERY_OP_ERROR;
 			break;
 		}
-		cliconf__set_splitter(tmpconf, query->splitter);
+		cliconf__set_splitter(tmpconf, query__get_splitter(query));
 		ret = QUERY_OP_OK;
 		break;
 
 	case QUERY_OP_UNSET:
-		cliconf_del_pattern(iconf, query->pattern);
+		cliconf_del_pattern(iconf, query__get_pattern(query));
 		ret = QUERY_OP_OK;
 		break;
 

+ 0 - 1
cliconf/buf.h

@@ -16,7 +16,6 @@ Use it to implement config in memory.
 
 #include <stdio.h>
 
-#include "cliconf/buf/private.h"
 #include "lub/bintree.h"
 
 typedef struct conf_buf_s conf_buf_t;

+ 0 - 2
cliconf/conf.h

@@ -16,8 +16,6 @@ Use it to implement config in memory.
 
 #include <stdio.h>
 
-#include "cliconf/conf/private.h"
-
 #include "lub/types.h"
 #include "lub/bintree.h"
 

+ 0 - 2
cliconf/net.h

@@ -3,8 +3,6 @@
 
 typedef struct conf_client_s conf_client_t;
 
-#include "cliconf/net/private.h"
-
 #define CONFD_SOCKET_PATH "/tmp/confd.socket"
 
 conf_client_t *conf_client_new(char *path);

+ 1 - 0
cliconf/net/net.c

@@ -17,6 +17,7 @@
 #include <sys/un.h>
 
 #include "clish/private.h"
+#include "private.h"
 #include "lub/string.h"
 
 #ifndef UNIX_PATH_MAX

+ 4 - 3
cliconf/query.h

@@ -15,8 +15,6 @@ typedef enum
 
 typedef struct query_s query_t;
 
-#include "cliconf/query/private.h"
-
 int query_parse(query_t *query, int argc, char **argv);
 int query_parse_str(query_t *query, char *str);
 query_t *query_new(void);
@@ -26,6 +24,9 @@ int query__get_pwdc(query_t *query);
 void query_dump(query_t *query);
 query_op_t query__get_op(query_t *query);
 char * query__get_path(query_t *query);
-const char *query__get_pattern(query_t *instance);
+const char * query__get_pattern(query_t *instance);
+const char * query__get_line(query_t *instance);
+unsigned short query__get_priority(query_t *instance);
+bool_t query__get_splitter(query_t *instance);
 
 #endif

+ 44 - 25
cliconf/query/query.c

@@ -14,7 +14,8 @@
 #include <assert.h>
 
 #include "clish/private.h"
-#include "cliconf/query.h"
+#include "private.h"
+#include "lub/types.h"
 #include "lub/argv.h"
 #include "lub/string.h"
 
@@ -87,30 +88,6 @@ void query_add_pwd(query_t *query, char *str)
 	query->pwd[query->pwdc++] = lub_string_dup(str);
 }
 
-char * query__get_pwd(query_t *query, unsigned index)
-{
-	if (!query)
-		return NULL;
-	if (index >= query->pwdc)
-		return NULL;
-
-	return query->pwd[index];
-}
-
-int query__get_pwdc(query_t *query)
-{
-	return query->pwdc;
-}
-
-query_op_t query__get_op(query_t *query)
-{
-	return query->op;
-}
-
-char * query__get_path(query_t *query)
-{
-	return query->path;
-}
 
 void query_free(query_t *query)
 {
@@ -249,7 +226,49 @@ int query_parse_str(query_t *query, char *str)
 	return res;
 }
 
+char * query__get_pwd(query_t *query, unsigned index)
+{
+	if (!query)
+		return NULL;
+	if (index >= query->pwdc)
+		return NULL;
+
+	return query->pwd[index];
+}
+
+int query__get_pwdc(query_t *query)
+{
+	return query->pwdc;
+}
+
+query_op_t query__get_op(query_t *query)
+{
+	return query->op;
+}
+
+char * query__get_path(query_t *query)
+{
+	return query->path;
+}
+
+
 const char * query__get_pattern(query_t *this)
 {
 	return this->pattern;
 }
+
+const char * query__get_line(query_t *this)
+{
+	return this->line;
+}
+
+unsigned short query__get_priority(query_t *this)
+{
+	return this->priority;
+}
+
+bool_t query__get_splitter(query_t *this)
+{
+	return this->splitter;
+}
+