[bwm-tools-devel] COMMIT - r17 - trunk/bwm_firewall
Brought to you by:
nkukard
From: SVN C. <sv...@li...> - 2005-01-02 15:33:06
|
Author: nkukard Date: 2005-01-02 17:32:38 +0200 (Sun, 02 Jan 2005) New Revision: 17 Modified: trunk/bwm_firewall/bwm_firewall.c Log: * Giang Hu <fre...@gm...> - Added datetime stamp to generated iptables firewall Modified: trunk/bwm_firewall/bwm_firewall.c =================================================================== --- trunk/bwm_firewall/bwm_firewall.c 2005-01-01 06:56:51 UTC (rev 16) +++ trunk/bwm_firewall/bwm_firewall.c 2005-01-02 15:32:38 UTC (rev 17) @@ -36,14 +36,21 @@ #include "common.h" #include "xmlConf.h" +// return current date string like +// Sun Jan 2 21:52:25 2005 +static char *date2str(char *buffer) +{ + time_t t = time(NULL); + sprintf(buffer, "%s", ctime(&t)); + return buffer; +} - // Function to write firewall to file static int writeFirewall(GList *ruleList, char *filename) { int fd; int fuct = 0; - char *buffer; + char *buffer, datetime[32]; // Write rule by rule to file @@ -72,8 +79,8 @@ } buffer = (char *) malloc0(BUFFER_SIZE); - // FIXME - add date - snprintf(buffer,BUFFER_SIZE,"# Generated using BWM Firewall v%s: %s\n",PACKAGE_VERSION,"DATE"); + // Write out comment to say what version & at what datetime we generated the firewall + snprintf(buffer,BUFFER_SIZE,"# Generated using BWM Firewall v%s: %s\n",PACKAGE_VERSION, date2str(&datetime)); write(fd,buffer,strlen(buffer)); // Loop with all rules |