// Assin the setname to the session data.
int r = ipset_session_data_set(session, IPSET_SETNAME, setname);
if (r < 0) {
- printf("Could not set ipset name: %s\n",
- ipset_session_report_msg(session));
-
- return;
+ goto ERROR;
}
// Assign additinal options to the session data.
r = ipset_parse_typename(session, IPSET_OPT_TYPE, typename);
if (r < 0) {
- printf("Could not set set type: %s\n",
- ipset_session_report_msg(session));
-
- return;
+ goto ERROR;
}
type = ipset_type_get(session, IPSET_CMD_CREATE);
if (!type) {
- printf("Could not get hash type.\n");
-
- return;
+ goto ERROR;
}
r = ipset_session_data_set(session, IPSET_OPT_FAMILY, &family);
if (r < 0) {
- printf("Could not set family: %s\n",
- ipset_session_report_msg(session));
-
- return;
+ goto ERROR;
}
r = ipset_session_data_set(session, IPSET_OPT_HASHSIZE, &hashsize);
if (r < 0) {
- printf("Could not set hashsize: %s\n",
- ipset_session_report_msg(session));
-
- return;
+ goto ERROR;
}
r = ipset_session_data_set(session, IPSET_OPT_MAXELEM, &maxelem);
if (r < 0) {
- printf("Could not set maxelem: %s\n",
- ipset_session_report_msg(session));
-
- return;
+ goto ERROR;
}
r = ipset_cmd(session, IPSET_CMD_CREATE, 0);
if (r < 0) {
- printf("Command failed: %s\n",
- ipset_session_report_msg(session));
-
- RETVAL = false;
+ goto ERROR;
}
-
+
RETVAL = true;
+ goto END;
+
+ ERROR:
+ RETVAL = false;
+
+ // Reset may assigned session data.
+ ipset_data_reset(ipset_session_data(session));
+
+ END:
OUTPUT:
RETVAL
// Assign the setname to the session data.
int r = ipset_session_data_set(session, IPSET_SETNAME, setname);
if (r < 0) {
- printf("Could not set setname: %s\n",
- ipset_session_report_msg(session));
+ goto ERROR;
}
r = ipset_cmd(session, cmd, 0);
if (r < 0) {
- printf("Command failed: %s\n",
- ipset_session_report_msg(session));
-
- RETVAL = false;
+ goto ERROR;
}
RETVAL = true;
+ goto END;
+
+ ERROR:
+ RETVAL = false;
+
+ // Reset session data.
+ ipset_data_reset(ipset_session_data(session));
+
+ END:
OUTPUT:
RETVAL
// Assign the setname to the session data.
int r = ipset_session_data_set(session, IPSET_SETNAME, setname);
if (r < 0) {
- printf("Could not set setname: %s\n",
- ipset_session_report_msg(session));
+ goto ERROR;
}
r = ipset_session_data_set(session, IPSET_OPT_SETNAME2, new_setname);
if (r < 0) {
- printf("Could not assign new setname: %s\n",
- ipset_session_report_msg(session));
+ goto ERROR;
}
r = ipset_cmd(session, cmd, 0);
if (r < 0) {
- printf("Command failed: %s\n",
- ipset_session_report_msg(session));
-
- RETVAL = false;
+ goto ERROR;
}
RETVAL = true;
+ goto END;
+
+ ERROR:
+ RETVAL = false;
+
+ // Reset session data.
+ ipset_data_reset(ipset_session_data(session));
+ END:
OUTPUT:
RETVAL
// Assign the setname to the session data.
int r = ipset_session_data_set(session, IPSET_SETNAME, setname);
if (r < 0) {
- printf("Could not set setname: %s\n",
- ipset_session_report_msg(session));
+ goto ERROR;
}
// Assign the second set data.
r = ipset_session_data_set(session, IPSET_OPT_SETNAME2, setname2);
if (r < 0) {
- printf("Could not assign second set name: %s\n",
- ipset_session_report_msg(session));
+ goto ERROR;
}
r = ipset_cmd(session, cmd, 0);
if (r < 0) {
- printf("Command failed: %s\n",
- ipset_session_report_msg(session));
-
- RETVAL = false;
+ goto ERROR;
}
RETVAL = true;
+ goto END;
+
+ ERROR:
+ RETVAL = false;
+
+ // Reset session data.
+ ipset_data_reset(ipset_session_data(session));
+ END:
OUTPUT:
RETVAL
// Assign the setname as session data.
int r = ipset_session_data_set(session, IPSET_SETNAME, setname);
if (r < 0) {
- printf("Could not set setname: %s\n",
- ipset_session_report_msg(session));
+ goto ERROR;
}
r = ipset_cmd(session, cmd, 0);
if (r < 0 ) {
- printf("Command failed: %s\n",
- ipset_session_report_msg(session));
-
- RETVAL = false;
+ goto ERROR;
}
RETVAL = true;
+ goto END;
+
+ ERROR:
+ RETVAL = false;
+
+ // Reset session data.
+ ipset_data_reset(ipset_session_data(session));
+ END:
OUTPUT:
RETVAL
-
+
void
DESTROY(session)
struct ipset_session *session;