Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, April 19, 2024

File: [Platon] / tucniak / db / tdb_cell.c (download)

Revision 1.1.1.1 (vendor branch), Fri Nov 11 16:08:26 2005 UTC (18 years, 5 months ago) by koli


Changes since 1.1: +0 -0 lines

Initial import

// Copyright (c) 2003,2004,2005 Juraj Kolesár <koli@koli.sk>               
#include "tdb.h"
/* width {{{ *******************************************************************/
int t_cellist_width_sum(T_CELLIST *list, int pos) {
    int i;
    int width = 0;
    T_CELL *cell;
    list = g_list_first(list);
    for (i=0; i <= pos; i++) {
        cell = list->data;
        width += cell->width;
        if (list->next != NULL) 
            list = g_list_next(list);
        else return(__LT_ERR);
    }
    return(width);
}
/* }}} */
/* widths sum {{{ *************************************************************/
int t_cols_width_sum(T_COLS *cols) {
    int i;
    int width = 0;
    T_CELL *cell;
    while (cols != NULL) {
        cell = cols->data;
        width += cell->width;
        cols = g_slist_next(cols);
    }
    return(width);
}
/* }}} */
/* cols get values {{{ ********************************************************/
int t_cols_get_values(T_COLS *cols, int column, 
                        int *pos, int *width, char *value) {
    T_CELL *cell = cols->data;
    *pos = 1;
    while ((column > 0) && (cols->next != NULL)) {
        if (cell->width > 0) *pos += cell->width + 1;
        cols = g_slist_next(cols);
        cell = cols->data;
        column--;
    }
    *width = cell->width;
    strcpy(value,cell->value);
    return(column);
}
/* }}} */
/* cols set values {{{ ********************************************************/
int t_cols_set_value(T_COLS *cols, int column, int width, char *value) {
    register int i;
    T_CELL *cell;
    for (i=0; i < column; i++) {
        if (cols->next != NULL) cols = g_slist_next(cols);
        else return(__LT_ERR);
    }
    cell = cols->data;
    cell->width = width;
    strcpy(cell->value, value);
    return(__LT_OK);
}
/* }}} */
/* width {{{ *******************************************************************/
int t_cols_next(T_COLS *cols, int *column) {
    T_COLS *m_cols = cols;
    T_CELL *cell;
    register int i;
    for (i=0; i < *column; i++) {
        if (m_cols->next != NULL) m_cols = g_slist_next(m_cols);
        else return(__LT_ERR);
    } 
    do {
        if (m_cols->next != NULL) {
            m_cols = g_slist_next(m_cols);
            (*column)++;
        } else {
            m_cols = cols;
            *column = 0;
        }
        cell = m_cols->data;
    } while (cell->width == 0);
    return(__LT_OK);
}
/* }}} */

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top