#include #include #include #include "graphic_render.h" /* Adjust these or set via environment if you prefer later. */ #ifndef DB_HOST #define DB_HOST "localhost" #endif #ifndef DB_USER #define DB_USER "shridhar" #endif #ifndef DB_PASS #define DB_PASS "ramarama1!" /* set at compile-time if you want */ #endif #ifndef DB_NAME #define DB_NAME "kamatpharma" #endif static void render_graphic_css(MYSQL *conn, int graphicID, int size){ MYSQL_RES *res=NULL; MYSQL_ROW row; char q[256]; printf("\n"); } static void render_graphic_table(MYSQL *conn, int graphicID){ MYSQL_RES *res=NULL; MYSQL_ROW row; char q[128]; snprintf(q,sizeof(q), "SELECT * FROM grid_data_16x16 WHERE id=%d", graphicID); if(mysql_query(conn,q)!=0){ printf("

Graphic load error: %s

\n", mysql_error(conn)); return; } res = mysql_store_result(conn); if(res && (row=mysql_fetch_row(res))){ printf("\n", graphicID); for(int i=1;i<=16;i++){ printf(""); for(int j=1;j<=16;j++){ int cell_index=(i-1)*16 + j; const char* cls = row[cell_index] ? row[cell_index] : "0"; printf("", graphicID, cls); } printf("\n"); } printf("
\n"); } if(res) mysql_free_result(res); } void g(int graphicID, int size){ MYSQL *conn = mysql_init(NULL); if(!conn || !mysql_real_connect(conn, DB_HOST, DB_USER, DB_PASS, DB_NAME, 0, NULL, 0)){ printf("\n", conn? mysql_error(conn):"init"); if(conn) mysql_close(conn); return; } render_graphic_css(conn, graphicID, size); render_graphic_table(conn, graphicID); mysql_close(conn); }