summaryrefslogtreecommitdiff
path: root/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'init.c')
-rw-r--r--init.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/init.c b/init.c
index f0a5066..6fae895 100644
--- a/init.c
+++ b/init.c
@@ -79,7 +79,19 @@ static char* get_time()
return asctime(timeinfo);
}
+char* newline_cut(char *str, struct gc_data *gc)
+{
+ char* data = (char*)malloc(gc->file_sz);
+ memset(data, '\0', gc->file_sz);
+ for(int i = 0 ; i < gc->file_sz; i++) {
+ if (*(str + i) != '\n') {
+ *(data + i) = *(str + i);
+ }
+ }
+ return data;
+
+}
static void get_bat_num(struct gc_data *gc)
{
@@ -87,12 +99,6 @@ static void get_bat_num(struct gc_data *gc)
}
-// static void run_thread()
-// {
-// pthread_t *
-// }
-
-
int main(void)
{
signal(SIGINT, signal_handler);
@@ -101,8 +107,9 @@ int main(void)
setup_fd(&gc);
get_bat_num(&gc);
-
- printf("%s\n", gc.bat0bufptr);
+ char* cropped = newline_cut(gc.bat0bufptr, &gc);
+ printf("%s", cropped);
+ free(cropped);
run_garbage_collector_clear(&gc);
return 0;