[pisa-src] r1779 - in trunk/pairing: management.c management.h

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Wed, 25 Nov 2009 14:41:18 +0100

Author: biurrun
Date: Wed Nov 25 14:41:17 2009
New Revision: 1779

Log:
Merge contents of management.h into management.c.
The structures and definitions are used nowhere else so there is no
point in putting them in a separate file.

Deleted:
   trunk/pairing/management.h
Modified:
   trunk/pairing/management.c

Modified: trunk/pairing/management.c
==============================================================================
--- trunk/pairing/management.c  Wed Nov 25 14:37:17 2009        (r1778)
+++ trunk/pairing/management.c  Wed Nov 25 14:41:17 2009        (r1779)
@@ -18,6 +18,7 @@
 #include <signal.h>
 #include <getopt.h>
 #include <fcntl.h>
+#include <libconfig.h>
 
 #include "libpisa/cfg.h"
 #include "libpisa/debug.h"
@@ -27,7 +28,87 @@
 #include "libpisa/util.h"
 #include "libconfig_wrapper.h"
 #include "libpisa/hitlist.h"
-#include "management.h"
+
+
+#define MAX_USERNAME_LENGTH 100
+#define MAX_CREDIT_CARD_LENGTH 20
+
+#define USERS_SECTION "users"
+#define DEFAULT_USERS_CONFIG_FILE "users.conf"
+#define DEFAULT_AUTHORIZED_HOSTS_FILE "authorized_hosts.conf"
+
+#define ERROR_OPENING_CONFIG 2
+#define ERROR_NOT_FOUND 3
+#define ERROR_PARSING_COMMANDLINE 4
+#define ERROR_WRITING_CONFIG 5
+#define ERROR_GENERAL 6
+#define ERROR_ALREADY_RUNNING 7
+
+#define DEACTIVATED 0
+#define ACTIVATED 1
+#define NO_CHANGE 2
+
+/** This macro prints the given expression if true
+ * or a new line otherwise
+ */
+#define PRINT_ENTRY(func,fmt,args...) \
+       if(func) {\
+               printf( fmt , ## args);\
+       }else{ \
+               printf("\n"); \
+       }
+
+#define USE_DEFAULT_EXPIRATION 2
+
+#define OPTION_STRING "h:e:rl:u:a:f:c:s:p:"
+
+enum mode 
{ADD_OR_EDIT,ADD_OR_EDIT_ONLY_HIT,REMOVE,REMOVE_ONLY_HIT,LIST_SINGLE,LIST_SINGLE_ONLY_HIT,LIST_ALL};
+enum list_mode {NORMAL,SHORT};
+
+typedef struct
+{
+    char hit[INET6_ADDRSTRLEN];
+    char user_name[MAX_USERNAME_LENGTH];
+    int active;
+    char expiration[LENGTH_TIMEOUT];
+    char creditcard[MAX_CREDIT_CARD_LENGTH];
+} pisa_userhitlist_entry;
+
+typedef struct
+{
+    char hit[INET6_ADDRSTRLEN];
+    config_setting_t *group;
+    char user_name[MAX_USERNAME_LENGTH];
+    int active;
+    char creditcard[MAX_CREDIT_CARD_LENGTH];
+} pisa_userlist_entry;
+
+typedef struct
+{
+       pisa_userhitlist_entry *entries;
+    int max_slots;
+    int cur_slots;
+
+} pisa_userhitlist;
+
+typedef struct
+{
+    pisa_userlist_entry *entries;
+    int max_slots;
+    int cur_slots;
+} pisa_userlist;
+
+struct options
+{
+    enum mode mode;
+    enum list_mode list_mode;
+};
+
+typedef struct
+{
+    char userscfgfile[MAX_PATH];
+    char authorizedcfgfile[MAX_PATH];
+} management_conf;
 
 extern config_t cfg;
 management_conf managementconf;

Other related posts:

  • » [pisa-src] r1779 - in trunk/pairing: management.c management.h - Diego Biurrun