mirror of
				https://github.com/taigrr/tplinkController
				synced 2025-01-18 04:43:13 -08:00 
			
		
		
		
	small formatting changes
This commit is contained in:
		
							parent
							
								
									f870b6458d
								
							
						
					
					
						commit
						4bbecdaea0
					
				
							
								
								
									
										15
									
								
								comms.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								comms.c
									
									
									
									
									
								
							| @ -48,12 +48,14 @@ bool hs100_decrypt(uint8_t *d, uint8_t *s, size_t len) | ||||
| 
 | ||||
| uint8_t *hs100_encode(size_t *outlen, char *srcmsg) | ||||
| { | ||||
| 	if(srcmsg == NULL) return NULL; | ||||
| 	if (srcmsg == NULL) | ||||
| 		return NULL; | ||||
| 
 | ||||
| 	size_t srcmsg_len = strlen(srcmsg); | ||||
| 	*outlen = srcmsg_len + 4; | ||||
| 	uint8_t *d = calloc(1, *outlen); | ||||
| 	if(d == NULL) return NULL; | ||||
| 	if (d == NULL) | ||||
| 		return NULL; | ||||
| 	if (!hs100_encrypt(d + 4, (uint8_t *) srcmsg, srcmsg_len)) { | ||||
| 		free(d); | ||||
| 		return NULL; | ||||
| @ -66,8 +68,10 @@ uint8_t *hs100_encode(size_t *outlen, char *srcmsg) | ||||
| 
 | ||||
| char *hs100_decode(uint8_t *s, size_t s_len) | ||||
| { | ||||
| 	if(s == NULL) return NULL; | ||||
| 	if(s_len <= 4) return NULL; | ||||
| 	if (s == NULL) | ||||
| 		return NULL; | ||||
| 	if (s_len <= 4) | ||||
| 		return NULL; | ||||
| 
 | ||||
| 	uint32_t in_s_len; | ||||
| 	memcpy(&in_s_len, s, 4); | ||||
| @ -95,7 +99,8 @@ char *hs100_send(char *servaddr, char *msg) | ||||
| 		return NULL; | ||||
| 
 | ||||
| 	int sock = socket(AF_INET, SOCK_STREAM, 0); | ||||
| 	if(sock < 0) return NULL; | ||||
| 	if (sock < 0) | ||||
| 		return NULL; | ||||
| 
 | ||||
| 	struct sockaddr_in address; | ||||
| 	memset(&address, '0', sizeof(struct sockaddr_in)); | ||||
|  | ||||
							
								
								
									
										15
									
								
								hs100.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								hs100.c
									
									
									
									
									
								
							| @ -67,8 +67,7 @@ struct cmd_s cmds[] = { | ||||
| struct cmd_s *get_cmd_from_name(char *needle) | ||||
| { | ||||
| 	int cmds_index = 0; | ||||
| 	while(!cmds[cmds_index].end) | ||||
| 	{ | ||||
| 	while (!cmds[cmds_index].end) { | ||||
| 		if (!strcmp(cmds[cmds_index].command, needle)) | ||||
| 			return &cmds[cmds_index]; | ||||
| 		cmds_index++; | ||||
| @ -78,16 +77,14 @@ struct cmd_s *get_cmd_from_name(char *needle) | ||||
| 
 | ||||
| void print_usage() | ||||
| { | ||||
| 	fprintf(stderr, "hs100 version " VERSION_STRING ", Copyright (C) 2018 Jason Benaim.\n" | ||||
| 			"A tool for using certain wifi smart plugs.\n" | ||||
| 			"\n" | ||||
| 			"usage: hs100 <ip> <command>\n" | ||||
| 			"\n" | ||||
| 	fprintf(stderr, "hs100 version " VERSION_STRING | ||||
| 			", Copyright (C) 2018 Jason Benaim.\n" | ||||
| 			"A tool for using certain wifi smart plugs.\n\n" | ||||
| 			"usage: hs100 <ip> <command>\n\n" | ||||
| 			"Commands:\n" | ||||
| 	); | ||||
| 	int cmds_index = 0; | ||||
| 	while(!cmds[cmds_index].end) | ||||
| 	{ | ||||
| 	while (!cmds[cmds_index].end) { | ||||
| 		fprintf(stderr, "\t%s\n\n", cmds[cmds_index].help); | ||||
| 		cmds_index++; | ||||
| 	} | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user