예제 #1
0
FLAC__bool flac__vorbiscomment_add(FLAC__StreamMetadata *block, const char *comment, FLAC__bool value_from_file, FLAC__bool raw, const char **violation)
{
	Argument_VcField parsed;
	FLAC__bool dummy;

	FLAC__ASSERT(0 != block);
	FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
	FLAC__ASSERT(0 != comment);

	memset(&parsed, 0, sizeof(parsed));

	parsed.field_value_from_file = value_from_file;
	if(!parse_vorbis_comment_field(comment, &(parsed.field), &(parsed.field_name), &(parsed.field_value), &(parsed.field_value_length), violation)) {
		free_field(&parsed);
		return false;
	}

	if(!set_vc_field(block, &parsed, &dummy, raw, violation)) {
		free_field(&parsed);
		return false;
	}
	else {
		free_field(&parsed);
		return true;
	}
}
static void on_close(void)
{
	unpost_form(form);
	free_form(form);
	free_field(fields[0]);
	free_field(fields[1]);
	widget_free(&form_widget);
}
예제 #3
0
파일: client.c 프로젝트: Sindarus/snake
void free_all_client(field* map, snake** snakes, int size){
    free_field(map);
    int i;
    for(i = 0; i<size; i++){
        free_snake(snakes[i]);
    }
}
예제 #4
0
파일: conf.cpp 프로젝트: Oppen/einstein
int table_remove_field(HTable table, char *field)
{
    SField *f, *pf;

    if ((! table) || (! field))
        return -1;

    f = find_field(table, field);
    if (f)
    {
        if (table->fields == f)
            table->fields = f->next;
        else
        {
            pf = table->fields;
            while (pf && (pf->next != f))
                pf = pf->next;
            if (pf)
                pf->next = f->next;
        }
        free_field(f);
    }

    return 0;
}
예제 #5
0
/*
 * Delete the popup allocated memory.
 * This *won't* free popup_btn_action.
 */
void popup_delete(void)
{
	int i;

	if (popup_form) {
		unpost_form(popup_form);

		for (i = 0; popup_fields[i] != NULL; i++) {
			free(field_buffer(popup_fields[i], 0));
			free_field(popup_fields[i]);
		}

		free_form(popup_form);
		free(popup_fields);
	}

	unpost_menu(popup_menu);
	free_menu(popup_menu);

	for (i = 0; popup_items[i] != NULL; i++)
		free_item(popup_items[i]);

	free(popup_items);
	delwin(win_form);
	delwin(win_menu);
	delwin(win_body);
	win_body = NULL;
	popup_btn_action = NULL;
	popup_menu = NULL;
}
예제 #6
0
파일: term.c 프로젝트: lchsk/xstarter
void
free_term_gui(void)
{
    if (menu_list) {
        unpost_menu(menu_list);
        free_menu(menu_list);
    }

    if (list_items) {
        for (int i = 0; i < choices_cnt; i++) {
            free_item(list_items[i]);
        }

        free(list_items);
    }

    unpost_form(form);

    if (form)
        free_form(form);

    free_field(field[0]);

    endwin();
}
예제 #7
0
void
call_list_destroy(PANEL *panel)
{
    call_list_info_t *info;

    // Free its status data
    if ((info = call_list_info(panel))) {
        // Deallocate forms data
        if (info->form) {
            unpost_form(info->form);
            free_form(info->form);
            free_field(info->fields[FLD_LIST_FILTER]);
        }

        // Deallocate group data
        call_group_destroy(info->group);

        // Deallocate panel windows
        delwin(info->list_win);
        sng_free(info);
    }

    // Deallocate panel window
    delwin(panel_window(panel));
    // Deallocate panel pointer
    del_panel(panel);
}
예제 #8
0
파일: ui_save.c 프로젝트: cruzccl/sngrep
void
save_destroy(ui_t *ui)
{
    save_info_t *info;
    int i;

    // Get panel information
    if ((info = save_info(ui))) {
        // Remove panel form and fields
        unpost_form(info->form);
        free_form(info->form);
        for (i = 0; i < FLD_SAVE_COUNT; i++)
            free_field(info->fields[i]);

        // Remove panel window and custom info
        sng_free(info);
    }

    // Delete panel
    ui_panel_destroy(ui);

    // Resume capture
    capture_set_paused(0);

    // Disable cursor position
    curs_set(0);
}
예제 #9
0
void viper_form_destroy(FORM *form,gboolean free_windows)
{
	WINDOW	*parent;
	WINDOW	*window;
	WINDOW	*subwin;
	FIELD		**fields;
	gint		count;

	unpost_form(form);
	
	window=form_win(form);
	subwin=form_sub(form);
	parent=window->_parent;
		
	count=field_count(form);
	fields=form_fields(form);
	free_form(form);
	
	while(count>0)
	{
		free_field(fields[count-1]);
		count--;
	}
	g_free(fields);

   if(free_windows==FALSE) return;
	
	/*	delete subwin if it is completely independent.	*/
	if(subwin!=parent && subwin!=window && subwin!=NULL) delwin(subwin);
		
	/*	delete window if it is not the parent window.	*/
	if(parent!=NULL && window!=parent && window!=NULL) delwin(window);
			
	return;
}
예제 #10
0
/* 
 * called to destroy the menu
 */
static int wdg_input_destroy(struct wdg_object *wo)
{
   WDG_WO_EXT(struct wdg_input_handle, ww);
   size_t i = 0;
   
   WDG_DEBUG_MSG("wdg_input_destroy");

   /* erase the window */
   wbkgd(ww->win, COLOR_PAIR(wo->screen_color));
   werase(ww->win);
   wnoutrefresh(ww->win);

   /* destroy the internal form */
   wdg_input_form_destroy(wo);
   
   /* dealloc the structures */
   delwin(ww->win);
   
   /* free all the items */
   while(ww->fields[i] != NULL) 
      free_field(ww->fields[i++]);

   /* free the array */
   WDG_SAFE_FREE(ww->fields);

   /* free the buffer array */
   WDG_SAFE_FREE(ww->buffers);
   
   WDG_SAFE_FREE(wo->extend);

   return WDG_E_SUCCESS;
}
예제 #11
0
/*
 *  Adds a row to the list, keeping the null row and '...' row in the correct positions.
 *  Must copy data to new array due to limitations in the forms library.
 */
void ListBox::addRow(const std::string& str) {
    FIELD **pNewFields = new FIELD*[m_numRows + (m_editable ? 2 : 1)];
    
    //Copy existing fields, up to the second last ('...') row
    for (int i = 0; i < m_numRows - 1; i++) {
        pNewFields[i] = m_pFields[i];
    }
    
    //Create '...' row
    if (m_editable) {
        //Create new field at third-to-last index (before '...' row)
        createField(&pNewFields[m_numRows - 1], m_numRows - 1, str);
        
        createField(&pNewFields[m_numRows], m_numRows, "...");
        set_field_userptr(pNewFields[m_numRows], (void*)true);
    } else {
        createField(&pNewFields[m_numRows], m_numRows, str);
    }
    
    //Create null field
    pNewFields[m_editable ? m_numRows + 1 : m_numRows] = 0;
    
    for (int i = 0; i < m_numRows; i++) {
        if (m_pFields[i] != 0) {
            free_field(m_pFields[i]);
        }
    }
    
    m_numRows++;
    
    m_pFields = pNewFields;
    
    createForm();
}
예제 #12
0
static VALUE rbncurs_c_free_field(VALUE rb_field) {
  VALUE fields_hash   = rb_iv_get(mForm, "@fields_hash");
  FIELD* field       = get_field(rb_field);
  VALUE field_adress  = INT2NUM((long)(field));
  rb_funcall(fields_hash, rb_intern("delete"), 1, field_adress);
  rb_iv_set(rb_field, "@destroyed", Qtrue);
  return INT2NUM(free_field(field));
}
예제 #13
0
InputForm::~InputForm()
{ 
  unpost_form(form);
  free_form(form);
  for (int i = 0;i < choices;i++)
  {
    free_field(field[i]);
  } 
}
예제 #14
0
ListBox::~ListBox() {
    unpost_form(m_pForm);
    free_form(m_pForm);
    for (int i = 0; i < m_numRows; i++) {
        if (m_pFields[i] != 0) {
            free_field(m_pFields[i]);
        }
    }
}
예제 #15
0
파일: fld_def.c 프로젝트: aosm/old_ncurses
new_field
(int rows, int cols, int frow, int fcol, int nrow, int nbuf)
{
  FIELD *New_Field = (FIELD *)0;
  int err = E_BAD_ARGUMENT;

  if (rows>0  && 
      cols>0  && 
      frow>=0 && 
      fcol>=0 && 
      nrow>=0 && 
      nbuf>=0 &&
      ((err = E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */
      (New_Field=(FIELD *)malloc(sizeof(FIELD))) )
    {
      *New_Field       = default_field;
      New_Field->rows  = rows;
      New_Field->cols  = cols;
      New_Field->drows = rows + nrow;
      New_Field->dcols = cols;
      New_Field->frow  = frow;
      New_Field->fcol  = fcol;
      New_Field->nrow  = nrow;
      New_Field->nbuf  = nbuf;
      New_Field->link  = New_Field;

      if (_nc_Copy_Type(New_Field,&default_field))
	{
	  size_t len;

	  len = Total_Buffer_Size(New_Field);
	  if ((New_Field->buf = (char *)malloc(len)))
	    {
	      /* Prefill buffers with blanks and insert terminating zeroes
		 between buffers */
	      int i;

	      memset(New_Field->buf,' ',len);
	      for(i=0;i<=New_Field->nbuf;i++)
		{
		  New_Field->buf[(New_Field->drows*New_Field->cols+1)*(i+1)-1]
		    = '\0';
		}
	      return New_Field;
	    }
	}
    }

  if (New_Field) 
    free_field(New_Field);
  
  SET_ERROR( err );
  return (FIELD *)0;
}
예제 #16
0
파일: ui.c 프로젝트: iamjamestl/school
void delete_input_form() {
	unpost_form(url_form);

	if (url_form) {
		free_form(url_form);
		url_form = NULL;
	}

	if (url_field[0]) {
		free_field(url_field[0]);
		url_field[0] = NULL;
	}
}
예제 #17
0
파일: ui.c 프로젝트: jhawcroft/brain
void brsh_teardown(void)
{
    if (frm_input)
    {
        unpost_form(frm_input);
        free_form(frm_input);
    }
    if (fld_input) free_field(fld_input);
    frm_input = NULL;
    fld_input = NULL;
    
    endwin();
}
예제 #18
0
파일: fld_dup.c 프로젝트: 2asoft/freebsd
dup_field(FIELD *field, int frow, int fcol)
{
  FIELD *New_Field = (FIELD *)0;
  int err = E_BAD_ARGUMENT;

  T((T_CALLED("dup_field(%p,%d,%d)"), (void *)field, frow, fcol));
  if (field && (frow >= 0) && (fcol >= 0) &&
      ((err = E_SYSTEM_ERROR) != 0) &&	/* trick : this resets the default error */
      (New_Field = typeMalloc(FIELD, 1)))
    {
      T((T_CREATE("field %p"), (void *)New_Field));
      *New_Field = *_nc_Default_Field;
      New_Field->frow = (short) frow;
      New_Field->fcol = (short) fcol;
      New_Field->link = New_Field;
      New_Field->rows = field->rows;
      New_Field->cols = field->cols;
      New_Field->nrow = field->nrow;
      New_Field->drows = field->drows;
      New_Field->dcols = field->dcols;
      New_Field->maxgrow = field->maxgrow;
      New_Field->nbuf = field->nbuf;
      New_Field->just = field->just;
      New_Field->fore = field->fore;
      New_Field->back = field->back;
      New_Field->pad = field->pad;
      New_Field->opts = field->opts;
      New_Field->usrptr = field->usrptr;

      if (_nc_Copy_Type(New_Field, field))
	{
	  size_t i, len;

	  len = Total_Buffer_Size(New_Field);
	  if ((New_Field->buf = (FIELD_CELL *)malloc(len)))
	    {
	      for (i = 0; i < len; ++i)
		New_Field->buf[i] = field->buf[i];
	      returnField(New_Field);
	    }
	}
    }

  if (New_Field)
    free_field(New_Field);

  SET_ERROR(err);
  returnField((FIELD *)0);
}
예제 #19
0
DialogForm::~DialogForm() {
    unpost_form(m_pForm);
//    free_form(m_pForm); TODO: Fix segfault
    for (int i = 0; i < m_numFields; i++) {
        if (m_pFields[i] != 0) {
            void *usrPtr = field_userptr(m_pFields[i]);
            if (usrPtr != 0) {
                delete (FieldType*)usrPtr; //TODO: Fix potentially unsafe conversion
            }
            free_field(m_pFields[i]);
        }
    }
    curs_set(0);
    refresh();
}
예제 #20
0
void quit(void)
{
  int i; 

  unpost_form(fo);
  free_form(fo);

  for(i=0; i<=3; i++)
  {
    free_field(fi[i]);
  }

  free(fi);
  endwin();
}
예제 #21
0
파일: conf.cpp 프로젝트: Oppen/einstein
void table_free(HTable table)
{
    SField *f, *nf;

    if (! table) return;

    f = table->fields;
    while (f)
    {
        nf = f->next;
        free_field(f);
        f = nf;
    }
    if (table->stat_buf)
        free(table->stat_buf);
    free(table);
}
예제 #22
0
/*---------------------------------------------------------------------------
|   Facility      :  libnform  
|   Function      :  FIELD *dup_field(FIELD *field, int frow, int fcol)
|   
|   Description   :  Duplicates the field at the specified position. All
|                    field attributes and the buffers are copied.
|                    If an error occurs, errno is set to
|                    
|                    E_BAD_ARGUMENT - invalid argument
|                    E_SYSTEM_ERROR - system error
|
|   Return Values :  Pointer to the new field or NULL if failure
+--------------------------------------------------------------------------*/
FIELD *dup_field(FIELD * field, int frow, int fcol)
{
  FIELD *New_Field = (FIELD *)0;
  int err = E_BAD_ARGUMENT;

  if (field && (frow>=0) && (fcol>=0) && 
      ((err=E_SYSTEM_ERROR) != 0) && /* trick : this resets the default error */
      (New_Field=(FIELD *)malloc(sizeof(FIELD))) )
    {
      *New_Field         = *_nc_Default_Field;
      New_Field->frow    = frow;
      New_Field->fcol    = fcol;
      New_Field->link    = New_Field;
      New_Field->rows    = field->rows;
      New_Field->cols    = field->cols;
      New_Field->nrow    = field->nrow;
      New_Field->drows   = field->drows;
      New_Field->dcols   = field->dcols;
      New_Field->maxgrow = field->maxgrow;
      New_Field->nbuf    = field->nbuf;
      New_Field->just    = field->just;
      New_Field->fore    = field->fore;
      New_Field->back    = field->back;
      New_Field->pad     = field->pad;
      New_Field->opts    = field->opts;
      New_Field->usrptr  = field->usrptr;

      if (_nc_Copy_Type(New_Field,field))
	{
	  size_t len;

	  len = Total_Buffer_Size(New_Field);
	  if ( (New_Field->buf=(char *)malloc(len)) )
	    {
	      memcpy(New_Field->buf,field->buf,len);
	      return New_Field;
	    }
	}
    }

  if (New_Field) 
    free_field(New_Field);

  SET_ERROR(err);
  return (FIELD *)0;
}
예제 #23
0
파일: form.c 프로젝트: smsajid/scdk
int main()
{	FIELD *f1[2];
	FORM  *frm1;
	chtype ch;
	int error;
	HOOK fptr=getbuf;
	
	initscr();
	f1[0]=new_field(24,80,0,0,1,1);
	assert(f1[0]!=NULL);
	f1[1]=NULL;
	frm1=new_form(f1);
	assert(frm1!=NULL);
	set_field_fore(f1[0],A_REVERSE);
	field_opts_off(f1[0],O_STATIC);
	//set_field_buffer(f1[0],0,"Sajid");
	set_field_type(f1[0],TYPE_ALPHA,80);
	set_field_term(f1[0],fptr);
	
	post_form(frm1);
	wrefresh(stdscr);
	keypad(stdscr,TRUE);
	
	while((ch=getch())!=KEY_F(3))
	{	switch(ch)
		{	case KEY_LEFT:
				error=form_driver(frm1,REQ_PREV_CHAR);
				if(error==E_REQUEST_DENIED)
					form_driver(frm1,REQ_SCR_BCHAR);
				break;
			case KEY_RIGHT:
				form_driver(frm1,REQ_NEXT_CHAR);
				break;
			default:
				form_driver(frm1,ch);
				break;
		}
	}
	unpost_form(frm1);
	free_form(frm1);
	free_field(f1[0]);
	getch();
	printw(ptr);
	endwin();
}
예제 #24
0
파일: live-udp.c 프로젝트: dima74/akos
void run_worker(int port)
{
	create_socket(port);
	int id = port - START_PORT;
	
	struct worker_info info;
	if (debug) printf("%d recvinfo\n", id);
	recvinfo(&info);
	if (debug) printf("%d recvinfo done\n", id);
	int parth = info.i1 - info.i0;
	int partw = info.w;
	info.field = malloc_field(parth + 2, partw);
	if (debug) printf("%d recvfield\n", id);
	myrecvfrom_field(PART_OF_INITIAL_FIELD, info.field, parth + 2, partw, 0, NULL, NULL, NULL, NULL);
	if (debug) printf("%d recvfield done\n", id);
	
	//print_field(info.field, parth + 2, partw);
	//print_field_named(info.id, "field0", info.field, parth + 2, partw);
	
	mysendto_ack(-1, ACK_FOR_INITIAL_DATA);
	
	worker(&info);
	
	while (1)
	{
		if (debug) printf("%d sendfield\n", id);
		mysendto_field(-1, NULL, 0, PART_OF_RESULTING_FIELD, info.field + 1, parth, partw, info.i0);
		if (debug) printf("%d sendfield done, waiting for ack...\n", id);
		
		uint8_t data[MAX_PACKET_SIZE];
		int len;
		int id = myrecvfrom_withtimeout(data, &len, DEFAULT_TIMEOUT);
		if ((id == -1 && check_for_initial_ack(*data)) || (id >= 0 && *data == PART_OF_LINE))
			continue;
		if (id == -1)
			break;
		assert(id == -2);
	}
	
	free_field(info.field, parth + 2, partw);
	close(sockfd);
	if (debug) printf("%d EXIT\n", id);
}
예제 #25
0
파일: fld_link.c 프로젝트: CSU-GH/okl4_3.0
link_field(FIELD *field, int frow, int fcol)
{
  FIELD *New_Field = (FIELD *)0;
  int err = E_BAD_ARGUMENT;

  T((T_CALLED("link_field(%p,%d,%d)"), field, frow, fcol));
  if (field && (frow >= 0) && (fcol >= 0) &&
      ((err = E_SYSTEM_ERROR) != 0) &&	/* trick: this resets the default error */
      (New_Field = (FIELD *)malloc(sizeof(FIELD))))
    {
      *New_Field = *_nc_Default_Field;
      New_Field->frow = frow;
      New_Field->fcol = fcol;

      New_Field->link = field->link;
      field->link = New_Field;

      New_Field->buf = field->buf;
      New_Field->rows = field->rows;
      New_Field->cols = field->cols;
      New_Field->nrow = field->nrow;
      New_Field->nbuf = field->nbuf;
      New_Field->drows = field->drows;
      New_Field->dcols = field->dcols;
      New_Field->maxgrow = field->maxgrow;
      New_Field->just = field->just;
      New_Field->fore = field->fore;
      New_Field->back = field->back;
      New_Field->pad = field->pad;
      New_Field->opts = field->opts;
      New_Field->usrptr = field->usrptr;

      if (_nc_Copy_Type(New_Field, field))
	returnField(New_Field);
    }

  if (New_Field)
    free_field(New_Field);

  SET_ERROR(err);
  returnField((FIELD *)0);
}
예제 #26
0
파일: bw_sec.c 프로젝트: James-TR/vuurmuur
static int
trafvol_section_destroy(void)
{
    size_t  i = 0;

    // Un post form and free the memory
    unpost_form(TrafVolSection.form);
    free_form(TrafVolSection.form);

    for(i = 0; i < TrafVolSection.n_fields; i++)
    {
        free_field(TrafVolSection.fields[i]);
    }
    free(TrafVolSection.fields);

    del_panel(TrafVolSection.panel[0]);
    destroy_win(TrafVolSection.win);

    return(0);
}
예제 #27
0
void free_pspec(pspec_info *pspec){
  SID_log("Freeing power spectrum...",SID_LOG_OPEN);
  free_cosmo(&(pspec->cosmo));
  free_field(&(pspec->FFT));
  SID_free(SID_FARG (pspec->k_1D));
  SID_free(SID_FARG (pspec->n_modes_1D));
  SID_free(SID_FARG (pspec->n_modes_2D));
  int i_run;
  for(i_run=0;i_run<4;i_run++){
      SID_free(SID_FARG (pspec->P_k_1D[i_run]));
      SID_free(SID_FARG (pspec->dP_k_1D[i_run]));
      SID_free(SID_FARG (pspec->P_k_2D[i_run]));
      SID_free(SID_FARG (pspec->dP_k_2D[i_run]));
  }
  SID_free(SID_FARG pspec->P_k_1D);
  SID_free(SID_FARG pspec->dP_k_1D);
  SID_free(SID_FARG pspec->P_k_2D);
  SID_free(SID_FARG pspec->dP_k_2D);
  SID_log("Done.",SID_LOG_CLOSE);
}
예제 #28
0
void
column_select_destroy(ui_t *ui)
{
    int i;
    column_select_info_t *info = column_select_info(ui);

    // Remove menu and items
    unpost_menu(info->menu);
    free_menu(info->menu);
    for (i = 0; i < SIP_ATTR_COUNT; i++)
        free_item(info->items[i]);

    // Remove form and fields
    unpost_form(info->form);
    free_form(info->form);
    for (i = 0; i < FLD_COLUMNS_COUNT; i++)
        free_field(info->fields[i]);

    sng_free(info);

    // Remove panel window and custom info
    ui_panel_destroy(ui);
}
예제 #29
0
int kullanici_onayla()
{
	FIELD *field[3];
	FORM  *my_form;
	int ch;

	touchwin(ana_win);
	wrefresh(ana_win);
			
	init_pair(1, COLOR_WHITE, COLOR_BLUE);
	init_pair(2, COLOR_WHITE, COLOR_BLUE);
		
/*calisma yili 4 karakter*/
	field[0] = new_field(1, 10, 18, 42, 0, 0);
/*firma 2 karakter*/
	field[1] = new_field(1, 10, 20, 42, 0, 0);
	field[2] = NULL;

	set_field_fore(field[0], COLOR_PAIR(1));
	set_field_fore(field[1], COLOR_PAIR(1));
/*geri plan rengi olsun*/
	set_field_back(field[0], COLOR_PAIR(2));
	set_field_back(field[1], COLOR_PAIR(2));
/*
	set_field_type(field[0], TYPE_INTEGER);
	set_field_type(field[1], TYPE_INTEGER);
*/
	field_opts_off(field[0], O_AUTOSKIP); 
	field_opts_off(field[1], O_AUTOSKIP); 

/*sifre alani olan ikinci field password biçiminde olmali/
	field_opts_off(field[1], O_PUBLIC);

	/*geri plan rengi olmasin*/
/*	set_field_back(field[0], A_UNDERLINE); 
	set_field_back(field[1], A_UNDERLINE); 
*/
	my_form = new_form(field);
	post_form(my_form);
	refresh();
	
	set_current_field(my_form, field[0]); 

	mvprintw(18, 25, _("User name :") );
	mvprintw(20, 25, _("Password  :"******"This application under GPL license.") );
attroff(A_BLINK);
attroff(A_BOLD);

attron(A_BOLD);
mvprintw(LINES-3, 5, _("F2-> Begin                                               ESC-> Cancel") );
mvprintw(18, 5, _("F5-> Settings") );
attroff(A_BOLD);

mvprintw(7,3, _("                               Acik                          "));
mvprintw(8,3,"  _|              _|                _|                                  ");
mvprintw(9,3,"         _|_|_|   _|     _|_|     _|_|_|_|   _|_|_|  _|_|       _|_|    ");
mvprintw(10,3,"  _|   _|_|       _|   _|_|_|_|     _|       _|    _|    _|   _|_|_|_|  ");
mvprintw(11,3,"  _|       _|_|   _|   _|           _|       _|    _|    _|   _|        ");
mvprintw(12,3,"  _|   _|_|_|     _|     _|_|_|       _|_|   _|    _|    _|     _|_|_|  ");
refresh();
    while((ch = getch()) )
	{	switch(ch)
		{	
		case 8: /*KEY_BACKSPACE hatali kod vermekte 8 dogru olandir konsolda 8 xterm key_backspace*/
    		form_driver(my_form, REQ_PREV_CHAR);
			form_driver(my_form, REQ_DEL_CHAR);
			break;
		case KEY_BACKSPACE: 
    		form_driver(my_form, REQ_PREV_CHAR);
			form_driver(my_form, REQ_DEL_CHAR);
			break;		
		case 9: /*TAB tusuna basýlmasý durumunda sonraki field konumlan*/
			form_driver(my_form, REQ_NEXT_FIELD);
			form_driver(my_form, REQ_END_LINE);
			break;		
		case 10: /*ENTER tuþuna basýlmasý durumunda sonraki feild gececek*/
			form_driver(my_form, REQ_NEXT_FIELD);
			form_driver(my_form, REQ_END_LINE);
			break;		
		case KEY_DC:	/*del tusu*/		
    		form_driver(my_form,REQ_DEL_CHAR);
			break;			
		case KEY_HOME:
			form_driver(my_form,REQ_BEG_LINE);
			break;						
		case KEY_END:
			form_driver(my_form,REQ_END_LINE);
			break;
		case KEY_DOWN:
			form_driver(my_form, REQ_NEXT_FIELD);
			form_driver(my_form, REQ_END_LINE);
			break;
		case KEY_UP:
			form_driver(my_form, REQ_PREV_FIELD);
			form_driver(my_form, REQ_END_LINE);
			break;
		case KEY_LEFT:
    			form_driver(my_form,REQ_LEFT_CHAR);
			break;
		case KEY_RIGHT:
    			form_driver(my_form,REQ_RIGHT_CHAR);
			break;
		case 27: /*esc durumunda*/
				unpost_form(my_form);
				free_form(my_form);
				free_field(field[0]);
				free_field(field[1]); 
				endwin();
				exit(0);	
				break;
		
		case KEY_F(5): 	/*ayarlara gecis*/
				ayarlar();
				
				unpost_form(my_form);
				free_form(my_form);
				free_field(field[0]);
				free_field(field[1]);
				
				endwin();
		
				exit (0);
				break;
				case KEY_F(2): 	/*f2 durumunda*/
				form_driver(my_form, REQ_PREV_FIELD);
				strcpy(query, "select kullanici, sifre, haklar from kullanicilar");
		
				if ( pgsql_sorgula(query) ==1 ) { mesaj(sql_sorgulama_hatasi); return 1;}
	
				for (i=0;i<pgsql_row_miktar;i++)
					{						
					sprintf(kullanici,"%s", pgsql_kayit_field() );
					sprintf(sifre,"%s", pgsql_kayit_field() );
					sprintf(haklar,"%s", pgsql_kayit_field() );

					if ( strcmp(g_strstrip(field_buffer(field[0],0)), kullanici) ==NULL )
						{
						if  ( (sifre_kripto_coz( g_strstrip(field_buffer(field[1],0)) , sifre) == 0) || (strcmp(g_strstrip(field_buffer(field[1],0)), sifre) == NULL ) )
							{
							//kullanýcý root ise haklar full olmalý 
							//databaseden degistirme ihtimali olabilir								
							if ( strstr( kullanici, "root") ) 
							{sprintf(haklar,"%s", "1111111111111111111111111111111111111111111111111111111111111111");}
												
							beep();
						
							unpost_form(my_form);
							free_form(my_form);
							free_field(field[0]);
							free_field(field[1]);
							touchwin(ana_win);
							wrefresh(ana_win);							
															
							return;
								
							}
							else
							{							
							set_field_buffer(field[0],0," ");
							set_field_buffer(field[1],0," ");
							refresh();	
							//beep sesi							
							beep();
							
							}
						}
					}
			
													
				break;
			
			default:
				form_driver(my_form, ch);
				break;

		}
	}

return 0;
/*son*/
}
예제 #30
0
char *input_box(size_t length, const char *title, const char *description)
{
    WINDOW *ib_win = NULL;
    PANEL *my_panels[1];
    FIELD **fields;
    FORM *my_form = NULL;
    int height, width, startx, starty, max_height, max_width, ch = 0, rows,
                                                              cols, quit = 0, i;
    char *result_ptr = NULL, *temp_ptr = NULL;

    /* create a buffer with the size of 'length' */
    if (!(temp_ptr = malloc(length))) {
        vrmr_error(-1, VR_ERR, gettext("malloc failed: %s"), strerror(errno));
        return (NULL);
    }

    // set the window size
    getmaxyx(stdscr, max_height, max_width);
    height = 8;
    if (length < 16) {
        width = 37; // minimum TODO: why 37?
    } else if ((int)length + 8 > max_width) {
        free(temp_ptr);
        return NULL;
    } else {
        width = (int)length + 8;
        if ((int)StrLen(title) + 8 > width)
            width = (int)StrLen(title) + 8;
        if ((int)StrLen(description) + 8 > width)
            width = (int)StrLen(description) + 8;
    }
    // print on the centre of the screen
    starty = (max_height - height) / 2;
    startx = (max_width - width) / 2;

    // create window
    ib_win = create_newwin(
            height, width, starty, startx, title, vccnf.color_win);
    my_panels[0] = new_panel(ib_win);
    fields = (FIELD **)calloc(1 + 1, sizeof(FIELD *));
    fields[0] = new_field_wrap(
            1, (int)length - 1, 3, (int)(((width - length) / 2) - 2), 0, 0);
    set_field_back(fields[0], vccnf.color_win_rev);
    field_opts_off(fields[0], O_AUTOSKIP);
    set_field_status(fields[0], FALSE);
    my_form = new_form(fields);
    scale_form(my_form, &rows, &cols);
    keypad(ib_win, TRUE);
    set_form_win(my_form, ib_win);
    set_form_sub(my_form, derwin(ib_win, rows, cols, 1, 2));
    post_form(my_form);

    mvwprintw(ib_win, 2, 4, "%s", description);
    mvwprintw(ib_win, 6, 4, gettext("Note: whitespaces not allowed."));

    update_panels();
    doupdate();

    while (quit == 0) {
        ch = wgetch(ib_win);
        switch (ch) {
            case 27:
            case KEY_F(10):
            case 10: // enter
                // Go to next field
                form_driver_wrap(my_form, REQ_NEXT_FIELD);
                form_driver_wrap(my_form, REQ_END_LINE);
                quit = 1;
                break;
            case KEY_BACKSPACE:
            case 127:
                form_driver_wrap(my_form, REQ_PREV_CHAR);
                form_driver_wrap(my_form, REQ_DEL_CHAR);
                form_driver_wrap(my_form, REQ_END_LINE);
                break;
            case KEY_DC:
                form_driver_wrap(my_form, REQ_PREV_CHAR);
                form_driver_wrap(my_form, REQ_DEL_CHAR);
                form_driver_wrap(my_form, REQ_END_LINE);
                break;
            default:
                // If this is a normal character, it gets printed
                form_driver_wrap(my_form, ch);
                break;
        }
    }

    // status_print(status_win, "data: '%s' (%d)", field_buffer(fields[0], 0),
    // length);
    (void)strlcpy(temp_ptr, field_buffer(fields[0], 0), length);

    // get the length of the entry
    i = strlen(temp_ptr);
    while (i--) {
        if (isspace(temp_ptr[i]))
            temp_ptr[i] = '\0';
        else
            break;
    }

    if (!(result_ptr = strdup(temp_ptr))) {
        vrmr_error(-1, VR_ERR, gettext("malloc failed: %s"), strerror(errno));
        goto end;
    }

    if (result_ptr[0] == '\0') {
        free(result_ptr);
        result_ptr = NULL;
    }

end:
    free(temp_ptr);
    unpost_form(my_form);
    free_form(my_form);
    free_field(fields[0]);
    free(fields);
    del_panel(my_panels[0]);
    destroy_win(ib_win);
    update_panels();
    doupdate();
    return (result_ptr);
}