#include "NameHeader.h" #include "web.h" #define HTMLSRC "HTMLSrc/NameSearchTemplate.html" #define HTMLSRC_ENG "HTMLSrc/NameSearch_eng.html" #define DICT_DIR "/animal/Dic" #define KOREAN 1 static int lang = 0; main() { int fd; FILE *fin; /* html template */ DATA *d; char query[128]; /* user query */ getentry entries[16]; /* arguments from the user via http */ int Matched = 0; /* matched (1) or not (0) */ char buf[256]; char *ptr; int i, j, x; printf("Content-type: text/html\n\n"); if ( (fd = open(DATA_FILE, O_RDONLY)) < 0) { printf("Can't open data file [%s]\n", DATA_FILE); exit(0); } read(fd, (char *) &cnt, sizeof(int)); d = (DATA *) malloc(sizeof(DATA)*cnt); read(fd, (char *) d, sizeof(DATA)*cnt); close(fd); strcpy(query, "\0"); /* initialize user query as NULL */ i = ProcessGetMethod( entries ); /* extract user's requirements */ for (x=0; x<=i; x++) { if (!strcasecmp(entries[x].name, "qt")) { strcpy(query, entries[x].val); trim(query); continue; } } if ( (fin=fopen(HTMLSRC, "r")) == NULL) { printf("HTML template¸¦ ¿ ¼ö ¾ø½À´Ï´Ù. °ü¸®ÀÚ¿¡°Ô ¹®ÀÇÇϽʽÿÀ.\n"); exit(0); } while (fgets(buf, 256, fin)) { if ( (ptr=(char *)strstr(buf, "__QUERY__")) != NULL) { *ptr = '\0'; printf("%s%s%s", buf, query, ptr+9); } else if ( strstr(buf, "__RESULT__") && (strlen(query) > 0) ) { for (i=0, j=0; i < cnt; i++) { if (strstr(d[i].han, query)) Matched = 1; strlower(query); strcpy(buf, d[i].eng); strlower(buf); if (strstr(buf, query)) Matched = 1; strcpy(buf, d[i].sci); strlower(buf); if (strstr(buf, query)) Matched = 1; if (Matched) { j++; if (j==1) { printf("
| ¼ø¼ | ÇÑ±Û | ¿µ¾î | Çиí |
|---|
Á˼ÛÇÕ´Ï´Ù. ÁúÀÇ¿¡ ÀûÇÕÇÑ Ç׸ñÀÌ ¾ø½À´Ï´Ù.\n"); } else if ( strstr(buf, "__RESULT__") && (strlen(query) <= 0) ) printf("