static void send_error_helper(const char sep, int errnum, const char *message) { sx_uuid_t node_uuid; CGI_PRINTF("%c\"ErrorMessage\":", sep); json_send_qstring(message ? message : ""); if (errnum == 500 || errnum == 400) { if (message) WARN("HTTP %d: %s", errnum, message); CGI_PUTS(",\"ErrorDetails\":"); json_send_qstring(msg_log_end()); } CGI_PUTS(",\"NodeId\":"); json_send_qstring(sx_hashfs_self_uuid(hashfs, &node_uuid)==OK ? node_uuid.string : "<UNKNOWN>"); CGI_PUTS(",\"ErrorId\":"); json_send_qstring(msg_get_id()); CGI_PUTC('}'); }
static void print_html(int status, const char *title, int errnum, const char *errmsg) { if (status) CGI_PRINTF("Status: %d\r\n", status); CGI_PRINTF("Content-Type: text/html\r\n\r\n"); CGI_PRINTF(HTML_1, errmsg ? 653: 600); CGI_PUTS(HTML_2); CGI_PUTS(LOGO); CGI_PUTS(HTML_3); if (errmsg) CGI_PRINTF("<h2>Error %d: %s</h2>", errnum, errmsg); unsigned int version; const sx_uuid_t *cluster_uuid = sx_hashfs_uuid(hashfs); const sx_uuid_t *dist_uuid = sx_hashfs_distinfo(hashfs, &version, NULL); sx_uuid_t node_uuid; CGI_PRINTF(HTML_4, cluster_uuid->string, sx_hashfs_self_uuid(hashfs, &node_uuid) == OK ? node_uuid.string : "<not assigned yet>", dist_uuid ? dist_uuid->string : "<not defined yet>", dist_uuid ? version : 0 ); }
static void print_html(int status, const char *title, int errnum, const char *errmsg) { if (status) CGI_PRINTF("Status: %d\r\n", status); CGI_PRINTF("Content-Type: text/html\r\n\r\n\ <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\ <html>\ <head><title>%s</title></head>", title); CGI_PUTS("<body style='background-color:#9fcdea'>\ <div style='position:absolute; top:50%; height:20em; margin-top: -10em; text-align:center; width: 90%;'>\ <img src=\""); CGI_PUTS(LOGO1);/* too large to put into printf */ CGI_PUTS(LOGO2); CGI_PUTS("\"/>"); if (errmsg) CGI_PRINTF("<h2>Error %d</h2><pre>%s</pre>", errnum, errmsg); CGI_PUTS("\ <h2>\ This is an <a href=\"http://www.skylable.com/products/sx\">"SERVER_NAME" node</a>\ </h2>\ </div>\ <div style=\"position: absolute; bottom:1em; right: 1em; border: #ddd 1px solid; font: 10px normal; color: #07c;\">"); unsigned int version; const sx_uuid_t *cluster_uuid = sx_hashfs_uuid(hashfs); const sx_uuid_t *dist_uuid = sx_hashfs_distinfo(hashfs, &version, NULL); sx_uuid_t node_uuid; CGI_PRINTF("Cluster UUID: %s<br>Node UUID: %s<br>Distribution: ", cluster_uuid->string, sx_hashfs_self_uuid(hashfs, &node_uuid) == OK ? node_uuid.string : "<not assigned yet>"); if(dist_uuid) CGI_PRINTF("%s(%u)", dist_uuid->string, version); else CGI_PUTS("<not defined yet>"); CGI_PUTS("\ </div>\ </body>\ </html>"); }