C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 20th, 2003, 03:24 PM
dmittner dmittner is offline
Dazed&Confused
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Tempe, AZ
Posts: 91 dmittner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 34 m 13 sec
Reputation Power: 7
Send a message via ICQ to dmittner Send a message via AIM to dmittner
C, Linux - Decoding URLs

Greetings...

I'm working on a program that parses Apache log files and manipulates, then records, their data. I'm nearly finished but am running into a small problem with pulling apart search keywords from the refering page, for example:

Code:
http://search.yahoo.com/search?p=this+is+a+test&ei=UTF-8


I've got it stripping out everything I don't need, leaving the 'this+is+a+test' remaining. Substituting the pluses for spaces is easy enough, but the problem comes in if there are any special characters encoded in the %## format.

I have an idea of how I can translate these, but I don't doubt it's a verbose and inefficient way, so I was wondering if anyone knows of a function that already does this. Not being familiar with any of this, the answer could well be right in front of me and I'm not seeing it.

Anyway... any info is appeciated.

Last edited by dmittner : June 20th, 2003 at 03:26 PM.

Reply With Quote
  #2  
Old June 21st, 2003, 11:03 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,587 Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 21 h 21 m 5 sec
Reputation Power: 997
Well, those numbers represent the ascii value of the character, in hex. E.g. %20 - 20 in hex is 32 in decimal, which is the ascii code for the space character. You could use sscanf() to translate the hex value to int and then cast that to a char.

Reply With Quote
  #3  
Old June 21st, 2003, 12:21 PM
dmittner dmittner is offline
Dazed&Confused
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Tempe, AZ
Posts: 91 dmittner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 34 m 13 sec
Reputation Power: 7
Send a message via ICQ to dmittner Send a message via AIM to dmittner
Thanks for the reply, but I ended up taking the verbose route, I just go through the string, pull the next two characters if it hits a percent sign, finds out what to substitute with a bunch of if statements, then adds it to a new string. Probably not full-proof, but good enough for now.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > C, Linux - Decoding URLs


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT