Skip to Main Content
Learn C the Hard Way: Practical Exercises on the Computational Subjects You Keep Avoiding (Like C)
book

Learn C the Hard Way: Practical Exercises on the Computational Subjects You Keep Avoiding (Like C)

by Zed A. Shaw
July 2015
Intermediate to advanced content levelIntermediate to advanced
380 pages
10h 15m
English
Addison-Wesley Professional
Content preview from Learn C the Hard Way: Practical Exercises on the Computational Subjects You Keep Avoiding (Like C)

Exercise 47. A Fast URL Router

Im now going to show you how I use the TSTree to do fast URL routing in Web servers that I’ve written. This works for simple URL routing that you might use at the edge of an application, but it doesn’t really work for the more complex (and sometimes unnecessary) routing found in many Web application frameworks.

To play with routing, I’m going to make a little command line tool that I’m calling urlor, which reads a simple file of routes, and then prompts the user to enter in URLs.

urlor.c

  1   #include <lcthw/tstree.h>   2   #include <lcthw/bstrlib.h>   3   4   TSTree *add_route_data(TSTree * routes, bstring line)   5   {   6       struct bstrList *data = bsplit(line, ' ');   7       check ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Modern C for Absolute Beginners: A Friendly Introduction to the C Programming Language

Modern C for Absolute Beginners: A Friendly Introduction to the C Programming Language

Slobodan Dmitrović

Publisher Resources

ISBN: 9780133124385Purchase Link