-
Notifications
You must be signed in to change notification settings - Fork 0
/
addauthor.c
56 lines (40 loc) · 1.08 KB
/
addauthor.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*Domenic Bianchi
CIS 2750 Assignment 2
February 19, 2017
This program adds or removes a user from a stream or multiple streams*/
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include "addauthor.h"
#include "stream.h"
int main(int argc, char * argv[]) {
char list[256];
char name[256];
char statusMessage[256];
bool removeFlag = false;
clearArray(list, 256);
clearArray(name, 256);
clearArray(statusMessage, 256);
if (strcmp(argv[1], "-r") == 0) {
removeFlag = true;
}
updateStreams(argv[3], argv[2], statusMessage, removeFlag);
printf("%s", statusMessage);
return 0;
}
void updateStreams(char username[], char streamList[], char statusMessage[], bool flag) {
/*If falg is true, that means the -r flag was included in the user input and the user should be removed for the stream(s)*/
if (flag == true) {
removeUser(username, streamList);
}
else {
addUser(username, streamList, statusMessage);
}
}
void clearArray(char string[], int length) {
int j = 0;
/*Set entire array to null terminators*/
for (j = 0; j < length; j++) {
string[j] = '\0';
}
}