Changeset - c89c9fbb46f7
[Not reviewed]
default
0 1 0
ethanzonca - 16 years ago 2009-07-25 01:01:24

Added argument parsing, and some additional stuff
1 file changed with 30 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/server/slave.c
Show inline comments
 
@@ -29,24 +29,44 @@
 

	
 
// Provides DISTREN_REQUEST* which is in reality, DISTREN_SEND(signal) in the minds of your average joe
 
#include "protocol.h"
 
#include <string.h>
 

	
 
int main(int argc, char *arvg[])
 
int slavestatus = 0; // Ugh global vars
 

	
 
int main(int argc, char *argv[])
 
{
 

	
 
	/* Semi-pseudo Slave Code */
 

	
 

	
 
	int slavestatus = 0;
 
/* Parses arguments, skips if there are no args */
 
	if(argc>1
 
		&& (strcmp("-c", argv[1]) == 0))
 
	{
 
		char *username;
 
		char *email;
 

	
 
	if('no username in config file, no key present'){
 
		fprintf(stderr "run distrend -c username] [emailaddr] to register")
 
	}
 
	if('they use a -c flag according to getopt, with 2 args'){
 
		if(argc != 4)
 
		{
 
			fprintf(stderr, "I need more arguments!\n%d is not enough!\n Invoke 'slave -c <username> <emailaddr> to register'", argc - 1);
 
			return 234;
 
		}
 

	
 
		username = argv[2];
 
		email = argv[3];
 

	
 
		if(!strchr(email, '@'))
 
		{
 
			fprintf(stderr, "I want to see an '@' in your email address!\n%s may be good enough for you, but I need more!\n", email);
 
			return 235;
 
		}
 
		*key = register_user(username, email); // register_user returns a uniquely random url to a key
 
		get("http://protofusion.org/distren/key/%s",key);
 
		fprintf(stderr, "you registered, hopefully successfully. Invoke distrend with no args now.");
 
		exec('echo %s >> distrend.conf',key);
 
	}
 
	if('username is in conf file and key is present'){
 
/* End arg parser */
 

	
 

	
 

	
 
	if('username and the user\'s key filename are in conf file'){
 
		loginuser(username);
 
	}
 

	
0 comments (0 inline, 0 general)