| | |
Help designing an ftp client prompt.
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
I am designing an ftp client prompt in C (unix environment).
At this point, I have an infinite loop with an fprintf of the prompt on stdout and an fgets for reading user input.
I need help with the structure of my program. How do I implement this?
I have two char* arrays. One contains a listing of commands the client will use and the other contains a one line help description of each command in the first array (the order corresponds with each command location in the first array).
Provided I do an sscanf on the user input to find out the command and (1) optional argument if applicable, what is the best way to implement this? I'm guessing at some point I will need a switch statement.
Let's start with the help command. It will have the exact same functionality as a help command in an ftp client. help alone prints a listing of all commands and help arg prints help on a specific command.
Thanks for any help you can provide.
At this point, I have an infinite loop with an fprintf of the prompt on stdout and an fgets for reading user input.
I need help with the structure of my program. How do I implement this?
I have two char* arrays. One contains a listing of commands the client will use and the other contains a one line help description of each command in the first array (the order corresponds with each command location in the first array).
Provided I do an sscanf on the user input to find out the command and (1) optional argument if applicable, what is the best way to implement this? I'm guessing at some point I will need a switch statement.
Let's start with the help command. It will have the exact same functionality as a help command in an ftp client. help alone prints a listing of all commands and help arg prints help on a specific command.
Thanks for any help you can provide.
Well, I got this figured out.
I will do it this way:
command/argument processor function (extracts/separates a user command and its arguments)
if arg1 is "help" then help function is called with number of arguments the user supplied after help (in my case the user can only supply one argument)
the help function then decided to print a listing of all commands available (if the user typed "help" only) or show help for a specific function if there is an extra argument (ie. help chdir).
if 1st case - 'for' loop printing all elements of char* array.
if 2nd case - loop/process command array till command is found, then use index for the command to retrieve command description from 2nd char array.
I will do it this way:
command/argument processor function (extracts/separates a user command and its arguments)
if arg1 is "help" then help function is called with number of arguments the user supplied after help (in my case the user can only supply one argument)
the help function then decided to print a listing of all commands available (if the user typed "help" only) or show help for a specific function if there is an extra argument (ie. help chdir).
if 1st case - 'for' loop printing all elements of char* array.
if 2nd case - loop/process command array till command is found, then use index for the command to retrieve command description from 2nd char array.
![]() |
Similar Threads
- Looking for good FTP client with compare/sync feature (IT Professionals' Lounge)
- URGENT: FTP Client / Server using RMI (Java)
- Cannot FTP with Windows XP with any client or to any server (Networking Hardware Configuration)
- I can't make my FTP work (Growing an Online Community)
- ftp client issues...im so confused...plz help!!! (Windows Software)
Other Threads in the C Forum
- Previous Thread: joining two string or more
- Next Thread: airplane seat reservation
| Thread Tools | Search this Thread |
#include * ansi array arrays asterisks bash binarysearch centimeter changingto char character convert copyimagefile cprogramme creafecopyofanytypeoffileinc database dynamic execv feet fgets file floatingpointvalidation fork framework function getlogicaldrivestrin givemetehcodez grade gtkwinlinux hacking histogram ide inches include incrementoperators infiniteloop initialization input interest intmain() iso kernel keyboard kilometer license linked linkedlist linux list lists locate looping lowest matrix meter microsoft number oddnumber opendocumentformat openwebfoundation overwrite owf pdf pointer posix power probleminc process program programming radix recursion recv recvblocked research reversing scripting segmentationfault sequential single socket socketprograming socketprogramming standard strchr string suggestions systemcall test testing threads turboc unix urboc user variable wab whythiscodecausesegmentationfault windowsapi





