Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

create_database_read_write.c

00001 #include <stdio.h>
00002 #include "tables.h"
00003 
00004 
00005 
00006 
00007 int main ()
00008 {
00009    fprintf (stdout,
00010             "# WARNING: This file is generated by <./bin/create_database_read_write>. Do not edit this file by hand.");
00011 
00012    fprintf (stdout,
00013             "\n\n\n");
00014 
00015    /* ------------------------------------------------------------------- */
00016    /* Database "dhcp_adsl"                                                */
00017    /* ------------------------------------------------------------------- */
00018 
00019    fprintf (stdout,
00020             "CREATE DATABASE IF NOT EXISTS dhcp_adsl_read_write;\n");
00021 
00022    fprintf (stdout,
00023             "USE dhcp_adsl_read_write;\n\n\n");
00024 
00025    fprintf (stdout,
00026             "DROP TABLE IF EXISTS ip_lease;\n");
00027 
00028    fprintf (stdout,
00029             "DROP TABLE IF EXISTS pool;\n\n");
00030 
00031    /* ------------------------------------------------------------------- */
00032    /* TABLE "ip_lease"                                                    */
00033    /* ------------------------------------------------------------------- */
00034 
00035    fprintf (stdout,
00036             "CREATE TABLE IF NOT EXISTS ip_lease\n");
00037 
00038    fprintf (stdout,
00039             "(\n");
00040 
00041    fprintf (stdout,
00042             "\tUNIQUE INDEX           cidr_idx                (cidr),\n");
00043 
00044    fprintf (stdout,
00045             "\tINDEX                  vlan_id_idx             (vlan_id),\n\n");
00046 
00047    fprintf (stdout,
00048             "\tip_lease_id            INT(4) UNSIGNED         NOT NULL AUTO_INCREMENT,\n");
00049 
00050    fprintf (stdout,
00051             "\tvlan_id                INT(4) UNSIGNED         NOT NULL,\n");
00052 
00053    fprintf (stdout,
00054             "\tcidr                   VARCHAR(%d)            NOT NULL,\n", CIDR_SIZE-1);
00055 
00056    fprintf (stdout,
00057             "\tsubnet                 VARCHAR(%d)             NOT NULL,\n", IP_ADDRESS_STR_SIZE-1);
00058 
00059    fprintf (stdout,
00060             "\tgateway                VARCHAR(%d)             NOT NULL,\n", IP_ADDRESS_STR_SIZE-1);
00061 
00062    fprintf (stdout,
00063             "\tPRIMARY KEY (ip_lease_id)\n");
00064 
00065    fprintf (stdout,
00066             ");\n\n\n");
00067 
00068    /* ------------------------------------------------------------------- */
00069    /* TABLE "pool"                                                        */
00070    /* ------------------------------------------------------------------- */
00071 
00072    fprintf (stdout,
00073             "CREATE TABLE IF NOT EXISTS pool\n");
00074 
00075    fprintf (stdout,
00076             "(\n");
00077 
00078    fprintf (stdout,
00079             "\tINDEX                 ip_lease_id_idx         (ip_lease_id),\n");
00080 
00081    fprintf (stdout,
00082             "\tUNIQUE INDEX          ip_idx                  (ip),\n\n");
00083 
00084    fprintf (stdout,
00085             "\tINDEX                 abonnes_id_idx          (abonnes_id),\n");
00086 
00087    fprintf (stdout,
00088             "\tINDEX                 couple_index            (ip_lease_id, abonnes_id),\n");
00089 
00090    fprintf (stdout,
00091             "\tINDEX                 expiration_idx          (expiration),\n\n"); 
00092 
00093    fprintf (stdout,
00094             "\tpool_id               INT(4) UNSIGNED         NOT NULL AUTO_INCREMENT,\n");
00095 
00096    fprintf (stdout,
00097             "\tip_lease_id           INT(4) UNSIGNED         NOT NULL,\n");
00098 
00099    fprintf (stdout,
00100             "\tabonnes_id            INT(4) UNSIGNED,\n");
00101 
00102    fprintf (stdout,
00103             "\tip                    VARCHAR(%d)             NOT NULL,\n", IP_ADDRESS_STR_SIZE-1);
00104 
00105    fprintf (stdout,
00106             "\texpiration            INT(4) UNSIGNED         NOT NULL,\n");
00107 
00108    fprintf (stdout,
00109             "\tPRIMARY KEY (pool_id)\n");
00110 
00111    fprintf (stdout,
00112             ");\n\n\n");
00113 
00114    /* ------------------------------------------------------------------- */
00115    /* Create users                                                        */
00116    /* ------------------------------------------------------------------- */
00117 
00118    fprintf (stdout, "GRANT ALL ON dhcp_adsl_read_write.* TO dhcp_adsl@'localhost'   IDENTIFIED BY 'liberty';\n");
00119 
00120    fprintf (stdout, "GRANT ALL ON dhcp_adsl_read_write.* TO dhcp_adsl@'b-dhcp1'     IDENTIFIED BY 'liberty';\n");
00121 
00122    fprintf (stdout, "GRANT ALL ON dhcp_adsl_read_write.* TO dhcp_adsl@'b-dhcp2'     IDENTIFIED BY 'liberty';\n");
00123 
00124    fprintf (stdout, "GRANT ALL ON dhcp_adsl_read_write.* TO dba@'localhost'         IDENTIFIED BY 'liberty';\n");
00125 
00126    fprintf (stdout, "GRANT ALL ON dhcp_adsl_read_write.* TO dhcp_adsl@'devvoip'     IDENTIFIED BY 'liberty';\n");
00127 
00128    fprintf (stdout, "GRANT ALL ON dhcp_adsl_read_only.* TO dhcp_adsl@'devregister1' IDENTIFIED BY 'liberty';\n");
00129 
00130    return 0;
00131 }

Generated on Mon Jun 19 12:31:05 2006 for MyDhcp_V2 by doxygen1.2.15