diff options
| author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-01-02 08:20:59 +0000 |
|---|---|---|
| committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-01-02 08:20:59 +0000 |
| commit | a819cb0cc0f54a042a088dfba9c1f6b817928641 (patch) | |
| tree | 7931a9d81367c184ca2550a1819ef685e3e0c927 /src/tools | |
| parent | 3617d7978899f830d952d9bac70ed14bb0cc0fd6 (diff) | |
Rewrote the vhost code, and moved it to be part of nickalias instead of in its own list. This also fixes being able to steal other users vhosts with /hs on
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2724 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/db-convert.c | 55 | ||||
| -rw-r--r-- | src/tools/db-convert.h | 20 |
2 files changed, 47 insertions, 28 deletions
diff --git a/src/tools/db-convert.c b/src/tools/db-convert.c index fbef58eed..c70f41ecd 100644 --- a/src/tools/db-convert.c +++ b/src/tools/db-convert.c @@ -324,6 +324,28 @@ int main(int argc, char *argv[]) } } + head = NULL; + if ((f = open_db_read("HostServ", "hosts.db", 3))) + { + int c; + HostCore *hc; + + while ((c = getc_db(f)) == 1) + { + hc = (HostCore *)calloc(1, sizeof(HostCore)); + READ(read_string(&hc->nick, f)); + READ(read_string(&hc->vIdent, f)); + READ(read_string(&hc->vHost, f)); + READ(read_string(&hc->creator, f)); + READ(read_int32(&hc->time, f)); + + hc->next = head; + head = hc; + } + + close_db(f); + } + /* Nick cores */ for (i = 0; i < 1024; i++) { @@ -432,6 +454,12 @@ int main(int argc, char *argv[]) << ((na->status & NS_FORBIDDEN) ? " FORBIDDEN" : "") << ((na->status & NS_NO_EXPIRE) ? " NOEXPIRE" : "") << std::endl; } + + HostCore *hc = findHostCore(na->nick); + if (hc) + { + fs << "MD VHOST " << hc->creator << " " << hc->time << " " << hc->vHost << " :" << hc->vIdent << std::endl; + } } } } @@ -891,33 +919,6 @@ int main(int argc, char *argv[]) } /* for (chanlists[i]) */ } /* for (i) */ - /* Section IV: Hosts */ - /* IVa: First database */ - if ((f = open_db_read("HostServ", "hosts.db", 3))) { - int c; - int32 time; - char *nick, *vIdent, *vHost, *creator; - - std::cout << "Converting hosts..." << std::endl; - - while ((c = getc_db(f)) == 1) { - READ(read_string(&nick, f)); - READ(read_string(&vIdent, f)); - READ(read_string(&vHost, f)); - READ(read_string(&creator, f)); - READ(read_int32(&time, f)); - if (vIdent) - std::cout << "Writing vHost for " << nick << " (" << vIdent << "@" << vHost << ")" << std::endl; - else - std::cout << "Writing vHost for " << nick << " (" << vHost << ")" << std::endl; - // because vIdent can sometimes be empty, we put it at the end of the list - fs << "HI " << nick << " " << creator << " " << time << " " << vHost << " :" - << (vIdent ? vIdent : "") << std::endl; - free(nick); if (vIdent) free(vIdent); free(vHost); free(creator); - } - close_db(f); - } // host database - /*********************************/ /* OPERSERV Section */ /*********************************/ diff --git a/src/tools/db-convert.h b/src/tools/db-convert.h index 6ffcdffdb..1ebeec9f4 100644 --- a/src/tools/db-convert.h +++ b/src/tools/db-convert.h @@ -68,6 +68,7 @@ typedef struct nickalias_ NickAlias; typedef struct nickcore_ NickCore; typedef struct chaninfo_ ChannelInfo; typedef struct badword_ BadWord; +typedef struct hostcore_ HostCore; struct memo_ { uint32 number; /* Index number -- not necessarily array position! */ @@ -189,6 +190,14 @@ struct badword_ { uint16 type; }; +struct hostcore_ { + HostCore *next; + char *nick; + char *vIdent; + char *vHost; + char *creator; + int32 time; +}; dbFILE *open_db_write(const char *service, const char *filename, int version); dbFILE *open_db_read(const char *service, const char *filename, int version); @@ -216,6 +225,7 @@ void close_db(dbFILE * f); ChannelInfo *chanlists[256]; NickAlias *nalists[1024]; NickCore *nclists[1024]; +HostCore *head = NULL; int b64_encode(char *src, size_t srclength, char *target, size_t targsize); @@ -774,7 +784,15 @@ void alpha_insert_chan(ChannelInfo * ci) ptr->prev = ci; } - +HostCore *findHostCore(char *nick) +{ + for (HostCore *hc = head; head; head = head->next) + { + if (nick && hc->nick && !mystricmp(hc->nick, nick)) + return hc; + } + return NULL; +} static char *int_to_base64(long); static long base64_to_int(char *); |
