ÃÑ ÆäÀÌÁö ¼ö : 3224
![]()
|
Facebook Joinc ±×·ì
Joinc QA »çÀÌÆ®
![]()
Tweet
joinc´Â Firefox¿Í chrome¿¡¼ Å×½ºÆ® Çß½À´Ï´Ù. IE¿¡¼´Â Å×À̺íÀÌ ±úÁö°Å³ª À̹ÌÁö°¡ º¸ÀÌÁö ¾ÊÀ» ¼ö ÀÖ½À´Ï´Ù. ƯÈ÷ ±¸±Û DocsÀ̹ÌÁöÀÇ °æ¿ì ¿¢¹Úó¸®µÉ ¼ö ÀÖ½À´Ï´Ù. Link ¾ò±â Sample
#include <sys/time.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <WWWLib.h>
#include <WWWInit.h>
#include <WWWHTML.h>
PRIVATE int terminate_handler (HTRequest * request, HTResponse * response,
void * param, int status)
{
/* We are done with this request */
HTRequest_delete(request);
/* Terminate libwww */
HTProfile_delete();
exit(0);
}
PRIVATE void foundLink (HText * text,
int element_number, int attribute_number,
HTChildAnchor * anchor,
const BOOL * present, const char ** value)
{
if (anchor) {
/*
** Find out which link we got. The anchor we are passed is
** a child anchor of the anchor we are current parsing. We
** have to go from this child anchor to the actual destination.
*/
HTAnchor * dest = HTAnchor_followMainLink((HTAnchor *) anchor);
char * address = HTAnchor_address(dest);
HTPrint("Found link `%s\'\n", address);
HT_FREE(address);
}
}
int main (int argc, char ** argv)
{
char * uri = NULL;
/* Create a new premptive client */
HTProfile_newHTMLNoCacheClient ("ShowLinks", "1.0");
/* Set trace messages and alert messages */
#if 0
HTSetTraceMessageMask("sop");
#endif
/* Add our own termination filter */
HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL, HT_FILTER_LAST);
/*
** Register our HTML link handler. We don't actually create a HText
** object as this is not needed. We only register the specific link
** callback.
*/
HText_registerLinkCallback(foundLink);
/* Setup a timeout on the request for 15 secs */
HTHost_setEventTimeout(15000);
/* Handle command line args */
if (argc >= 2)
uri = HTParse(argv[1], NULL, PARSE_ALL);
if (uri) {
HTRequest * request = NULL;
HTAnchor * anchor = NULL;
BOOL status = NO;
/* Create a request */
request = HTRequest_new();
/* Get an anchor object for the URI */
anchor = HTAnchor_findAddress(uri);
/* Issue the GET and store the result in a chunk */
status = HTLoadAnchor(anchor, request);
/* Go into the event loop... */
if (status == YES) HTEventList_loop(request);
} else {
HTPrint("Type the URI to print out a list of embedded links\n");
HTPrint("\t%s <uri>\n", argv[0]);
HTPrint("For example:\n");
HTPrint("\t%s http://www.w3.org\n", argv[0]);
}
return 0;
}
#############################################################################
# Makefile for building sample
# Generated by tmake at 20:01, 2006/01/09
# Project: sample
# Template: app
#############################################################################
####### Compiler, tools and options
CC = gcc
CXX = g++
CFLAGS = -pipe -Wall -W -O2
CXXFLAGS= -pipe -Wall -W -O2
INCPATH = -I/usr/include/w3c-libwww
LINK = gcc
LFLAGS =
LIBS = -L/usr/lib -lwwwcore -lwwwutils -lwwwhttp -lmd5 -lwwwmime -lwwwdir\
-lwwwfile -lwwwinit -lwwwmux -lwwwstream -lwwwtrans -lwwwxml -lwwwhtml \
-lwwwcache -lxmlparse -lxmltok -lwwwapp -lwwwnews -lwwwftp -lwwwtelnet\
-lwwwgopher -lwwwzip
TAR = tar -cf
GZIP = gzip -9f
####### Files
HEADERS =
SOURCES = sample.c
OBJECTS = sample.o
INTERFACES =
UICDECLS =
UICIMPLS =
SRCMOC =
OBJMOC =
DIST =
TARGET = sample
INTERFACE_DECL_PATH = .
####### Implicit rules
.SUFFIXES: .cpp .cxx .cc .C .c
.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.C.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
####### Build rules
all: $(TARGET)
$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)
dist:
$(TAR) sample.tar sample.pro $(SOURCES) $(HEADERS) $(INTERFACES) $(DIST)
$(GZIP) sample.tar
clean:
-rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) $(TARGET)
-rm -f *~ core
####### Sub-libraries
###### Combined headers
####### Compile
sample.o: sample.c
|
|
|
EmailÀ» ±âÀÔÇϸé, ´ñ±ÛÀÌ ¸ÞÀÏ·Î Àü´ÞµË´Ï´Ù. |
|