| 1 | /* |
|---|
| 2 | FILE |
|---|
| 3 | glossary.c |
|---|
| 4 | $Id: glossary.c 660 2008-12-18 18:48:48Z hus $ |
|---|
| 5 | AUTHOR |
|---|
| 6 | (C) 2006-2010 Gary Wallis and Hugo Urquiza for Unixservice, LLC. |
|---|
| 7 | GPLv2 license applies see LICENSE file included. |
|---|
| 8 | PURPOSE |
|---|
| 9 | For tGlossary content html popups. |
|---|
| 10 | */ |
|---|
| 11 | |
|---|
| 12 | #include "mysqlrad.h" |
|---|
| 13 | |
|---|
| 14 | static char cLabel[33]={""}; |
|---|
| 15 | static char *cText=""; |
|---|
| 16 | |
|---|
| 17 | //Protos |
|---|
| 18 | void StyleSheet(void);//main.c |
|---|
| 19 | |
|---|
| 20 | // |
|---|
| 21 | //Local only |
|---|
| 22 | void SelectGlossary(char *cLabel); |
|---|
| 23 | void htmlGlossaryPage(void); |
|---|
| 24 | void htmlGlossary(void); |
|---|
| 25 | |
|---|
| 26 | void GlossaryGetHook(entry gentries[],int x) |
|---|
| 27 | { |
|---|
| 28 | register int i; |
|---|
| 29 | |
|---|
| 30 | for(i=0;i<x;i++) |
|---|
| 31 | { |
|---|
| 32 | if(!strcmp(gentries[i].name,"cLabel")) |
|---|
| 33 | sprintf(cLabel,"%.32s",gentries[i].val); |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | if(cLabel[0]) |
|---|
| 37 | { |
|---|
| 38 | MYSQL_RES *res; |
|---|
| 39 | MYSQL_ROW field; |
|---|
| 40 | |
|---|
| 41 | SelectGlossary(cLabel); |
|---|
| 42 | res=mysql_store_result(&gMysql); |
|---|
| 43 | |
|---|
| 44 | if((field=mysql_fetch_row(res))) |
|---|
| 45 | cText=field[0]; |
|---|
| 46 | else |
|---|
| 47 | cText="No description available"; |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | htmlGlossary(); |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | }//void GlossaryGetHook(entry gentries[],int x) |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | void htmlGlossary(void) |
|---|
| 57 | { |
|---|
| 58 | printf("Content-type: text/html\n\n"); |
|---|
| 59 | StyleSheet(); |
|---|
| 60 | printf("<title>%s Glossary Entry</title>\n",cLabel); |
|---|
| 61 | htmlGlossaryPage(); |
|---|
| 62 | exit(0); |
|---|
| 63 | |
|---|
| 64 | }//void htmlGlossary(void) |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | void htmlGlossaryPage(void) |
|---|
| 68 | { |
|---|
| 69 | printf("<b>%s Glossary Entry</b><br><br>\n" |
|---|
| 70 | "%s", |
|---|
| 71 | cLabel |
|---|
| 72 | ,cText |
|---|
| 73 | ); |
|---|
| 74 | |
|---|
| 75 | }//void htmlGlossaryPage() |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | void SelectGlossary(char *cLabel) |
|---|
| 79 | { |
|---|
| 80 | sprintf(gcQuery,"SELECT cText FROM tGlossary WHERE cLabel='%s'",cLabel); |
|---|
| 81 | mysql_query(&gMysql,gcQuery); |
|---|
| 82 | |
|---|
| 83 | if(mysql_errno(&gMysql)) |
|---|
| 84 | htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 85 | |
|---|
| 86 | }//void SelectGlossary(char *cLabel) |
|---|
| 87 | |
|---|