Browse code

group: replace STR_PARAM with PARAM_STR

Alekzander Spiridonov authored on 28/07/2014 12:43:47 • Daniel-Constantin Mierla committed on 05/08/2014 10:48:27
Showing 1 changed files
... ...
@@ -87,41 +87,28 @@ static int get_gid_fixup(void** param, int param_no);
87 87
 
88 88
 
89 89
 #define TABLE "grp"
90
-#define TABLE_LEN (sizeof(TABLE) - 1)
91
-
92 90
 #define USER_COL "username"
93
-#define USER_COL_LEN (sizeof(USER_COL) - 1)
94
-
95 91
 #define DOMAIN_COL "domain"
96
-#define DOMAIN_COL_LEN (sizeof(DOMAIN_COL) - 1)
97
-
98 92
 #define GROUP_COL "grp"
99
-#define GROUP_COL_LEN (sizeof(GROUP_COL) - 1)
100
-
101 93
 #define RE_TABLE "re_grp"
102
-#define RE_TABLE_LEN (sizeof(TABLE) - 1)
103
-
104 94
 #define RE_EXP_COL "reg_exp"
105
-#define RE_EXP_COL_LEN (sizeof(USER_COL) - 1)
106
-
107 95
 #define RE_GID_COL "group_id"
108
-#define RE_GID_COL_LEN (sizeof(DOMAIN_COL) - 1)
109 96
 
110 97
 /*
111 98
  * Module parameter variables
112 99
  */
113
-static str db_url = {DEFAULT_RODB_URL, DEFAULT_RODB_URL_LEN};
100
+static str db_url = str_init(DEFAULT_RODB_URL);
114 101
 /*! Table name where group definitions are stored */
115
-str table         = {TABLE, TABLE_LEN}; 
116
-str user_column   = {USER_COL, USER_COL_LEN};
117
-str domain_column = {DOMAIN_COL, DOMAIN_COL_LEN};
118
-str group_column  = {GROUP_COL, GROUP_COL_LEN};
102
+str table         = str_init(TABLE);
103
+str user_column   = str_init(USER_COL);
104
+str domain_column = str_init(DOMAIN_COL);
105
+str group_column  = str_init(GROUP_COL);
119 106
 int use_domain    = 0;
120 107
 
121 108
 /* table and columns used for regular expression-based groups */
122 109
 str re_table      = {0, 0};
123
-str re_exp_column = {RE_EXP_COL, RE_EXP_COL_LEN};
124
-str re_gid_column = {RE_GID_COL, RE_GID_COL_LEN};
110
+str re_exp_column = str_init(RE_EXP_COL);
111
+str re_gid_column = str_init(RE_GID_COL);
125 112
 int multiple_gid  = 1;
126 113
 
127 114
 /* DB functions and handlers */
... ...
@@ -145,15 +132,15 @@ static cmd_export_t cmds[] = {
145 132
  * Exported parameters
146 133
  */
147 134
 static param_export_t params[] = {
148
-	{"db_url",        STR_PARAM, &db_url.s       },
149
-	{"table",         STR_PARAM, &table.s        },
150
-	{"user_column",   STR_PARAM, &user_column.s  },
151
-	{"domain_column", STR_PARAM, &domain_column.s},
152
-	{"group_column",  STR_PARAM, &group_column.s },
135
+	{"db_url",        PARAM_STR, &db_url       },
136
+	{"table",         PARAM_STR, &table        },
137
+	{"user_column",   PARAM_STR, &user_column  },
138
+	{"domain_column", PARAM_STR, &domain_column},
139
+	{"group_column",  PARAM_STR, &group_column },
153 140
 	{"use_domain",    INT_PARAM, &use_domain     },
154
-	{"re_table",      STR_PARAM, &re_table.s     },
155
-	{"re_exp_column", STR_PARAM, &re_exp_column.s},
156
-	{"re_gid_column", STR_PARAM, &re_gid_column.s},
141
+	{"re_table",      PARAM_STR, &re_table     },
142
+	{"re_exp_column", PARAM_STR, &re_exp_column},
143
+	{"re_gid_column", PARAM_STR, &re_gid_column},
157 144
 	{"multiple_gid",  INT_PARAM, &multiple_gid   },
158 145
 	{0, 0, 0}
159 146
 };
... ...
@@ -189,17 +176,6 @@ static int child_init(int rank)
189 176
 
190 177
 static int mod_init(void)
191 178
 {
192
-	/* Calculate lengths */
193
-	db_url.len = strlen(db_url.s);
194
-	table.len = strlen(table.s);
195
-	user_column.len = strlen(user_column.s);
196
-	domain_column.len = strlen(domain_column.s);
197
-	group_column.len = strlen(group_column.s);
198
-
199
-	re_table.len = (re_table.s && re_table.s[0])?strlen(re_table.s):0;
200
-	re_exp_column.len = strlen(re_exp_column.s);
201
-	re_gid_column.len = strlen(re_gid_column.s);
202
-
203 179
 	/* Find a database module */
204 180
 	if (group_db_bind(&db_url)) {
205 181
 		return -1;