Example #1
0
G_MODULE_EXPORT gboolean select_file_for_ecu_restore(GtkWidget *widget, gpointer data)
{
	MtxFileIO *fileio = NULL;
	gchar *filename = NULL;
	extern gconstpointer *global_data;

	if (!DATA_GET(global_data,"interrogated"))
		return FALSE;

	fileio = g_new0(MtxFileIO ,1);
	fileio->external_path = g_strdup("MTX_ecu_snapshots");
	fileio->parent = lookup_widget_f("main_window");
	fileio->on_top = TRUE;
	fileio->title = g_strdup("Restore your ECU Settings from which file");
	fileio->action = GTK_FILE_CHOOSER_ACTION_OPEN;
	fileio->shortcut_folders = g_strdup("ecu_snapshots,MTX_ecu_snapshots");

	filename = choose_file(fileio);
	if (filename == NULL)
	{
		update_logbar_f("tools_view","warning",_("NO FILE chosen for ECU restore\n"),FALSE,FALSE,FALSE);
		return FALSE;
	}
	update_logbar_f("tools_view",NULL,_("Full Restore of ECU Initiated\n"),FALSE,FALSE,FALSE);
	restore_all_ecu_settings(filename);
	g_free(filename);
	free_mtxfileio(fileio);
	return TRUE;

}
Example #2
0
/*callback function*/
void mainwnd::file_open_setlist()
{
    if (is_save()){
    	//todo: stop playing - when?
        choose_file(true);
        //open_setlist_player();



    }
}
Example #3
0
void	menu_connect(GtkWidget *widget, t_map *map)
{
	if (ft_strsearch("Open scene", (char*)gtk_widget_get_name(widget)) != -1)
		choose_file(widget, map);
	else if (ft_strsearch("Quitter", (char*)gtk_widget_get_name(widget)) != -1)
		exit_rt(map);
	else if (ft_strsearch("Save picture", (char*)gtk_widget_get_name(widget)) != -1)
		write_bitmap(map);
	else if (ft_strsearch("Ouvrir generateur de scene", (char*)gtk_widget_get_name(widget)) != -1)
		open_generateur_scene(map);
}
Example #4
0
G_MODULE_EXPORT gboolean select_vex_for_export(GtkWidget *widget, gpointer data)
{
	MtxFileIO *fileio = NULL;
	gchar *filename = NULL;
	GIOChannel *iochannel = NULL;
	struct tm *tm = NULL;
	time_t *t = NULL;
	Firmware_Details *firmware = NULL;

	firmware = DATA_GET(global_data,"firmware");

	if (!DATA_GET(global_data,"interrogated"))
		return FALSE;

	t = g_malloc(sizeof(time_t));
	time(t);
	tm = localtime(t);
	g_free(t);


	fileio = g_new0(MtxFileIO ,1);
	fileio->external_path = g_strdup("MTX_VexFiles");
	fileio->title = g_strdup("Save your VEX file");
	fileio->parent = lookup_widget_f("main_window");
	fileio->on_top = TRUE;
	fileio->default_filename= g_strdup("VEX_Backup.vex");
	fileio->default_filename= g_strdup_printf("%s-%.4i%.2i%.2i%.2i%.2i.vex",g_strdelimit(firmware->name," ,",'_'),tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min);
	fileio->default_extension= g_strdup("vex");
	fileio->action = GTK_FILE_CHOOSER_ACTION_SAVE;

	filename = choose_file(fileio);
	if (filename == NULL)
	{
		update_logbar_f("tools_view","warning",_("NO FILE chosen for VEX export\n"),FALSE,FALSE,FALSE);
		return FALSE;
	}

	iochannel = g_io_channel_new_file(filename, "a+",NULL);
	if (!iochannel)
	{
		update_logbar_f("tools_view","warning",_("File open FAILURE! \n"),FALSE,FALSE,FALSE);
		return FALSE;
	}
	if (vex_comment == NULL)
		update_logbar_f("tools_view",NULL,_("VEX File Opened. VEX Comment undefined, exporting without one.\n"),FALSE,FALSE,FALSE);
	else
		update_logbar_f("tools_view",NULL,_("VEX File Opened. VEX Comment already stored.\n"),FALSE,FALSE,FALSE);
	all_table_export(iochannel);
	g_io_channel_shutdown(iochannel,TRUE,NULL);
	g_io_channel_unref(iochannel);
	free_mtxfileio(fileio);
	return TRUE;
}
Example #5
0
struct ffsb_file *choose_file_writer(struct benchfiles *bf, randdata_t *rd)
{
	struct ffsb_file *ret ;

	rw_lock_read(&bf->fileslock);
	assert(bf->holes->count != bf->listsize);
	ret = choose_file(bf, rd);

	if (rw_trylock_write(&ret->lock)) {
		rw_unlock_read(&bf->fileslock);
		return choose_file_writer(bf, rd);
	}

	rw_unlock_read(&bf->fileslock);
	return ret;
}
Example #6
0
/*!
  \brief initiates an offline ECU restore from file. Prompts for file, if
  valid, it calles the restore_all function from the ECU plugin
  */
G_MODULE_EXPORT void offline_ecu_restore_pf(void)
{
	MtxFileIO *fileio = NULL;
	gchar *filename = NULL;
	void (*restore_all_f)(const gchar *);
	Firmware_Details *firmware = NULL;

	ENTER();
	firmware = (Firmware_Details *)DATA_GET(global_data,"firmware");
	get_symbol("restore_all_ecu_settings",(void **)&restore_all_f);

	g_return_if_fail(firmware);
	g_return_if_fail(restore_all_f);

	if (!DATA_GET(global_data,"interrogated"))
	{
		EXIT();
		return;
	}

	fileio = g_new0(MtxFileIO ,1);
	fileio->default_path = g_strdup(BACKUP_DATA_DIR);
	fileio->project = (const gchar *)DATA_GET(global_data,"project_name");
	fileio->parent = lookup_widget("main_window");
	fileio->on_top = TRUE;
	fileio->title = g_strdup("You should load an ECU backup from a file");
	fileio->action = GTK_FILE_CHOOSER_ACTION_OPEN;
	fileio->shortcut_folders = g_strdup(BACKUP_DATA_DIR);
	if (DATA_GET(global_data,"last_offline_filename"))
	fileio->default_filename = g_strdup((gchar *)DATA_GET(global_data,"last_offline_filename"));

	filename = choose_file(fileio);
	if (filename)
	{
		DATA_SET_FULL(global_data,"last_offline_filename",g_strdup(filename),g_free);
		update_logbar("tools_view",NULL,_("Full Restore of ECU Initiated\n"),FALSE,FALSE,FALSE);
		restore_all_f(filename);
		g_free(filename);
	}
	else
		io_cmd(firmware->get_all_command,NULL);

	free_mtxfileio(fileio);
	EXIT();
	return;
}
Example #7
0
/*! 
  \brief select_datalog_for_import() loads a datalog file for playback
  \param widget is the Calling widget
  \param data is unused
  */
G_MODULE_EXPORT gboolean select_datalog_for_import(GtkWidget *widget, gpointer data)
{
	MtxFileIO *fileio = NULL;
	gchar *filename = NULL;
	GIOChannel *iochannel = NULL;

	ENTER();
	reset_logviewer_state();
	free_log_info((Log_Info *)DATA_GET(global_data,"log_info"));

	fileio = g_new0(MtxFileIO ,1);
	fileio->default_path = g_strdup(DATALOG_DATA_DIR);
	fileio->project = (const gchar *)DATA_GET(global_data,"project_name");
	fileio->parent = lookup_widget("main_window");
	fileio->on_top = TRUE;
	fileio->title = g_strdup("Choose a datalog to view");
	fileio->action = GTK_FILE_CHOOSER_ACTION_OPEN;

	filename = choose_file(fileio);
	if (filename == NULL)
	{
		update_logbar("dlog_view","warning",_("NO FILE opened for logviewing!\n"),FALSE,FALSE,FALSE);
		EXIT();
		return FALSE;
	}

	iochannel = g_io_channel_new_file(filename, "r+",NULL);
	if (!iochannel)
	{
		update_logbar("dlog_view","warning",_("File open FAILURE! \n"),FALSE,FALSE,FALSE);
		EXIT();
		return FALSE;
	}

	update_logbar("dlog_view",NULL,_("DataLog ViewFile Opened\n"),FALSE,FALSE,FALSE);
	load_logviewer_file(iochannel);
	g_io_channel_shutdown(iochannel,FALSE,NULL);
	g_io_channel_unref(iochannel);

	update_logbar("dlog_view",NULL,_("LogView File Closed\n"),FALSE,FALSE,FALSE);
	gtk_widget_set_sensitive(lookup_widget("logviewer_controls_hbox"),TRUE);
	enable_playback_controls(TRUE);
	free_mtxfileio(fileio);
	EXIT();
	return TRUE;
}
Example #8
0
G_MODULE_EXPORT void select_table_for_import(gint table_num)
{
	MtxFileIO *fileio = NULL;
	gchar *filename = NULL;
	GIOChannel *iochannel = NULL;
	Firmware_Details *firmware = NULL;

	firmware = DATA_GET(global_data,"firmware");

	if (!DATA_GET(global_data,"interrogated"))
		return;

	if ((table_num < 0) || (table_num >= firmware->total_tables))
		return;

	fileio = g_new0(MtxFileIO ,1);
	fileio->external_path = g_strdup("MTX_VexFiles");
	fileio->parent = lookup_widget_f("main_window");
	fileio->on_top = TRUE;
	fileio->title = g_strdup("Select your VEX file to import");
	fileio->action = GTK_FILE_CHOOSER_ACTION_OPEN;

	filename = choose_file(fileio);
	if (filename == NULL)
	{
		update_logbar_f("tools_view","warning",_("NO FILE chosen for VEX import\n"),FALSE,FALSE,FALSE);
		return;
	}

	iochannel = g_io_channel_new_file(filename, "r+",NULL);
	if (!iochannel)
	{
		update_logbar_f("tools_view","warning",_("File open FAILURE! \n"),FALSE,FALSE,FALSE);
		return;
	}
	update_logbar_f("tools_view",NULL,_("VEX File Closed\n"),FALSE,FALSE,FALSE);
	gtk_entry_set_text(GTK_ENTRY(lookup_widget_f("tools_vex_comment_entry")),"");

	single_table_import(iochannel,table_num);
	g_io_channel_shutdown(iochannel,TRUE,NULL);
	g_io_channel_unref(iochannel);
	free_mtxfileio(fileio);
	return;
}
Example #9
0
G_MODULE_EXPORT gboolean select_file_for_ecu_backup(GtkWidget *widget, gpointer data)
{
	MtxFileIO *fileio = NULL;
	gchar *filename = NULL;
	struct tm *tm = NULL;
	time_t *t = NULL;
	extern gconstpointer *global_data;
	Firmware_Details *firmware = NULL;

	firmware = DATA_GET(global_data,"firmware");


	if (!DATA_GET(global_data,"interrogated"))
		return FALSE;

	t = g_malloc(sizeof(time_t));
	time(t);
	tm = localtime(t);
	g_free(t);

	fileio = g_new0(MtxFileIO ,1);
	fileio->external_path = g_strdup("MTX_ecu_snapshots");
	fileio->title = g_strdup("Save your ECU Settings to file");
	fileio->parent = lookup_widget_f("main_window");
	fileio->on_top = TRUE;
	fileio->default_filename = g_strdup_printf("%s-%.4i_%.2i_%.2i-%.2i%.2i.ecu",g_strdelimit(firmware->name," ,",'_'),tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min);
	fileio->default_extension = g_strdup("ecu");
	fileio->action = GTK_FILE_CHOOSER_ACTION_SAVE;
	fileio->shortcut_folders = g_strdup("MTX_ecu_snapshots");

	filename = choose_file(fileio);
	if (filename == NULL)
	{
		update_logbar_f("tools_view","warning",_("NO FILE chosen for ECU Backup\n"),FALSE,FALSE,FALSE);
		return FALSE;
	}
	update_logbar_f("tools_view",NULL,_("Full Backup of ECU Initiated\n"),FALSE,FALSE,FALSE);
	backup_all_ecu_settings(filename);
	update_logbar_f("tools_view",NULL,_("Full Backup File Closed\n"),FALSE,FALSE,FALSE);
	g_free(filename);
	free_mtxfileio(fileio);
	return TRUE;
}
Example #10
0
struct ffsb_file *choose_file_reader(struct benchfiles *bf, randdata_t *rd)
{
	struct ffsb_file *ret;

	rw_lock_read(&bf->fileslock);
	/* If b->holes->count == bf->listsize, all files have been
	 * deleted!
	 */
	assert(bf->holes->count != bf->listsize);

	ret = choose_file(bf, rd);
	if (rw_trylock_read(&ret->lock)) {
		rw_unlock_read(&bf->fileslock);
		return choose_file_reader(bf, rd);
	}

	rw_unlock_read(&bf->fileslock);
	return ret;
}
Example #11
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    _filename(DEFAULT_FILENAME),
    _file(DEFAULT_FILENAME)
{
    ui->setupUi(this);
    ui->txt_file_chooser->lineEdit().setReadOnly(true);

    ui->btnWriteBytes->setEnabled(false);

    update_count = 0;

    update_file();

    fsw = new QFileSystemWatcher(QStringList(_filename));
    connect(fsw, SIGNAL(fileChanged(QString)), this, SLOT(caught_file_updated()));

    connect(&ui->txt_file_chooser->pushButton(), SIGNAL(clicked()),
            this, SLOT(choose_file()));
}
Example #12
0
int
main(int argc, char **argv)
{
	char path[PATH_MAX] = {'\0'};
	const char *file = path;
	int fd;
	char *buffer;
	unsigned start, i;
	unsigned count;
	struct stat stat;

	srand(system_time() % INT_MAX);

	if (argc > 1) {
		// if there are arguments, choose one randomly
		file = argv[1 + (rand() % (argc - 1))];
	} else if (find_directory(B_SYSTEM_DATA_DIRECTORY, -1, false, path,
			sizeof(path)) == B_OK) {
		strlcat(path, "/fortunes", sizeof(path));
	}

	fd = open(file, O_RDONLY, 0);
	if (fd < 0) {
		fprintf(stderr, "Couldn't open %s: %s\n", file, strerror(errno));
		return 1;
	}

	if (fstat(fd, &stat) < 0) {
		fprintf(stderr, "stat() failed: %s\n", strerror(errno));
		return 1;
	}

	if (S_ISDIR(stat.st_mode)) {
		close(fd);

		fd = choose_file(file);
		if (fd < 0) {
			fprintf(stderr, "Could not find any fortune file.\n");
			return 1;
		}

		if (fstat(fd, &stat) < 0) {
			fprintf(stderr, "stat() failed: %s\n", strerror(errno));
			return 1;
		}
	}

	buffer = malloc(stat.st_size + 1);
	if (buffer == NULL) {
		fprintf(stderr, "Not enough memory.\n");
		return 1;
	}

	if (read(fd, buffer, stat.st_size) < 0) {
		fprintf(stderr, "Could not read from fortune file: %s\n",
			strerror(errno));
		return -1;
	}

	buffer[stat.st_size] = '\0';
	close(fd);

	// count fortunes

	count = 0;
	for (i = 0; i < stat.st_size - 2; i++) {
		if (!strncmp(buffer + i, "\n%\n", 3)) {
			count++;
			i += 3;
		}
	}

	if (!count) {
		printf("Out of cookies...\n");
		return 0;
	}

	count = rand() % count;
	start = 0;

	// find beginning & end
	for (i = 0; i < stat.st_size - 2; i++) {
		if (!strncmp(buffer + i, "\n%\n", 3)) {
			if (count-- <= 0) {
				buffer[i] = '\0';
				break;
			}

			i += 3;
			start = i;
		}
	}

	puts(buffer + start);
	return 0;
}
Example #13
0
void PPTKBARBash::on_namelist_choose_clicked()
{
    m_namelist_edit->setText(choose_file(tr("Choose namelist file"),
        QFileInfo(m_namelist_edit->text() + "/").absolutePath()));
}
Example #14
0
void PPTKBARBash::on_bar_path_choose_clicked()
{
    m_bar_path_edit->setText(choose_file(tr("Choose BAR binary")));
    m_previewed = false;
}
Example #15
0
INT_PTR CALLBACK prg2wav_dialog_proc(HWND hwndDlg,      //handle to dialog box
                                     UINT uMsg, //message
                                     WPARAM wParam,     //first message parameter
                                     LPARAM lParam      // second message parameter
  ){
  switch (uMsg) {
  case WM_INITDIALOG:
    CheckRadioButton(hwndDlg, IDC_FAST, IDC_SLOW, IDC_FAST);
    CheckRadioButton(hwndDlg, IDC_TO_TAP, IDC_TO_SOUND, IDC_TO_TAP);
    if (audiotap_startup_status.audiofile_init_status != LIBRARY_OK
     || audiotap_startup_status.tapdecoder_init_status != LIBRARY_OK)
      EnableWindow(GetDlgItem(hwndDlg, IDC_TO_WAV), FALSE);
    if (audiotap_startup_status.portaudio_init_status != LIBRARY_OK
     || audiotap_startup_status.tapdecoder_init_status != LIBRARY_OK)
      EnableWindow(GetDlgItem(hwndDlg, IDC_TO_SOUND), FALSE);
    SetDlgItemInt(hwndDlg, IDC_FREQ, 44100, FALSE);
    SetDlgItemInt(hwndDlg, IDC_VOL, 254, FALSE);
    SendMessageA(GetDlgItem(hwndDlg, IDC_MACHINE_TO), CB_ADDSTRING, 0,
      (LPARAM) "C64 PAL");
    SendMessageA(GetDlgItem(hwndDlg, IDC_MACHINE_TO), CB_ADDSTRING, 0,
      (LPARAM) "C64 NTSC");
    SendMessageA(GetDlgItem(hwndDlg, IDC_MACHINE_TO), CB_ADDSTRING, 0,
      (LPARAM) "VIC20 PAL");
    SendMessageA(GetDlgItem(hwndDlg, IDC_MACHINE_TO), CB_ADDSTRING, 0,
      (LPARAM) "VIC20 NTSC");
    SendMessageA(GetDlgItem(hwndDlg, IDC_MACHINE_TO), CB_ADDSTRING, 0,
      (LPARAM) "C16 PAL");
    SendMessageA(GetDlgItem(hwndDlg, IDC_MACHINE_TO), CB_ADDSTRING, 0,
      (LPARAM) "C16 NTSC");
    SendMessage(GetDlgItem(hwndDlg, IDC_MACHINE_TO), CB_SETCURSEL, 0, 0);
    SendMessageA(GetDlgItem(hwndDlg, IDC_WAVEFORM), CB_ADDSTRING, 0,
      (LPARAM) "Triangle");
    SendMessageA(GetDlgItem(hwndDlg, IDC_WAVEFORM), CB_ADDSTRING, 0,
      (LPARAM) "Square");
    SendMessageA(GetDlgItem(hwndDlg, IDC_WAVEFORM), CB_ADDSTRING, 0,
      (LPARAM) "Sine");
    SendMessageA(GetDlgItem(hwndDlg, IDC_WAVEFORM), CB_SETCURSEL, 1, 0);
    SendMessageA(GetDlgItem(hwndDlg, IDC_THRESHOLD_SPIN), UDM_SETRANGE, 
      0, MAKELONG(1600, 102));
    SendMessage(GetDlgItem(hwndDlg, IDC_THRESHOLD_SPIN), UDM_SETPOS, 
      0, 263);
    return TRUE;
  case WM_COMMAND:
    switch (LOWORD(wParam)) {
    case IDC_FAST:
      EnableWindow(GetDlgItem(hwndDlg, IDC_THRESHOLD), TRUE);
      return TRUE;
    case IDC_SLOW:
      EnableWindow(GetDlgItem(hwndDlg, IDC_THRESHOLD), FALSE);
      return TRUE;
    case IDC_TO_TAP:
      EnableWindow(GetDlgItem(hwndDlg, IDC_INVERTED), FALSE);
      EnableWindow(GetDlgItem(hwndDlg, IDC_FREQ), FALSE);
      EnableWindow(GetDlgItem(hwndDlg, IDC_VOL), FALSE);
      EnableWindow(GetDlgItem(hwndDlg, IDC_WAVEFORM), FALSE);
      return TRUE;
    case IDC_TO_WAV:
    case IDC_TO_SOUND:
      EnableWindow(GetDlgItem(hwndDlg, IDC_INVERTED), TRUE);
      EnableWindow(GetDlgItem(hwndDlg, IDC_FREQ), TRUE);
      EnableWindow(GetDlgItem(hwndDlg, IDC_VOL), TRUE);
      EnableWindow(GetDlgItem(hwndDlg, IDC_WAVEFORM), TRUE);
      return TRUE;
    case IDOK:
      choose_file(hwndDlg);
      return TRUE;
    case IDCANCEL:
      EndDialog(hwndDlg, 0);
      return TRUE;
    default:
      return FALSE;
    }
  case WM_DROPFILES:
    {
      UINT numfiles = DragQueryFileA((HDROP)wParam, 0xFFFFFFFF, NULL, 0);
      UINT i;
      struct prg2wav_params params;
      struct simple_block_list_element **current_block = &params.program;

      params.program = NULL;

      for (i = 0; i < numfiles; i++)
      {
        UINT filenamesize = DragQueryFile((HDROP)wParam, i, NULL, 0);
        LPSTR filename;
        FILE* fd;
        filenamesize++; /* for the null termination */
        filename = (LPSTR)malloc(filenamesize);
        DragQueryFileA((HDROP)wParam, i, filename, filenamesize);
        if ((fd = fopen(filename, "rb")) != NULL){
          struct simple_block_list_element **new_current_block = add_all_entries_from_file(current_block, fd);
          if (detect_type(fd) == prg)
            put_filename_in_entryname(filename, (*current_block)->block.info.name);
          fclose(fd);
          current_block = new_current_block;
        }
        free(filename);
      }
      DragFinish((HDROP)wParam);
      if (params.program != NULL)
        choose_destination_file_and_convert(hwndDlg, &params);
    }
    return TRUE;
#ifdef HAVE_HTMLHELP
  case WM_HELP:
    HtmlHelpA(hwndDlg, "docs\\wavprg.chm::/prg2wav_main.htm",
              HH_DISPLAY_TOPIC, 0);
    return TRUE;
#endif
  default:
    return FALSE;
  }
}
Example #16
0
/*callback function*/
void mainwnd::file_open()
{
    if (is_save())
        choose_file(false);
}
Example #17
0
File: tcp.c Project: llostris/mikro
void tcp_actions(union ethframe* frame, struct tcp_header* hdr) {

	printf("\n****** TCP ACTIONS *******\n");
	srand(time(NULL));
	switch ( hdr->flags ) {
		case 2 : {
			printf("\n---- SENDING TCP SYN-ACK ----\n");
			/* We got a TCP packet with a SYN flag: reply with SYN-ACK */
			struct tcp_header response_tcp;
		//	printf("%u %u\n", hdr->sequence_number, (hdr->sequence_number + 1));
			create_tcp_hdr(&response_tcp, hdr->source_port, TCP_FLAG_SYN + TCP_FLAG_ACK, hdr->sequence_number + 1, rand() * 24000, hdr->window_size, hdr->data_offset);	

			// sequence_number is a random number TO BE REMEMBERED

			reply_tcp(frame, &response_tcp);
			struct ip6_hdr* iphdr;
			iphdr = (struct ip6_hdr*) frame->field.data;
			hdr = (struct tcp_header*) (frame->field.data + IPV6_HDR_LEN);
		//	printf("\nChecksum before sending: %x", hdr->checksum);
			send_frame(frame, ETH_HDR_LEN + IPV6_HDR_LEN + ntohs(iphdr->payload_len));
			break;
		}

		case 24 : {
			/* We got a HTTP GET REQUEST */			

			unsigned char* request;
			request = (unsigned char*) (frame->field.data + IPV6_HDR_LEN + TCP_HDR_LEN);
			if ( is_httpget(request) == -1 )
				break;	/* This is not our HTTP GET */
			printf("\n------ HTTP GET ------\n");

//			printf("%s\n", request);

			unsigned char* file = malloc(300);
			unsigned char* response = malloc(400);
			memset(file, 0, 300);
			memset(response, 0, 400);
//			parse_file(file);
			choose_file(request, file);
			sprintf(response, "HTTP/1.1 200 OK\r\nContent-Length: %d\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n%s", strlen(file), file);
			//printf("RESP: \n%s\n", response);

			struct tcp_header response_tcp;
			create_tcp_hdr(&response_tcp, hdr->source_port, TCP_FLAG_PSH + TCP_FLAG_ACK, hdr->sequence_number + 1, hdr->acknowledgement_number, hdr->window_size, hdr->data_offset);
			
			struct ip6_hdr* iphdr;
			iphdr = (struct ip6_hdr*) frame->field.data;
			iphdr->payload_len = htons(TCP_HDR_LEN + strlen(response));

			add_http(frame, response, strlen(response));
			reply_tcp(frame, &response_tcp);	

			send_frame(frame, ETH_HDR_LEN + IPV6_HDR_LEN + ntohs(iphdr->payload_len));
			
			//finalize(frame);
			
			free(file);
			free(response);
			break;
		}

		case TCP_FLAG_FIN : {
			struct ip6_hdr* iphdr;
			iphdr = (struct ip6_hdr*) frame->field.data;
			iphdr->payload_len = iphdr->payload_len;

			struct tcp_header* hdr;
			hdr = (struct tcp_header*) (frame->field.data + IPV6_HDR_LEN);
			create_tcp_hdr(hdr, hdr->source_port, TCP_FLAG_FIN + TCP_FLAG_ACK, hdr->sequence_number + 1, hdr->acknowledgement_number, hdr->window_size, hdr->data_offset);

		//	oldtcp->checksum = checksum_pseudo(oldtcp, iphdr->source_address, iphdr->destination_address, NEXT_HDR_TCP, TCP_HDR_LEN);
			reply_tcp(frame, hdr);	

			send_frame(frame, ETH_HDR_LEN + IPV6_HDR_LEN + ntohs(iphdr->payload_len));
		}
		
		default : break;
	}
};