#include #include void db_insert_user(struct user u) { MYSQL *conn; char mysql_query_str[1024]; conn = mysql_init(NULL); if (!conn) { printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn)); exit(EXIT_FAILURE); } if (!mysql_real_connect(conn, "localhost", "user", "password", "mailserver", 0, NULL, 0)) { printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn)); exit(EXIT_FAILURE); } snprintf(mysql_query_str, 1024, "insert into virtual_users(domain_id, password, email) " "values (1, '%s', '%s')", u.p, u.n); if (mysql_query(conn, mysql_query_str)) { printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn)); exit(1); } mysql_close(conn); }