diff --git a/utils/mnetsubunsub/mnetsubunsub.c b/utils/mnetsubunsub/mnetsubunsub.c index 0aef13a..ed43293 100644 --- a/utils/mnetsubunsub/mnetsubunsub.c +++ b/utils/mnetsubunsub/mnetsubunsub.c @@ -305,17 +305,19 @@ int main(int argc, char **argv) { fprintf(stderr, "Error creating file %s\n", buffer); return -1; } - + + // add config line + fptr = fopen(argv[1], "a"); + fprintf(fptr, "MSGAREA %d, %d, %s\n", msg.area, msg.daddr, argv[5]); + fclose(fptr); + msg_to_nl(&msg); fwrite(&msg, sizeof(struct msg_t), 1, fptr); fwrite("ADD\r", 4, 1, fptr); fclose(fptr); - // add config line - fptr = fopen(argv[1], "a"); - fprintf(fptr, "MSGAREA %d, %d, %s\n", msg.area, msg.daddr, argv[5]); - fclose(fptr); + } else if (strcasecmp(argv[2], "REMOVE") == 0) { // send remove control message @@ -355,14 +357,15 @@ int main(int argc, char **argv) { return -1; } + // remove config line + remove_config_file_area(msg.area); + msg_to_nl(&msg); fwrite(&msg, sizeof(struct msg_t), 1, fptr); fwrite("REMOVE\r", 7, 1, fptr); fclose(fptr); - // remove config line - remove_config_file_area(msg.area); } return 0;