Guest User

Untitled

a guest
Jun 16th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.43 KB | None | 0 0
  1. /************************************************************************
  2. * mIRC MySQL interface.cpp
  3. * Copyright (C) 2000-2003 Michael Reynolds
  4. * Modified by Bas 'soczol' Verhoeven
  5. *
  6. * See file readme.txt for additional names of the programmers.
  7. *
  8. * This file is part of mIRC MySQL.
  9. *
  10. * mIRC MySQL is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * mIRC MySQL is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with mIRC MySQL; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. */
  24.  
  25. #include "mircmysql.h"
  26.  
  27. /************************************************************************
  28. * Non MySQL functions *
  29. ************************************************************************/
  30.  
  31. mIRC(Echo)
  32. {
  33. char *data = _strdup(mIRCdata);
  34. if (data == NULL || strlen(data) == 0)
  35. {
  36. // 030 - Null data.
  37. strcpy(mIRCdata, "0 030 Echo");
  38. }
  39. else
  40. {
  41. snprintf(mIRCdata, BUFSIZE, "You supplied: %s", data);
  42. }
  43. free(data);
  44. return Status::ReturnData;
  45. }
  46.  
  47. mIRC(Reverse)
  48. {
  49. char *data = _strdup(mIRCdata);
  50. strncpy(mIRCdata, _strrev(data), BUFSIZE);
  51. free(data);
  52. return Status::ReturnData;
  53. }
  54.  
  55. mIRC(DLLInfo)
  56. {
  57. #if !defined(STATUS) || STATUS==ALPHA || STATUS==BETA || STATUS==RC
  58. snprintf(mIRCdata,BUFSIZE,"mIRC MySQL v%d.%d.%.2d(%s) for libmysql v%s by wshs, modified by soczol. [\37\2NO SUPPORT FOR THIS VERSION\2\37\17]",VERSIONmajor,VERSIONminor,VERSIONpatch,bench,mysql_get_client_info());
  59. #else
  60. snprintf(mIRCdata,BUFSIZE,"mIRC MySQL v%d.%d.%.2d(%s) for libmysql v%s by wshs.",VERSIONmajor,VERSIONminor,VERSIONpath,bench,mysql_get_client_info());
  61. #endif
  62. return Status::ReturnData;
  63. }
  64.  
  65. mIRC(ToBase64)
  66. {
  67. //char *data=_strdup(mIRCdata);
  68. //unsigned long i=0;
  69. //if (data==NULL || *data=='\0')
  70. // mIRCdata="0 030 ToBase64";
  71. //else {
  72. // i=strtoul(data,NULL,10);
  73. // snprintf(mIRCdata,BUFSIZE,"1 026 ToBase64 %s",int_to_base64(i));
  74. //}
  75. //free(data);
  76. //return 3;
  77.  
  78. strcpy(mIRCdata, "Not supported");
  79. return Status::ReturnData;
  80. }
  81.  
  82. mIRC(ToBase10)
  83. {
  84. //char *data=_strdup(mIRCdata);
  85. //unsigned long i=0;
  86. //if (data==NULL || *data=='\0')
  87. // mIRCdata="0 030 ToBase10";
  88. //else {
  89. // i=base64_to_int(data);
  90. // snprintf(mIRCdata,BUFSIZE,"1 026 ToBase10 %lu",i);
  91. //}
  92. //free(data);
  93. //return 3;
  94.  
  95. strcpy(mIRCdata, "Not supported");
  96. return Status::ReturnData;
  97. }
  98.  
  99. LABELS *GetLabel(char *labelname, char *function, char **mIRCdata)
  100. {
  101. LABELS *ret = NULL;
  102.  
  103. if (labelname == NULL || strlen(labelname) == 0)
  104. {
  105. // 001 - No label specified.
  106. snprintf(*mIRCdata, BUFSIZE, "0 001 %s", function);
  107. }
  108. else if (strlen(labelname) > LBLMAX)
  109. {
  110. // 002 - Label too long.
  111. snprintf(*mIRCdata, BUFSIZE, "0 002 %s %s", function, labelname);
  112. }
  113. else if ((ret = findlabel(labelname)) == NULL)
  114. {
  115. // 012 - Label not in use.
  116. snprintf(*mIRCdata, BUFSIZE, "0 012 %s %s", function, labelname);
  117. }
  118.  
  119. return ret;
  120. }
  121.  
  122. /************************************************************************
  123. * MySQL functions *
  124. ************************************************************************/
  125.  
  126. // Yuck, me no touchie..
  127. mIRC(Connect) {
  128. char *data=_strdup(mIRCdata),*lbl=NULL,*input_word_1=NULL,*sql_host=NULL,*sql_db=NULL,*sql_user=NULL,*sql_pass=NULL,*timeout=NULL;
  129. const char *sqlerror;
  130. lbl=strtok(data," "),input_word_1=strtok(NULL," ");
  131. int sqlerrno=0,sql_port=MYSQL_PORT,ssl=0,compress=0,flags=0;
  132. bool error=false;
  133. LABELS *templabel=NULL;
  134. if (check_version(1)) {
  135. mIRCdata="";
  136. error=true;
  137. }
  138. else if (lbl==NULL || *lbl=='\0') {
  139. mIRCdata="0 001 Connect";
  140. error=true;
  141. }
  142. else if (strlen(lbl) > LBLMAX) {
  143. snprintf(mIRCdata,BUFSIZE,"0 002 Connect %s",lbl);
  144. error=true;
  145. }
  146. else if (atoi(lbl) != 0) {
  147. snprintf(mIRCdata,BUFSIZE,"0 003 Connect %s",lbl);
  148. error=true;
  149. }
  150. else if (findlabel(lbl) != NULL) {
  151. snprintf(mIRCdata,BUFSIZE,"0 004 Connect %s",lbl);
  152. error=true;
  153. }
  154. else {
  155. if (input_word_1 && *input_word_1 && (*input_word_1 == '-')) {
  156. while (*input_word_1++ && !error) {
  157. switch (*input_word_1) {
  158. case 'h':
  159. sql_host=strtok(NULL," ");
  160. if (sql_host==NULL || *sql_host=='\0') {
  161. mIRCdata="0 005 Connect";
  162. error=true;
  163. }
  164. break;
  165. case 'p':
  166. sql_port=atoi(strtok(NULL," "));
  167. if (!sql_port) {
  168. mIRCdata="0 006 Connect";
  169. error=true;
  170. }
  171. break;
  172. case 'u':
  173. sql_user=strtok(NULL," ");
  174. if (sql_user==NULL || *sql_user=='\0') {
  175. mIRCdata="0 007 Connect";
  176. error=true;
  177. }
  178. break;
  179. case 'w':
  180. sql_pass=strtok(NULL," ");
  181. if (sql_pass==NULL || *sql_pass=='\0') {
  182. mIRCdata="0 008 Connect";
  183. error=true;
  184. }
  185. break;
  186. case 'd':
  187. sql_db=strtok(NULL," ");
  188. if (sql_db==NULL || *sql_db=='\0') {
  189. mIRCdata="0 019 Connect";
  190. error=true;
  191. }
  192. break;
  193. case 't':
  194. timeout=strtok(NULL," ");
  195. if (atoi(timeout)==0) {
  196. mIRCdata="0 032 Connect";
  197. error=true;
  198. }
  199. break;
  200. case 's':
  201. ssl=1;
  202. flags|=CLIENT_SSL;
  203. break;
  204. case 'c':
  205. compress=1;
  206. flags|=CLIENT_COMPRESS;
  207. break;
  208. default:
  209. if (*input_word_1 && (*input_word_1 > 0) && (*input_word_1 != 32)) {
  210. snprintf(mIRCdata,BUFSIZE,"0 009 Connect %c",*input_word_1);
  211. error=true;
  212. }
  213. break;
  214. }
  215. }
  216. }
  217. }
  218. if (!error) {
  219. templabel=makelabel(lbl);
  220. mysql_init(&templabel->mysql);
  221. if (mysql_real_connect(&templabel->mysql,sql_host,sql_user,sql_pass,sql_db,sql_port,NULL,ssl|compress)) {
  222. if (timeout)
  223. mysql_options(&templabel->mysql,MYSQL_OPT_CONNECT_TIMEOUT,timeout);
  224. snprintf(mIRCdata,BUFSIZE,"1 010 Connect %s",lbl);
  225. }
  226. else {
  227. sqlerror=mysql_error(&templabel->mysql);
  228. sqlerrno=mysql_errno(&templabel->mysql);
  229. snprintf(mIRCdata,BUFSIZE,"0 011 Connect %d %s",sqlerrno,sqlerror);
  230. }
  231. }
  232. free(data);
  233. return Status::ReturnData;
  234. }
  235.  
  236. mIRC(Close)
  237. {
  238. char *data = _strdup(mIRCdata);
  239. LABELS *label;
  240.  
  241. // MySQL.dll,Close,<LABEL>
  242. // Closes the database connection.
  243.  
  244. if ((label = GetLabel(data, "Close", &mIRCdata)) == NULL)
  245. {
  246. free(data);
  247. return Status::ReturnData;
  248. }
  249.  
  250. removelabel(label);
  251.  
  252. // 013 - Successful close.
  253. snprintf(mIRCdata, BUFSIZE, "1 013 Close %s", data);
  254. free(data);
  255. return Status::ReturnData;
  256. }
  257.  
  258. mIRC(Labels)
  259. {
  260. char *data = _strdup(mIRCdata);
  261. int num = atoi(data);
  262. LABELS *label;
  263.  
  264. // MySQL.dll,Labels,[n]
  265. // If n is specified, and a positive number, the label matching that number will be returned.
  266. // If n is 0, or not specified, the total number of labels will be returned. If n is greater
  267. // than the number of labels, an error will be returned.
  268.  
  269. if (num == 0)
  270. {
  271. snprintf(mIRCdata, BUFSIZE, "1 016 Labels %d", labelcount());
  272. }
  273. else if (num < 0)
  274. {
  275. strcpy(mIRCdata, "0 015 Labels");
  276. }
  277. else if ((unsigned long)num > labelcount())
  278. {
  279. strcpy(mIRCdata, "0 014 Labels");
  280. }
  281. else
  282. {
  283. label = findlabel_by_digit(num);
  284. snprintf(mIRCdata, BUFSIZE, "1 016 Labels %s", label->label);
  285. }
  286.  
  287. free(data);
  288. return Status::ReturnData;
  289. }
  290.  
  291.  
  292. mIRC(Rows)
  293. {
  294. char *data = _strdup(mIRCdata);
  295. char *labelname = data;
  296. char buffer[(BUFSIZE - 20)] = "";
  297. LABELS *label = NULL;
  298.  
  299. // Usage: MySQL.dll,Rows,<LABEL>
  300. // Will return the number of rows returned by Query.
  301.  
  302. if ((label = GetLabel(data, "Rows", &mIRCdata)) == NULL)
  303. {
  304. free(data);
  305. return Status::ReturnData;
  306. }
  307.  
  308. if (label->result == NULL)
  309. {
  310. // 028 - No result available.
  311. snprintf(mIRCdata, BUFSIZE, "0 028 Rows %s", labelname);
  312. free(data);
  313. return Status::ReturnData;
  314. }
  315.  
  316. // 018 - Successful row count.
  317. snprintf(mIRCdata, BUFSIZE, "1 018 Rows %s %d", labelname, mysql_num_rows(label->result));
  318. free(data);
  319. return Status::ReturnData;
  320. }
  321.  
  322. mIRC(RowsAffected)
  323. {
  324. char *data = _strdup(mIRCdata);
  325. char *labelname = data;
  326. char buffer[(BUFSIZE - 20)] = "";
  327. LABELS *label = NULL;
  328.  
  329. // Usage: MySQL.dll,RowsAffected,<LABEL>
  330. // Will return the number of rows affected by a DELETE, UPDATE, or INSERT statement. If the
  331. // query was a SELECT statement, RowsAffected will return the same result as Rows.
  332.  
  333. if ((label = GetLabel(data, "RowsAffected", &mIRCdata)) == NULL)
  334. {
  335. free(data);
  336. return Status::ReturnData;
  337. }
  338.  
  339. if (label->result == NULL)
  340. {
  341. // 028 - No result available.
  342. snprintf(mIRCdata, BUFSIZE, "0 028 RowsAffected %s", labelname);
  343. free(data);
  344. return Status::ReturnData;
  345. }
  346.  
  347. // 018 - Successful row count.
  348. snprintf(mIRCdata, BUFSIZE, "1 018 RowsAffected %s %d", labelname, mysql_affected_rows(&label->mysql));
  349. free(data);
  350. return Status::ReturnData;
  351. }
  352.  
  353.  
  354. mIRC(Query)
  355. {
  356. char *data = _strdup(mIRCdata);
  357. char *tok, *temp, *labelname, *dbname = NULL, *query = NULL;
  358.  
  359. LABELS *label = NULL;
  360.  
  361. // Usage: MySQL.dll,Query,<LABEL> -d [DB] <QUERY>
  362.  
  363. // LABEL is the label you used when calling the Connect command. Use a standard MySQL query for
  364. // QUERY. If the -d flag is specified, then the default database will be changed to DB.
  365.  
  366. labelname = strtok_s(data, " ", &tok);
  367. temp = strtok_s(NULL, "", &tok);
  368.  
  369. if ((label = GetLabel(labelname, "Query", &mIRCdata)) == NULL)
  370. {
  371. free(data);
  372. return Status::ReturnData;
  373. }
  374.  
  375. if (temp == NULL || strlen(temp) == 0)
  376. {
  377. // 030 - Null data.
  378. snprintf(mIRCdata, BUFSIZE, "0 030 Query %s", labelname);
  379. free(data);
  380. return Status::ReturnData;
  381. }
  382.  
  383. query = temp;
  384.  
  385. // Check for '-d <database>'
  386. if (temp[0] == '-')
  387. {
  388. char *flags = strtok_s(temp, " ", &tok);
  389. if (strlen(flags) == 1 || flags[1] != 'd')
  390. {
  391. // 009 - Invalid option flag.
  392. snprintf(mIRCdata, BUFSIZE, "0 009 Query %s %c", labelname, (strlen(flags) == 1 ? '?' : flags[1]));
  393. free(data);
  394. return Status::ReturnData;
  395. }
  396.  
  397. if ((dbname = strtok_s(NULL, " ", &tok)) == NULL)
  398. {
  399. // 019 - No database specified.
  400. snprintf(mIRCdata, BUFSIZE, "0 019 Query %s", labelname);
  401. free(data);
  402. return Status::ReturnData;
  403. }
  404.  
  405. query = strtok_s(NULL, "", &tok);
  406. }
  407.  
  408. if (query == NULL)
  409. {
  410. // 030 - Null data.
  411. snprintf(mIRCdata, BUFSIZE, "0 030 Query %s", labelname);
  412. free(data);
  413. return Status::ReturnData;
  414. }
  415.  
  416. if (label->result != NULL)
  417. {
  418. mysql_free_result(label->result);
  419. label->result = NULL;
  420. }
  421.  
  422. if (mysql_ping(&label->mysql) != 0)
  423. {
  424. // 034 - Server connection dropped.
  425. snprintf(mIRCdata, BUFSIZE, "0 034 Query %s", labelname);
  426. free(data);
  427. return Status::ReturnData;
  428. }
  429.  
  430. if (dbname != NULL && mysql_select_db(&label->mysql, dbname) != 0)
  431. {
  432. // 020 - Unable to set DB.
  433. snprintf(mIRCdata, BUFSIZE, "0 020 Query %s %s", labelname, dbname);
  434. free(data);
  435. return Status::ReturnData;
  436. }
  437.  
  438. if (mysql_real_query(&label->mysql, query, strlen(query)) != 0)
  439. {
  440. // 021 - Unable to send Query.
  441. snprintf(mIRCdata, BUFSIZE, "0 021 Query %s %s", labelname, query);
  442. free(data);
  443. return Status::ReturnData;
  444. }
  445.  
  446. label->result = mysql_store_result(&label->mysql);
  447.  
  448. // 022 - Successful query.
  449. snprintf(mIRCdata, BUFSIZE, "1 022 Query %s %d", labelname, (label->result == NULL ? 0 : 1));
  450. free(data);
  451. return Status::ReturnData;
  452. }
  453.  
  454. mIRC(Fields)
  455. {
  456. char *data = _strdup(mIRCdata);
  457. char *labelname = data;
  458. char buffer[(BUFSIZE - 20)] = "";
  459.  
  460. int numfields;
  461. LABELS *label = NULL;
  462. MYSQL_FIELD *fields;
  463.  
  464. // Usage: MySQL.dll,Fields,<LABEL>
  465.  
  466. // Will return a comma delimited list of the field names returned by a Query.
  467.  
  468. if ((label = GetLabel(data, "Fields", &mIRCdata)) == NULL)
  469. {
  470. free(data);
  471. return Status::ReturnData;
  472. }
  473.  
  474. if (label->result == NULL)
  475. {
  476. // 028 - No result available.
  477. snprintf(mIRCdata, BUFSIZE, "0 028 Fields %s", labelname);
  478. free(data);
  479. return Status::ReturnData;
  480. }
  481.  
  482. numfields = mysql_num_fields(label->result);
  483.  
  484. if ((fields = mysql_fetch_fields(label->result)) == NULL)
  485. {
  486. // 031 - Null result.
  487. snprintf(mIRCdata, BUFSIZE, "0 031 Fields %s", labelname);
  488. free(data);
  489. return Status::ReturnData;
  490. }
  491.  
  492. for (int i = 0; i < numfields; i++)
  493. {
  494. char *value = (fields[i].name == NULL ? "NULL" : fields[i].name);
  495. if (strlen(buffer) + strlen(value) + 1 >= sizeof(buffer))
  496. {
  497. // 035 - Result too large.
  498. // TODO: Add to error file
  499. snprintf(mIRCdata, BUFSIZE, "0 035 Fields %s", labelname);
  500. free(data);
  501. return Status::ReturnData;
  502. }
  503.  
  504. if (strlen(buffer) > 0) strcat(buffer, ",");
  505. strcat(buffer, value);
  506. }
  507.  
  508. // 023 - Successful fields lookup.
  509. snprintf(mIRCdata, BUFSIZE, "1 023 Fields %s %d %s", labelname, numfields, buffer);
  510. free(data);
  511. return Status::ReturnData;
  512. }
  513.  
  514. mIRC(FetchRow)
  515. {
  516. char *data = _strdup(mIRCdata);
  517. char *tok, *labelname, *rownum, *seperator;
  518. char buffer[(BUFSIZE - 20)] = "";
  519.  
  520. int row, numfields;
  521. LABELS *label = NULL;
  522. MYSQL_ROW rowdata;
  523.  
  524. // Usage: MySQL.dll,FetchRow,<LABEL> <ROW> [SEPARATOR]
  525.  
  526. // Will return the row number specified by ROW, with data being separated by the character
  527. // specified by SEPARATOR. If SEPARATOR is not specified, a tab character will be assumed.
  528.  
  529. labelname = strtok_s(data, " ", &tok);
  530. rownum = strtok_s(NULL, " ", &tok);
  531. seperator = strtok_s(NULL, " ", &tok);
  532.  
  533. if ((label = GetLabel(labelname, "Query", &mIRCdata)) == NULL)
  534. {
  535. free(data);
  536. return Status::ReturnData;
  537. }
  538.  
  539. if (label->result == NULL)
  540. {
  541. // 028 - No result available.
  542. snprintf(mIRCdata, BUFSIZE, "0 028 FetchRow %s", labelname);
  543. free(data);
  544. return Status::ReturnData;
  545. }
  546.  
  547. if (rownum == NULL || strlen(rownum) == 0 || (row = atoi(rownum)) <= 0 || row > mysql_num_rows(label->result))
  548. {
  549. // 024 - Invalid row pointer.
  550. snprintf(mIRCdata, BUFSIZE, "0 024 FetchRow %s", labelname);
  551. free(data);
  552. return Status::ReturnData;
  553. }
  554.  
  555. if (seperator == NULL)
  556. {
  557. seperator = "\t";
  558. }
  559.  
  560. mysql_data_seek(label->result, (row - 1));
  561. numfields = mysql_num_fields(label->result);
  562.  
  563. if ((rowdata = mysql_fetch_row(label->result)) == NULL)
  564. {
  565. // 031 - Null result.
  566. snprintf(mIRCdata, BUFSIZE, "0 031 FetchRow %s %d", labelname, row);
  567. free(data);
  568. return Status::ReturnData;
  569. }
  570.  
  571. for (int i = 0; i < numfields; i++)
  572. {
  573. char *value = (rowdata[i] == NULL ? "NULL" : rowdata[i]);
  574. if (strlen(buffer) + strlen(value) + strlen(seperator) >= sizeof(buffer))
  575. {
  576. // 035 - Result too large.
  577. // TODO: Add to error file
  578. snprintf(mIRCdata, BUFSIZE, "0 035 FetchRow %s %d", labelname, row);
  579. free(data);
  580. return Status::ReturnData;
  581. }
  582.  
  583. if (strlen(buffer) > 0) strcat(buffer, seperator);
  584. strcat(buffer, value);
  585. }
  586.  
  587. // 025 - Successful row retrieval.
  588. snprintf(mIRCdata, BUFSIZE, "1 025 FetchRow %s %d %s", labelname, numfields, buffer);
  589. free(data);
  590. return Status::ReturnData;
  591. }
  592.  
  593. char *IntEscapeString(char *data)
  594. {
  595. char *escaped = (char *)calloc(1, (strlen(data) * 2) + 1);
  596. if (data != NULL)
  597. {
  598. mysql_escape_string(escaped, data, strlen(data));
  599. }
  600. return escaped;
  601. }
  602.  
  603. mIRC(EscapeString)
  604. {
  605. char *data = _strdup(mIRCdata);
  606.  
  607. if (data == NULL || strlen(data) == 0)
  608. {
  609. // 027 - Successful escape string.
  610. strcpy(mIRCdata, "1 027 EscapeString");
  611. }
  612. else
  613. {
  614. char *escape = IntEscapeString(data);
  615. snprintf(mIRCdata, BUFSIZE, "1 027 EscapeString %s", escape);
  616. free(escape);
  617. }
  618.  
  619. free(data);
  620. return Status::ReturnData;
  621. }
  622.  
  623. mIRC(bEscapeString)
  624. {
  625. char *data = _strdup(mIRCdata);
  626.  
  627. if (data == NULL || strlen(data) == 0)
  628. {
  629. strcpy(mIRCdata, "");
  630. }
  631. else
  632. {
  633. char *escape = IntEscapeString(data);
  634. strncpy(mIRCdata, escape, BUFSIZE);
  635. free(escape);
  636. }
  637.  
  638. free(data);
  639. return Status::ReturnData;
  640. }
  641.  
  642. mIRC(SetDatabase)
  643. {
  644. char *data = _strdup(mIRCdata);
  645. char *tok, *labelname, *dbname;
  646.  
  647. LABELS *label = NULL;
  648.  
  649. labelname = strtok_s(data, " ", &tok);
  650. dbname = strtok_s(NULL, "", &tok);
  651.  
  652. if ((label = GetLabel(labelname, "SetDatabase", &mIRCdata)) == NULL)
  653. {
  654. free(data);
  655. return Status::ReturnData;
  656. }
  657.  
  658. if (dbname == NULL || strlen(dbname) == 0)
  659. {
  660. // 019 - No database specified.
  661. snprintf(mIRCdata, BUFSIZE, "0 019 SetDatabase %s", labelname);
  662. free(data);
  663. return Status::ReturnData;
  664. }
  665.  
  666. if (mysql_ping(&label->mysql) != 0)
  667. {
  668. // 034 - Server connection dropped.
  669. snprintf(mIRCdata, BUFSIZE, "0 034 SetDatabase %s", labelname);
  670. free(data);
  671. return Status::ReturnData;
  672. }
  673.  
  674. if (mysql_select_db(&label->mysql, dbname) != 0)
  675. {
  676. // 020 - Unable to set DB.
  677. snprintf(mIRCdata, BUFSIZE, "0 020 SetDatabase %s", labelname);
  678. free(data);
  679. return Status::ReturnData;
  680. }
  681.  
  682. // 022 - Successful query.
  683. snprintf(mIRCdata, BUFSIZE, "1 022 SetDatabase %s", labelname);
  684. free(data);
  685. return Status::ReturnData;
  686. }
  687.  
  688. mIRC(Error)
  689. {
  690. char *data = _strdup(mIRCdata);
  691. LABELS *label;
  692.  
  693. if ((label = GetLabel(data, "Error", &mIRCdata)) == NULL)
  694. {
  695. free(data);
  696. return Status::ReturnData;
  697. }
  698.  
  699. // 029 - Successful error lookup.
  700. snprintf(mIRCdata, BUFSIZE, "1 029 Error %d %s", mysql_errno(&label->mysql), mysql_error(&label->mysql));
  701. free(data);
  702. return Status::ReturnData;
  703. }
Add Comment
Please, Sign In to add comment