Thread: write a license for c project

  1. #1
    Registered User
    Join Date
    Feb 2014
    Posts
    9

    write a license for c project

    Hi everyone, new on this site, but hope someone can help me solve this problem.

    i want to write a license check system for my c project(.c | .h).
    my project finished and now i want to set a license for it ...

    i want a license source with this

    when client want to run my compiled project ( ./myproject)

    the project first load a license like this :

    first check the server ip ... (linux ipv4)
    second go to this url : http://mysite.com/$serverip.txt

    if the file exist and in the file wrote (Active) come back and run the project

    else if the file not exist show ( there is not license)
    else if the file exist and wrote (Expired ) (in the http://mysite.com/$serverip.txt) Come back and show ( the license expired) and not run the project .(exit from file)(stop the file)

    please help me . tnx

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,416
    Is this merely a learning exercise on network programming, or are you really trying to write a license check for software to be sold?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Feb 2014
    Posts
    9
    this is merely a learning exercise on network programming forget the name (License) I need c source that work like this: get the server ip (ipv4) after that check the url : http://mysite.com/$serverip.txt the are 2 options : if this file (serverip.txt) exist : 1- check if there is (Active) word on this txt file (Just Active Word) get back to c project other classes and run the other project classes (work like license ( if there is license run other c clases)(pass the license function and go to run other clasees) 2- else if there is (Expire) word on this txt file (Just Expire Word) stop the running and show the error ( License Expired) and stop other clasees) if this file (serverip.txt) dosnt exsit : stop the running and show the error ( There is no License) and stop other clasees)

  4. #4
    Registered User
    Join Date
    Feb 2014
    Posts
    9
    Quote Originally Posted by laserlight View Post
    Is this merely a learning exercise on network programming, or are you really trying to write a license check for software to be sold?
    this is merely a learning exercise on network programming

    forget the name (License)

    I need c source that work like this:

    get the server ip (ipv4)
    after that check the url : http://mysite.com/$serverip.txt


    the are 2 options :

    if this file (serverip.txt) exist :

    1- check if there is (Active) word on this txt file (Just Active Word) get back to c project other classes and run the other project classes (work like license ( if there is license run other c clases)(pass the license function and go to run other clasees)
    2- else if there is (Expire) word on this txt file (Just Expire Word) stop the running and show the error ( License Expired) and stop other clasees)

    if this file (serverip.txt) dosnt exsit : stop the running and show the error ( There is no License) and stop other clasees)

  5. #5
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    To make requests for remote URLs probabls the easiest way is to use libcurl. After you pull down the remote file you can do whatever checks you want on the contents of that remote file and act accordingly.

    curl and libcurl

  6. #6
    Registered User
    Join Date
    Feb 2014
    Posts
    9
    Quote Originally Posted by c99tutorial View Post
    To make requests for remote URLs probabls the easiest way is to use libcurl. After you pull down the remote file you can do whatever checks you want on the contents of that remote file and act accordingly.

    curl and libcurl
    I now this but i dont want to use libcurl for some reason ... i just want some source that do like (what i said about theme)
    For example, to get ip :


    Code:
    #include <stdio.h>      
    #include <sys/types.h>
    #include <ifaddrs.h>
    #include <netinet/in.h> 
    #include <string.h> 
    #include <arpa/inet.h>
    
    int main (int argc, const char * argv[]) {
        struct ifaddrs * ifAddrStruct=NULL;
        struct ifaddrs * ifa=NULL;
        void * tmpAddrPtr=NULL;
    
        getifaddrs(&ifAddrStruct);
    
        for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) {
            if (ifa ->ifa_addr->sa_family==AF_INET) { // check it is IP4
                // is a valid IP4 Address
                tmpAddrPtr=&((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
                char addressBuffer[INET_ADDRSTRLEN];
                inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, INET_ADDRSTRLEN);
                printf("%s IP Address %s\n", ifa->ifa_name, addressBuffer); 
            } else if (ifa->ifa_addr->sa_family==AF_INET6) { // check it is IP6
                // is a valid IP6 Address
                tmpAddrPtr=&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr;
                char addressBuffer[INET6_ADDRSTRLEN];
                inet_ntop(AF_INET6, tmpAddrPtr, addressBuffer, INET6_ADDRSTRLEN);
                printf("%s IP Address %s\n", ifa->ifa_name, addressBuffer); 
            } 
        }
        if (ifAddrStruct!=NULL) freeifaddrs(ifAddrStruct);
        return 0;
    }
    this is the first source i need the other functions

  7. #7
    Registered User
    Join Date
    Feb 2014
    Posts
    9
    Any answer !!! Update !

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,416
    Quote Originally Posted by justmyhope
    i dont want to use libcurl for some reason
    What reason might that be?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #9
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    Quote Originally Posted by justmyhope View Post
    I now this but i dont want to use libcurl for some reason ... i just want some source that do like (what i said about theme)
    Curl is just one example, they are open source so why not look at that code to see if you want to implement your own version. There is also this one you should look at

    Getting the W3C libwww Source

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help to write min,max program for a project
    By nightwolf9ss in forum C Programming
    Replies: 11
    Last Post: 01-21-2014, 12:14 PM
  2. Replies: 4
    Last Post: 08-02-2013, 06:45 PM
  3. How not to write a Project Proposal
    By Mario F. in forum General Discussions
    Replies: 3
    Last Post: 12-14-2009, 01:38 PM
  4. Picking a license
    By Hannwaas in forum Tech Board
    Replies: 4
    Last Post: 07-01-2005, 05:59 AM
  5. MS Academic License for VS.NET Pro
    By lightatdawn in forum Tech Board
    Replies: 4
    Last Post: 03-27-2004, 08:48 AM