Optus Netstat

This is a discussion on Optus Netstat within the C Programming forums, part of the General Programming Boards category; Hello all, what i want to do is to create a little application that will save me going through Optus ...

  1. #1
    -
    Join Date
    Feb 2003
    Posts
    47

    Angry Optus Netstat

    Hello all, what i want to do is to create a little application that will save me going through
    Optus webpage and give me my netstat information quickly.. i havent attempted this in C yet...
    here is an algorithm ive made that shows what needs to be done roughly..

    If any one can direct me to some tutorials or just tell me where to start that would be great.

    Code:
    BEGIN NetStat Algorithm
    	Display "Enter User Name"
    	Display "Enter Password"
    	Locate optus netstat url and enter the user name and pass.
    	Display the url's output.
    END Netstat Algorithm
    Now this is the URL that will get your Data Usage information
    https://myaccount.optusnet.com.au/my...age.txt?login=<username>&passwd=<password>

    So i need to be able to change <username> and <password> to whatever the user inputs..
    then it will display the output...

    thankz for anyone that can help, just looking for someone to point me in the right direction

  2. #2
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    well this will ask for username and passwd and print out the addres

    Code:
    #include <stdio.h>
    
    #define MAX_LENGTH      25
    
    int main() {
        char name[MAX_LENGTH];
        char passwd[MAX_LENGTH];
        
        printf("\nEnter User Name: ");
        fgets(name, (MAX_LENGTH - 1), stdin);
        printf("Enter Password: ");
        fgets(passwd, (MAX_LENGTH - 1), stdin);
        
        printf("\nhttps://myaccount.optusnet.com.au/m...sage.txt?login=%s%s\n", name, passwd);
    
        return 0;
    }
    toget data from the page your going so have to be creative. you could be brave and try sockets, and connect to the site and then parse threw. or you could try to some how download the page (might be easer to use sockets if you cant find a header/program to do it) and parse threw it.

  3. #3
    -
    Join Date
    Feb 2003
    Posts
    47
    Guess my code is a little fat then...
    well here is what i have so far...

    any 'pointers' plz let meh know..

    Code:
    /* 
       Optusnetstat
       By:
       Date: -
       contact: easye@optusnet.com.au
    */
    
    #include <stdio.h>
    
    /* variables */
    char UserName;
    char Password;
    
    int main()
    {
      printf ( "Welcome to Daniel's Optus Netstat Program\n" );
      printf ( "This program will find your Data Usage if \n"  );
      printf ( "you are an optus customer.\n\n" );
        
        UsersName();                            /* Call UsersName function */
        
      system("PAUSE");	
      return 0;
    }
    
    /* no data validation has been done, this is all assuming that
       data entered is valid. */
    
    int UsersName()
    {
        printf ( "Enter your user name: " );
            scanf ( "%s" , &UserName );         /* get users input */
        printf ( "Stub: %s\n" , &UserName );    /* Test stub */
            UsersPassword();                    /* call UsersPassword function */
    }
    
    int UsersPassword()
    {
        printf ( "Enter your password: " );     
            scanf ( "%s" , &Password );         /* get users password */
        printf ( "Stub: %s\n\n" , &Password );  /* test stub */
    }

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    /* variables */
    char UserName;
    char Password;
    (a) Why are these global?
    (b) These are single characters. As such...

    Code:
    scanf ( "%s" , &UserName );         /* get users input */
    scanf ( "%s" , &Password );         /* get users password */
    (b) These are wrong. Use arrays, or dynamicly allocate space.
    (a) There is no need for globals here. While it's not wrong, it's certinly the lazy way to do this...

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    -
    Join Date
    Feb 2003
    Posts
    47
    thanks for all your help, yes i know globals are the lazy way to do things thus why i did it, im lazy. ill look up how you said to "Use arrays, or dynamicly allocate space" ill find out how to do that. thankz.

  6. #6
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    "Use arrays, or dynamicly allocate space"
    would he have to use a linked list? are there any alternatives? i was thinking malloc but can you figure out how much a user has type with out saving it (with out assembly/asm into the video card)?

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by mart_man00
    would he have to use a linked list? are there any alternatives? i was thinking malloc but can you figure out how much a user has type with out saving it (with out assembly/asm into the video card)?
    You could. You don't need to. An array would probably be best here. All he's getting is a name and password, neither of which are going to be huge in size.

    There are a few ways to do dynamic allocation. You can read one byte, malloc space, read another, realloc, later, rinse repeat... You could just malloc a chunk of memory at a time, say 1KB, read data, if there is more to read, malloc some more, etc.

    But here an array would be the easiest.

    For the original poster, an array is a list or series of the same data type. It takes the following form:

    data_type array_name[ARRAY_SIZE];

    So, to make a character array:

    signed char buffer[ 10 ];

    Thus, you have a block of 10 signed characters set aside from you.

    To access them you can either do it in one shot, using something like strcpy to copy a block of data into it at a time, or you can access each element individually.

    The one very important thing to remember about arrays is that the index of the array starts at zero and goes up to size - 1.

    So here, you'd have:

    buffer[0] ...through... buffer[9]

    That you could access. Accessing anything else is a BadThing(TM), because it's outside the boundries of the array. C does not stop you from doing this. You have to do this yourself.

    So, to access elements individually...

    buffer[0] = 'H';
    buffer[1] = 'i';
    buffer[2] = 'y';
    buffer[3] = 'a;
    buffer[4] = ' ';
    buffer[5] = 'c';
    buffer[6] = 'h';
    buffer[7] = 'u';
    buffer[8] = 'm';
    buffer[0] = '\0';

    Your C book of choice should cover arrays more.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Netstat
    By MetallicA in forum C++ Programming
    Replies: 3
    Last Post: 11-28-2004, 12:11 PM
  2. There is no netstat
    By Micko in forum Tech Board
    Replies: 2
    Last Post: 07-08-2004, 02:27 PM
  3. Netstat, nbtstat, nslookup, what else?
    By Stan100 in forum Networking/Device Communication
    Replies: 3
    Last Post: 07-01-2004, 10:19 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21