Server 0.0.1
HTTP/REST server implementation

src/http/message/get_version.c

Go to the documentation of this file.
00001 
00023 #include <string.h>
00024 #include <stdlib.h>
00025 
00026 #include "http/message.h"
00027 
00028 int
00029 httpMessageGetVersion(HttpMessage this, int * major, int * minor)
00030 {
00031         char * major_ptr = this->version + 5;
00032         char * minor_ptr = strchr(major_ptr, '.') + 1;
00033         char   version[] = "\0\0\0";
00034 
00035         if (NULL == minor_ptr ||
00036                         ((minor_ptr - major_ptr - 1) > 2) ||
00037                         strlen(minor_ptr) > 2)
00038                 return -1;
00039 
00040         memcpy(version, major_ptr, minor_ptr - major_ptr - 1);
00041         *major = atoi(version);
00042 
00043         memset(version, 0, 3);
00044         strcpy(version, minor_ptr);
00045         *minor = atoi(version);
00046 
00047         return ((*major)<<7)|(*minor);
00048 }
00049 
00050 // vim: set ts=4 sw=4:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines