3 #define MAX_OUTPUT_CHARACTERS 5000
6 * - Clear e_exec_instances on shutdown
7 * - Clear e_exec_start_pending on shutdown
8 * - Create border add handler
9 * - Launch .desktop in terminal if .desktop requires it
12 typedef struct _E_Exec_Launch E_Exec_Launch;
13 typedef struct _E_Exec_Search E_Exec_Search;
18 const char *launch_method;
23 Efreet_Desktop *desktop;
28 struct _E_Config_Dialog_Data
30 Efreet_Desktop *desktop;
33 Ecore_Exe_Event_Del event;
34 Ecore_Exe_Event_Data *error;
35 Ecore_Exe_Event_Data *read;
37 char *label, *exit, *signal;
40 /* local subsystem functions */
41 static E_Exec_Instance *_e_exec_cb_exec(void *data, Efreet_Desktop *desktop, char *exec, int remaining);
42 static Eina_Bool _e_exec_cb_expire_timer(void *data);
43 static Eina_Bool _e_exec_cb_exit(void *data, int type, void *event);
45 static Eina_Bool _e_exec_startup_id_pid_find(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *value, void *data);
47 static void _e_exec_error_dialog(Efreet_Desktop *desktop, const char *exec, Ecore_Exe_Event_Del *event, Ecore_Exe_Event_Data *error, Ecore_Exe_Event_Data *read);
48 static void _fill_data(E_Config_Dialog_Data *cfdata);
49 static void *_create_data(E_Config_Dialog *cfd);
50 static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
51 static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
52 static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
53 static Evas_Object *_dialog_scrolltext_create(Evas *evas, char *title, Ecore_Exe_Event_Data_Line *lines);
54 static void _dialog_save_cb(void *data, void *data2);
55 static void _e_exec_instance_free(E_Exec_Instance *inst);
57 /* local subsystem globals */
58 static Eina_List *e_exec_start_pending = NULL;
59 static Eina_Hash *e_exec_instances = NULL;
60 static int startup_id = 0;
62 static Ecore_Event_Handler *_e_exec_exit_handler = NULL;
63 static Ecore_Event_Handler *_e_exec_border_add_handler = NULL;
65 /* externally accessible functions */
69 e_exec_instances = eina_hash_string_superfast_new(NULL);
71 _e_exec_exit_handler =
72 ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _e_exec_cb_exit, NULL);
74 _e_exec_border_add_handler =
75 ecore_event_handler_add(E_EVENT_BORDER_ADD, _e_exec_cb_event_border_add, NULL);
85 snprintf(buf, sizeof(buf), "%i", startup_id);
86 e_util_env_set("E_STARTUP_ID", buf);
88 if (_e_exec_exit_handler) ecore_event_handler_del(_e_exec_exit_handler);
89 if (_e_exec_border_add_handler)
90 ecore_event_handler_del(_e_exec_border_add_handler);
91 eina_hash_free(e_exec_instances);
92 eina_list_free(e_exec_start_pending);
96 EAPI E_Exec_Instance *
97 e_exec(E_Zone *zone, Efreet_Desktop *desktop, const char *exec,
98 Eina_List *files, const char *launch_method)
100 E_Exec_Launch *launch;
101 E_Exec_Instance *inst = NULL;
103 if ((!desktop) && (!exec)) return NULL;
104 launch = E_NEW(E_Exec_Launch, 1);
105 if (!launch) return NULL;
109 e_object_ref(E_OBJECT(launch->zone));
112 launch->launch_method = eina_stringshare_add(launch_method);
117 inst = _e_exec_cb_exec(launch, NULL, strdup(exec), 0);
119 inst = efreet_desktop_command_get(desktop, files,
120 (Efreet_Desktop_Command_Cb) _e_exec_cb_exec, launch);
123 inst = _e_exec_cb_exec(launch, NULL, strdup(exec), 0);
127 EAPI Efreet_Desktop *
128 e_exec_startup_id_pid_find(int startup_id, pid_t pid)
130 E_Exec_Search search;
132 search.desktop = NULL;
133 search.startup_id = startup_id;
135 eina_hash_foreach(e_exec_instances, _e_exec_startup_id_pid_find, &search);
136 return search.desktop;
139 /* local subsystem functions */
140 static E_Exec_Instance *
141 _e_exec_cb_exec(void *data, Efreet_Desktop *desktop, char *exec, int remaining)
143 E_Exec_Instance *inst = NULL;
144 E_Exec_Launch *launch;
152 inst = E_NEW(E_Exec_Instance, 1);
153 if (!inst) return NULL;
160 p = getenv("E_STARTUP_ID");
161 if (p) startup_id = atoi(p);
162 e_util_env_set("E_STARTUP_ID", NULL);
164 if (++startup_id < 1) startup_id = 1;
165 /* save previous env vars we need to save */
166 penv_display = getenv("DISPLAY");
167 if (penv_display) penv_display = strdup(penv_display);
168 if ((penv_display) && (launch->zone))
174 head = launch->zone->container->manager->num;
177 p1 = strrchr(penv_display, ':');
178 p2 = strrchr(penv_display, '.');
179 if ((p1) && (p2) && (p2 > p1)) /* "blah:x.y" */
181 /* yes it could overflow... but who will overflow DISPLAY eh? why? to
182 * "exploit" your own applications running as you?
184 strcpy(buf, penv_display);
185 buf[p2 - penv_display + 1] = 0;
186 snprintf(buf2, sizeof(buf2), "%i", head);
189 else if (p1) /* "blah:x */
191 strcpy(buf, penv_display);
192 snprintf(buf2, sizeof(buf2), ".%i", head);
196 strcpy(buf, penv_display);
197 e_util_env_set("DISPLAY", buf);
199 snprintf(buf, sizeof(buf), "E_START|%i", startup_id);
200 e_util_env_set("DESKTOP_STARTUP_ID", buf);
202 // dont set vsync for clients - maybe inherited from compositore. fixme:
203 // need a way to still inherit from parent env of wm.
204 e_util_env_set("__GL_SYNC_TO_VBLANK", NULL);
206 //// FIXME: seem to be some issues with the pipe and filling up ram - need to
207 //// check. for now disable.
208 // exe = ecore_exe_pipe_run(exec,
209 // ECORE_EXE_PIPE_AUTO | ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_ERROR |
210 // ECORE_EXE_PIPE_READ_LINE_BUFFERED | ECORE_EXE_PIPE_ERROR_LINE_BUFFERED,
212 if ((desktop) && (desktop->path) && (desktop->path[0]))
214 if (!getcwd(buf, sizeof(buf)))
217 e_util_dialog_show(_("Run Error"),
218 _("Enlightenment was unable to get current directory"));
221 if (chdir(desktop->path))
224 e_util_dialog_show(_("Run Error"),
225 _("Enlightenment was unable to change to directory:<br>"
231 e_util_library_path_strip();
232 exe = ecore_exe_run(exec, inst);
233 e_util_library_path_restore();
236 e_util_dialog_show(_("Run Error"),
237 _("Enlightenment was unable to restore to directory:<br>"
247 e_util_library_path_strip();
248 exe = ecore_exe_run(exec, inst);
249 e_util_library_path_restore();
254 e_util_env_set("DISPLAY", penv_display);
260 e_util_dialog_show(_("Run Error"),
261 _("Enlightenment was unable to fork a child process:<br>"
268 if (launch->launch_method && !desktop)
269 e_exehist_add(launch->launch_method, exec);
271 /* 20 lines at start and end, 20x100 limit on bytes at each end. */
272 //// FIXME: seem to be some issues with the pipe and filling up ram - need to
273 //// check. for now disable.
274 // ecore_exe_auto_limits_set(exe, 2000, 2000, 20, 20);
275 ecore_exe_tag_set(exe, "E/exec");
281 efreet_desktop_ref(desktop);
282 inst->desktop = desktop;
283 inst->key = eina_stringshare_add(desktop->orig_path);
285 inst->startup_id = startup_id;
286 inst->launch_time = ecore_time_get();
287 inst->expire_timer = ecore_timer_add(e_config->exec.expire_timeout,
288 _e_exec_cb_expire_timer, inst);
289 l = eina_hash_find(e_exec_instances, desktop->orig_path);
290 lnew = eina_list_append(l, inst);
292 eina_hash_modify(e_exec_instances, desktop->orig_path, lnew);
294 eina_hash_add(e_exec_instances, desktop->orig_path, lnew);
295 e_exec_start_pending = eina_list_append(e_exec_start_pending, desktop);
297 e_exehist_add(launch->launch_method, desktop->exec);
308 if (launch->launch_method) eina_stringshare_del(launch->launch_method);
309 if (launch->zone) e_object_unref(E_OBJECT(launch->zone));
316 _e_exec_cb_expire_timer(void *data)
318 E_Exec_Instance *inst;
321 e_exec_start_pending = eina_list_remove(e_exec_start_pending, inst->desktop);
322 inst->expire_timer = NULL;
323 return ECORE_CALLBACK_CANCEL;
327 _e_exec_instance_free(E_Exec_Instance *inst)
329 Eina_List *instances;
333 instances = eina_hash_find(e_exec_instances, inst->key);
336 instances = eina_list_remove(instances, inst);
338 eina_hash_modify(e_exec_instances, inst->key, instances);
340 eina_hash_del(e_exec_instances, inst->key, NULL);
342 eina_stringshare_del(inst->key);
344 e_exec_start_pending = eina_list_remove(e_exec_start_pending, inst->desktop);
345 if (inst->expire_timer) ecore_timer_del(inst->expire_timer);
346 if (inst->desktop) efreet_desktop_free(inst->desktop);
353 _e_exec_cb_instance_finish(void *data)
355 _e_exec_instance_free(data);
356 return ECORE_CALLBACK_CANCEL;
361 _e_exec_cb_exit(void *data __UNUSED__, int type __UNUSED__, void *event)
363 Ecore_Exe_Event_Del *ev;
364 E_Exec_Instance *inst;
367 if (!ev->exe) return ECORE_CALLBACK_PASS_ON;
368 // if (ecore_exe_tag_get(ev->exe)) printf(" tag %s\n", ecore_exe_tag_get(ev->exe));
369 if (!(ecore_exe_tag_get(ev->exe) &&
370 (!strcmp(ecore_exe_tag_get(ev->exe), "E/exec"))))
371 return ECORE_CALLBACK_PASS_ON;
372 inst = ecore_exe_data_get(ev->exe);
373 if (!inst) return ECORE_CALLBACK_PASS_ON;
375 /* /bin/sh uses this if cmd not found */
377 ((ev->exit_code == 127) || (ev->exit_code == 255)))
379 if (e_config->exec.show_run_dialog)
383 dia = e_dialog_new(e_container_current_get(e_manager_current_get()),
384 "E", "_e_exec_run_error_dialog");
389 e_dialog_title_set(dia, _("Application run error"));
390 snprintf(buf, sizeof(buf),
391 _("Enlightenment was unable to run the application:<br>"
395 "The application failed to start."),
396 ecore_exe_cmd_get(ev->exe));
397 e_dialog_text_set(dia, buf);
398 e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
399 e_dialog_button_focus_num(dia, 1);
400 e_win_centered_set(dia->win, 1);
405 /* Let's hope that everything returns this properly. */
406 else if (!((ev->exited) && (ev->exit_code == EXIT_SUCCESS)))
408 if (e_config->exec.show_exit_dialog)
410 /* filter out common exits via signals - int/term/quit. not really
411 * worth popping up a dialog for */
412 if (!((ev->signalled) &&
413 ((ev->exit_signal == SIGINT) ||
414 (ev->exit_signal == SIGQUIT) ||
415 (ev->exit_signal == SIGTERM)))
418 /* Show the error dialog with details from the exe. */
419 _e_exec_error_dialog(inst->desktop, ecore_exe_cmd_get(ev->exe), ev,
420 ecore_exe_event_data_get(ev->exe, ECORE_EXE_PIPE_ERROR),
421 ecore_exe_event_data_get(ev->exe, ECORE_EXE_PIPE_READ));
426 /* maybe better 1 minute? it might be openoffice */
427 if (ecore_time_get() - inst->launch_time < 2.0)
430 if (inst->expire_timer) ecore_timer_del(inst->expire_timer);
431 inst->expire_timer = ecore_timer_add(e_config->exec.expire_timeout, _e_exec_cb_instance_finish, inst);
434 _e_exec_instance_free(inst);
436 return ECORE_CALLBACK_PASS_ON;
440 _e_exec_startup_id_pid_find(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *value, void *data)
442 E_Exec_Search *search;
443 E_Exec_Instance *inst;
447 EINA_LIST_FOREACH(value, l, inst)
449 if (((search->startup_id > 0) &&
450 (search->startup_id == inst->startup_id)) ||
451 ((inst->exe) && (search->pid > 1) &&
452 (search->pid == ecore_exe_pid_get(inst->exe))))
454 search->desktop = inst->desktop;
462 _e_exec_error_dialog(Efreet_Desktop *desktop, const char *exec, Ecore_Exe_Event_Del *event,
463 Ecore_Exe_Event_Data *error, Ecore_Exe_Event_Data *read)
465 E_Config_Dialog_View *v;
466 E_Config_Dialog_Data *cfdata;
469 v = E_NEW(E_Config_Dialog_View, 1);
471 cfdata = E_NEW(E_Config_Dialog_Data, 1);
477 cfdata->desktop = desktop;
478 if (cfdata->desktop) efreet_desktop_ref(cfdata->desktop);
479 if (exec) cfdata->exec = strdup(exec);
480 cfdata->error = error;
482 cfdata->event = *event;
484 v->create_cfdata = _create_data;
485 v->free_cfdata = _free_data;
486 v->basic.create_widgets = _basic_create_widgets;
487 v->advanced.create_widgets = _advanced_create_widgets;
489 con = e_container_current_get(e_manager_current_get());
490 /* Create The Dialog */
491 e_config_dialog_new(con, _("Application Execution Error"),
492 "E", "_e_exec_error_exit_dialog",
497 _fill_data(E_Config_Dialog_Data *cfdata)
503 snprintf(buf, sizeof(buf), _("%s stopped running unexpectedly."), cfdata->desktop->name);
504 cfdata->label = strdup(buf);
506 if ((cfdata->event.exited) && (!cfdata->exit))
508 snprintf(buf, sizeof(buf),
509 _("An exit code of %i was returned from %s."),
510 cfdata->event.exit_code, cfdata->exec);
511 cfdata->exit = strdup(buf);
513 if ((cfdata->event.signalled) && (!cfdata->signal))
515 if (cfdata->event.exit_signal == SIGINT)
516 snprintf(buf, sizeof(buf),
517 _("%s was interrupted by an Interrupt Signal."),
518 cfdata->desktop->exec);
519 else if (cfdata->event.exit_signal == SIGQUIT)
520 snprintf(buf, sizeof(buf), _("%s was interrupted by a Quit Signal."),
522 else if (cfdata->event.exit_signal == SIGABRT)
523 snprintf(buf, sizeof(buf),
524 _("%s was interrupted by an Abort Signal."), cfdata->exec);
525 else if (cfdata->event.exit_signal == SIGFPE)
526 snprintf(buf, sizeof(buf),
527 _("%s was interrupted by a Floating Point Error."),
529 else if (cfdata->event.exit_signal == SIGKILL)
530 snprintf(buf, sizeof(buf),
531 _("%s was interrupted by an Uninterruptable Kill Signal."),
533 else if (cfdata->event.exit_signal == SIGSEGV)
534 snprintf(buf, sizeof(buf),
535 _("%s was interrupted by a Segmentation Fault."),
537 else if (cfdata->event.exit_signal == SIGPIPE)
538 snprintf(buf, sizeof(buf),
539 _("%s was interrupted by a Broken Pipe."), cfdata->exec);
540 else if (cfdata->event.exit_signal == SIGTERM)
541 snprintf(buf, sizeof(buf),
542 _("%s was interrupted by a Termination Signal."),
544 else if (cfdata->event.exit_signal == SIGBUS)
545 snprintf(buf, sizeof(buf),
546 _("%s was interrupted by a Bus Error."), cfdata->exec);
548 snprintf(buf, sizeof(buf),
549 _("%s was interrupted by the signal number %i."),
550 cfdata->exec, cfdata->event.exit_signal);
551 cfdata->signal = strdup(buf);
552 /* FIXME: Add sigchld_info stuff
556 * int si_signo; Signal number
557 * int si_errno; An errno value
558 * int si_code; Signal code
559 * pid_t si_pid; Sending process ID
560 * uid_t si_uid; Real user ID of sending process
561 * int si_status; Exit value or signal
562 * clock_t si_utime; User time consumed
563 * clock_t si_stime; System time consumed
564 * sigval_t si_value; Signal value
565 * int si_int; POSIX.1b signal
566 * void * si_ptr; POSIX.1b signal
567 * void * si_addr; Memory location which caused fault
568 * int si_band; Band event
569 * int si_fd; File descriptor
576 _create_data(E_Config_Dialog *cfd)
578 E_Config_Dialog_Data *cfdata;
586 _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
588 if (cfdata->error) ecore_exe_event_data_free(cfdata->error);
589 if (cfdata->read) ecore_exe_event_data_free(cfdata->read);
591 if (cfdata->desktop) efreet_desktop_free(cfdata->desktop);
593 E_FREE(cfdata->exec);
594 E_FREE(cfdata->signal);
595 E_FREE(cfdata->exit);
596 E_FREE(cfdata->label);
601 _dialog_scrolltext_create(Evas *evas, char *title, Ecore_Exe_Event_Data_Line *lines)
603 Evas_Object *obj, *os;
605 char *trunc_note = _("***The remaining output has been truncated. Save the output to view.***\n");
606 int tlen, max_lines, i;
608 os = e_widget_framelist_add(evas, _(title), 0);
610 obj = e_widget_textblock_add(evas);
613 for (i = 0; lines[i].line; i++)
615 tlen += lines[i].size + 1;
616 /* When the program output is extraordinarily long, it can cause
617 * significant delays during text rendering. Limit to a fixed
618 * number of characters. */
619 if (tlen > MAX_OUTPUT_CHARACTERS)
621 tlen -= lines[i].size + 1;
622 tlen += strlen(trunc_note);
627 text = alloca(tlen + 1);
632 for (i = 0; i < max_lines; i++)
634 strcat(text, lines[i].line);
638 /* Append the warning about truncated output. */
639 if (lines[max_lines].line) strcat(text, trunc_note);
641 e_widget_textblock_plain_set(obj, text);
643 e_widget_size_min_set(obj, 240, 120);
645 e_widget_framelist_object_append(os, obj);
651 _basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata)
654 int error_length = 0;
655 Evas_Object *o, *ob, *os;
659 o = e_widget_list_add(evas, 0, 0);
661 ob = e_widget_label_add(evas, cfdata->label);
662 e_widget_list_object_append(o, ob, 1, 1, 0.5);
664 if (cfdata->error) error_length = cfdata->error->size;
667 os = _dialog_scrolltext_create(evas, _("Error Logs"),
668 cfdata->error->lines);
669 e_widget_list_object_append(o, os, 1, 1, 0.5);
673 ob = e_widget_label_add(evas, _("There was no error message."));
674 e_widget_list_object_append(o, ob, 1, 1, 0.5);
677 ob = e_widget_button_add(evas, _("Save This Message"), "system-run",
678 _dialog_save_cb, NULL, cfdata);
679 e_widget_list_object_append(o, ob, 0, 0, 0.5);
681 snprintf(buf, sizeof(buf), _("This error log will be saved as %s/%s.log"),
682 e_user_homedir_get(), cfdata->desktop->name);
683 ob = e_widget_label_add(evas, buf);
684 e_widget_list_object_append(o, ob, 1, 1, 0.5);
690 _advanced_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata)
694 int error_length = 0;
695 Evas_Object *o, *of, *ob, *ot;
699 o = e_widget_list_add(evas, 0, 0);
700 ot = e_widget_table_add(evas, 0);
702 ob = e_widget_label_add(evas, cfdata->label);
703 e_widget_list_object_append(o, ob, 1, 1, 0.5);
707 of = e_widget_framelist_add(evas, _("Error Information"), 0);
708 ob = e_widget_label_add(evas, _(cfdata->exit));
709 e_widget_framelist_object_append(of, ob);
710 e_widget_list_object_append(o, of, 1, 1, 0.5);
715 of = e_widget_framelist_add(evas, _("Error Signal Information"), 0);
716 ob = e_widget_label_add(evas, _(cfdata->signal));
717 e_widget_framelist_object_append(of, ob);
718 e_widget_list_object_append(o, of, 1, 1, 0.5);
721 if (cfdata->read) read_length = cfdata->read->size;
725 of = _dialog_scrolltext_create(evas, _("Output Data"),
726 cfdata->read->lines);
727 /* FIXME: Add stdout "start". */
728 /* FIXME: Add stdout "end". */
732 of = e_widget_framelist_add(evas, _("Output Data"), 0);
733 ob = e_widget_label_add(evas, _("There was no output."));
734 e_widget_framelist_object_append(of, ob);
736 e_widget_table_object_append(ot, of, 0, 0, 1, 1, 1, 1, 1, 1);
738 if (cfdata->error) error_length = cfdata->error->size;
741 of = _dialog_scrolltext_create(evas, _("Error Logs"),
742 cfdata->error->lines);
743 /* FIXME: Add stderr "start". */
744 /* FIXME: Add stderr "end". */
748 of = e_widget_framelist_add(evas, _("Error Logs"), 0);
749 ob = e_widget_label_add(evas, _("There was no error message."));
750 e_widget_framelist_object_append(of, ob);
752 e_widget_table_object_append(ot, of, 1, 0, 1, 1, 1, 1, 1, 1);
754 e_widget_list_object_append(o, ot, 1, 1, 0.5);
756 ob = e_widget_button_add(evas, _("Save This Message"), "system-run",
757 _dialog_save_cb, NULL, cfdata);
758 e_widget_list_object_append(o, ob, 0, 0, 0.5);
760 snprintf(buf, sizeof(buf), _("This error log will be saved as %s/%s.log"),
761 e_user_homedir_get(), cfdata->desktop->name);
762 ob = e_widget_label_add(evas, buf);
763 e_widget_list_object_append(o, ob, 1, 1, 0.5);
769 _dialog_save_cb(void *data __UNUSED__, void *data2)
771 E_Config_Dialog_Data *cfdata;
781 snprintf(buf, sizeof(buf), "%s/%s.log", e_user_homedir_get(),
782 e_util_filename_escape(cfdata->desktop->name));
788 snprintf(buffer, sizeof(buffer), "Error Information:\n\t%s\n\n",
790 fwrite(buffer, sizeof(char), strlen(buffer), f);
794 snprintf(buffer, sizeof(buffer), "Error Signal Information:\n\t%s\n\n",
796 fwrite(buffer, sizeof(char), strlen(buffer), f);
799 if (cfdata->read) read_length = cfdata->read->size;
804 for (i = 0; cfdata->read->lines[i].line; i++)
805 tlen += cfdata->read->lines[i].size + 2;
806 text = alloca(tlen + 1);
810 for (i = 0; cfdata->read->lines[i].line; i++)
813 strcat(text, cfdata->read->lines[i].line);
816 snprintf(buffer, sizeof(buffer), "Output Data:\n%s\n\n", text);
817 fwrite(buffer, sizeof(char), strlen(buffer), f);
822 snprintf(buffer, sizeof(buffer), "Output Data:\n\tThere was no output\n\n");
823 fwrite(buffer, sizeof(char), strlen(buffer), f);
826 /* Reusing this var */
828 if (cfdata->error) read_length = cfdata->error->size;
833 for (i = 0; cfdata->error->lines[i].line; i++)
834 tlen += cfdata->error->lines[i].size + 1;
835 text = alloca(tlen + 1);
839 for (i = 0; cfdata->error->lines[i].line; i++)
842 strcat(text, cfdata->error->lines[i].line);
845 snprintf(buffer, sizeof(buffer), "Error Logs:\n%s\n", text);
846 fwrite(buffer, sizeof(char), strlen(buffer), f);
851 snprintf(buffer, sizeof(buffer), "Error Logs:\n\tThere was no error message\n");
852 fwrite(buffer, sizeof(char), strlen(buffer), f);