コード例 #1
0
ファイル: vuurmuur_conf.c プロジェクト: inliniac/vuurmuur
/*  draw_field_active_mark

    Draws marks before and after the active field. If prev is non-NULL we first
   remove the marks from the previous field.
*/
void draw_field_active_mark(const FIELD *cur, const FIELD *prev,
        WINDOW *formwin, FORM *form, const chtype ch)
{
    int pos_x, pos_y, x, y, off_row, wrk_buff;

    /* safety */
    if (!cur || !formwin || !form)
        return;

    /* if supplied we remove the previous marking */
    if (prev) {
        if (field_info(prev, &y, &x, &pos_y, &pos_x, &off_row, &wrk_buff) < 0)
            return;

        mvwprintw(formwin, pos_y + 1, pos_x, " ");
        mvwprintw(formwin, pos_y + 1, pos_x + x + 3, " ");
    }

    /* draw our marking */
    if (field_info(cur, &y, &x, &pos_y, &pos_x, &off_row, &wrk_buff) < 0)
        return;

    wattron(formwin, ch);
    mvwprintw(formwin, pos_y + 1, pos_x, ">");
    mvwprintw(formwin, pos_y + 1, pos_x + x + 3, "<");
    wattroff(formwin, ch);
    wrefresh(formwin);

    /* restore cursor position */
    pos_form_cursor(form);
    return;
}
コード例 #2
0
ファイル: form_wrap.c プロジェクト: gauteh/ncursesw-ruby
/*
 * form_field_info(3x)
 */
static VALUE rbncurs_c_field_info(VALUE rb_field, VALUE rows, VALUE cols,
											 VALUE frow, VALUE fcol, VALUE nrow, VALUE nbuf) {
  if (rb_obj_is_instance_of(rows, rb_cArray) != Qtrue
		|| rb_obj_is_instance_of(cols, rb_cArray) != Qtrue
		|| rb_obj_is_instance_of(frow, rb_cArray) != Qtrue
		|| rb_obj_is_instance_of(fcol, rb_cArray) != Qtrue
		|| rb_obj_is_instance_of(nrow, rb_cArray) != Qtrue
		|| rb_obj_is_instance_of(nbuf, rb_cArray) != Qtrue) {
	 rb_raise(rb_eArgError,
				 "rows, cols, frow, fcol, nrow and nbuf arguments must be empty Arrays");
	 return Qnil;
  }
  else {
	 FIELD* field = get_field(rb_field);
	 int vals[6] = {0,0,0,0,0,0};

	 int result = field_info(field, &vals[0],&vals[1],&vals[2],&vals[3],&vals[4],&vals[5]);
	 rb_ary_push(rows, INT2NUM(vals[0]));
	 rb_ary_push(cols, INT2NUM(vals[1]));
	 rb_ary_push(frow, INT2NUM(vals[2]));
	 rb_ary_push(fcol, INT2NUM(vals[3]));
	 rb_ary_push(nrow, INT2NUM(vals[4]));
	 rb_ary_push(nbuf, INT2NUM(vals[5]));
	 return INT2NUM(result);
  }
}
コード例 #3
0
ファイル: menus.c プロジェクト: aspacsa/vlp
void get_cursor_pos(const FIELD const * field, int* row, int* col) {
  int rows, cols, nrow, nbuf, trow, tcol;
  field_info(field, &rows, &cols,
             &trow, &tcol, &nrow, &nbuf);
  *row = trow;
  *col = tcol;
  return;
}
コード例 #4
0
ファイル: describe.c プロジェクト: AsherBond/MondocosmOS
/* describe table, if c is not NULL cur->cols and cur->ncols is also set */
int describe_table(MYSQL_RES * res, dbTable ** table, cursor * c)
{
    int i, ncols, kcols;
    char *name;
    int sqltype, length;
    dbColumn *column;
    MYSQL_FIELD *fields;

    G_debug(3, "describe_table()");

    ncols = mysql_num_fields(res);
    fields = mysql_fetch_fields(res);

    /* Count columns of known type */
    kcols = 0;
    for (i = 0; i < ncols; i++) {
	field_info(&(fields[i]), &sqltype, &length);

	if (sqltype == DB_SQL_TYPE_UNKNOWN)
	    continue;

	kcols++;		/* known types */
    }

    G_debug(3, "kcols = %d", kcols);

    if (!(*table = db_alloc_table(kcols))) {
	return DB_FAILED;
    }

    if (c) {
	c->ncols = kcols;
	c->cols = (int *)G_malloc(kcols * sizeof(int));
    }

    db_set_table_name(*table, "");
    db_set_table_description(*table, "");

    /* Currently not used in GRASS */
    /*
       db_set_table_delete_priv_granted (*table);
       db_set_table_insert_priv_granted (*table);
       db_set_table_delete_priv_not_granted (*table);
       db_set_table_insert_priv_not_granted (*table);
     */

    kcols = 0;
    for (i = 0; i < ncols; i++) {
	name = fields[i].name;
	field_info(&(fields[i]), &sqltype, &length);

	G_debug(3, "col: %s, kcols %d, sqltype %d", name, kcols, sqltype);

	G_debug(3, "flags = %d", fields[i].flags);

	if (sqltype == DB_SQL_TYPE_UNKNOWN) {
	    /* Print warning and continue */
	    G_warning(_("MySQL driver: column '%s', type %d "
			"is not supported"), name, fields[i].type);
	    continue;
	}

	if (fields[i].type == MYSQL_TYPE_LONGLONG)
	    G_warning(_("column '%s' : type BIGINT is stored as "
			"integer (4 bytes) some data may be damaged"), name);

	column = db_get_table_column(*table, kcols);

	db_set_column_name(column, name);
	db_set_column_length(column, length);
	db_set_column_host_type(column, (int)fields[i].type);
	db_set_column_sqltype(column, sqltype);

	db_set_column_precision(column, (int)fields[i].decimals);
	db_set_column_scale(column, 0);

	if (!(fields[i].flags & NOT_NULL_FLAG)) {
	    db_set_column_null_allowed(column);
	}
	db_set_column_has_undefined_default_value(column);
	db_unset_column_use_default_value(column);

	/* Currently not used in GRASS */
	/*
	   db_set_column_select_priv_granted (column);
	   db_set_column_update_priv_granted (column);
	   db_set_column_update_priv_not_granted (column); 
	 */

	if (c) {
	    c->cols[kcols] = i;
	}

	kcols++;
    }

    return DB_OK;
}