Anope IRC Services

Anope Development => Modules => Topic started by: CrazyCat on December 15, 2011, 10:48:52 AM

Title: bs_quotes - Possible new features and improvment
Post by: CrazyCat on December 15, 2011, 10:48:52 AM
Hello there,

I've a few idea about bs_quotes and I need your feedback before beginning develop them:
Title: Re: bs_quotes - Possible new features and improvment
Post by: CrazyCat on January 25, 2012, 09:14:49 PM
Hello there,

I'm a really beginner in C and I've a small question for you.
I want, as said in my previous post, make the mysql config optional. So, the wanted working might be: if QuoteMySQLHost isn't defined in config, use MySQLHost. And if it isn't defined, return error.

What I did:
Code: [Select]
char *Q_MYSQL_HOST = NULL;
/* ... now in load_config, called by AnopeInit */
Directive confvalues[][1] = {
    {{ "QuoteMySQLHost",       { { PARAM_STRING, PARAM_RELOAD, &Q_MYSQL_HOST       } } }},
    {{ "QuoteMySQLPort",       { { PARAM_PORT,   PARAM_RELOAD, &Q_MYSQL_PORT       } } }},
    {{ "QuoteMySQLSocket",     { { PARAM_STRING, PARAM_RELOAD, &Q_MYSQL_SOCK       } } }},
    {{ "QuoteMySQLUser",       { { PARAM_STRING, PARAM_RELOAD, &Q_MYSQL_USER       } } }},
    {{ "QuoteMySQLPassword",   { { PARAM_STRING, PARAM_RELOAD, &Q_MYSQL_PASS       } } }},
    {{ "QuoteMySQLDatabase",   { { PARAM_STRING, PARAM_RELOAD, &Q_MYSQL_DB         } } }},
    {{ "QuoteEnableMultiLine", { { PARAM_SET,    PARAM_RELOAD, &Q_ENABLE_MULTILINE } } }},
    {{ "QuoteMySQLTable",      { { PARAM_STRING, PARAM_RELOAD, &Q_MYSQL_TABLE      } } }}
  };

   /* Setting of MySQLHost */
  moduleGetConfigDirective(confvalues[0]);
  if (!Q_MYSQL_HOST) {
     Directive confvalues[0][1] = {
      {{ "MySQLHost",       { { PARAM_STRING, PARAM_RELOAD, &Q_MYSQL_HOST       } } }}
     };
     moduleGetConfigDirective(confvalues[0]);
     if (!Q_MYSQL_HOST) { alog("[\002bs_quotes\002]: Missing config options!"); return MOD_STOP; }
  }
  /* Will be done for sock, user, pass, db */

I wonder there is a better way to do this, so I ask you : wich ?
Thanks a lot !