#include "apasrch_sm.h"
#define AV_WEB "http://service.bfast.com/bfast/click?siteid=26682941&bfpage=multimedia_smy&bfmid=22218516&user=befree&pg=q&q="
#define AV_IMG "http://service.bfast.com/bfast/click?siteid=26682941&bfpage=multimedia_smy&bfmid=22218516&user=befree&pg=q&stype=simage&q="
extern int APAsrch_sm(char *query);
extern int gLang;
main()
{
FILE *fp; /* file pointer to get HTML source */
char query[128]; /* user query */
getentry entries[16]; /* arguments from the user via http */
int dn; /* number of items in a web page */
int start; /* start point of the items */
short dspPreview; /* Display preview or not. YES or NO */
int i, x; /* for general use */
char line[256]; /* for general use */
int multimedia = 0; /* search multimedia? */
int dictionary = 0; /* search dictionary? */
strcpy(query, "\0"); /* initialize user query as NULL */
start = 0; /* start point, default as 0 */
dn = 10; /* display num's default as 10 */
dspPreview = YES; /* as default display preview image */
#ifdef FILEOUT
printf("Debugging Mode\n");
i = 2;
strcpy(entries[0].name, "qt");
strcpy(entries[0].val, "lion");
strcpy(entries[1].name, "dspNum");
strcpy(entries[1].val, "5");
strcpy(entries[2].name, "dspPreview");
strcpy(entries[2].val, "YES");
#else
i = ProcessGetMethod( entries );
#endif
/* 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 (!strcasecmp(entries[x].name, "start")) {
start = atoi(entries[x].val);
if (start <= 0) start = 0;
continue;
}
if (!strcasecmp(entries[x].name, "dspNum")) {
dn = atoi(entries[x].val);
if (dn <= 0) dn = 10;
continue;
}
if (!strcasecmp(entries[x].name, "dspPreview")) {
if (!strcasecmp(entries[x].val, "YES"))
dspPreview = YES;
else dspPreview = NO;
continue;
}
if (!strcasecmp(entries[x].name, "type")) {
if (!strcasecmp(entries[x].val, "multimedia"))
multimedia = YES;
else if (!strcasecmp(entries[x].val, "dictionary"))
dictionary = YES;
continue;
}
if (!strcasecmp(entries[x].name, "lang")) {
if ( !strcasecmp(entries[x].val, "Korean") ) {
gLang = KOREAN;
}
else gLang = ENGLISH;
continue;
}
}
#ifdef FILEOUT
printf("query [%s] dspNum : [%d] dspPreview : [%d]
\n", query, dn, dspPreview);
fflush(stdout);
#endif
if (dictionary) {
for (i=0; i 0 && start == 0)
{
i = APAsrch_sm(query);
if (i == 0) /* if there is no matching records */ {
// if no image, go to new interface
printf("\n");
exit(0);
if (gLang == KOREAN) fp = fopen(HTMLNORESULT_HAN, "r");
else fp = fopen(HTMLNORESULT, "r");
if (fp == NULL) {
printf("\n");
exit(0);
// fatal("HTML no result source file open failed");
}
while (fgets(line, 256, fp)) {
char *ptr;
if (ptr = (char *)strstr(line, "__QUERY__")) {
*ptr = '\0';
printf("%s%s%s\n", line, query, ptr+9);
}
else if (ptr=(char *)strstr(line, "__URL_QUERY__")) {
char buf2[256];
strcpy(buf2, query);
for (i=0; i»çÁø ´õº¸±â", query);
WebSearch(query, "web");
printf("%s", ptr+19);
}
else if ( (ptr = (char *)strstr(line, "__AUDIO_SEARCH_LINK__")) != NULL ) {
*ptr = '\0';
printf("%s", line);
WebSearch(query, "audio");
printf("%s", ptr+21);
}
else if ( (ptr = (char *)strstr(line, "__VIDEO_SEARCH_LINK__")) != NULL ) {
*ptr = '\0';
printf("%s", line);
WebSearch(query, "video");
printf("%s", ptr+21);
}
else printf("%s", line);
}
fclose(fp);
exit(0);
}
}
/* print the result */
printResult(start, dn, query, YES);
exit(0);
}