Beispiel #1
0
/*! \brief Create attribute pair
 *
 * This function takes a table, a row list, and a row name,
 * and returns a list holding
 * name=value pairs for all attribs pertainent to that particular
 * row.
 * If the row holds no attribs, it just returns NULL.
 *
 * \param row_name Name of the row to search for
 * \param table Table to be searched
 * \param row_list list of rows
 * \param num_attribs
 * \returns STRING_LIST of name=value pairs
 */
STRING_LIST *s_table_create_attrib_pair(gchar *row_name, 
					TABLE **table, 
					STRING_LIST *row_list,
					int num_attribs)
{
  STRING_LIST *attrib_pair_list;
  char *attrib_name, *attrib_value, *name_value_pair;
  int row, col;
  int count = 0;
  
  attrib_pair_list = s_string_list_new();

  row = s_table_get_index(row_list, row_name);
  /* Sanity check */
  if (row == -1) {
    /* we didn't find the item in the list */
    fprintf (stderr,
             "In s_table_create_attrib_pair, we didn't find the row name in the row list!\n");
    return attrib_pair_list;
  }

  for (col = 0; col < num_attribs; col++) {
    /* pull attrib from table.  If non-null, add it to attrib_pair_list  */
    if ( (table[row][col]).attrib_value != NULL) {
      attrib_name = (table[row][col]).col_name;
      attrib_value = (table[row][col]).attrib_value;
      name_value_pair = g_strconcat(attrib_name, "=", attrib_value, NULL);
      s_string_list_add_item(attrib_pair_list, &count, name_value_pair);
      g_free(name_value_pair);
    }
  }

  return attrib_pair_list;
}
Beispiel #2
0
/*! \brief Duplicate a STRING_LIST
 *
 * Given a STRING_LIST, duplicate it and returns a pointer
 * to the new, duplicate list.
 * \param old_string_list pointer to the STRING_LIST to be duplicated
 * \returns a pointer to the duplicate STRING_LIST
 */
STRING_LIST *s_string_list_duplicate_string_list(STRING_LIST *old_string_list) {
  STRING_LIST *new_string_list;
  STRING_LIST *local_string_list;
  char *data;
  gint count;

  new_string_list = s_string_list_new();

  if (old_string_list->data == NULL) 
    /* This is an empty string list */
    return new_string_list;

  local_string_list = old_string_list;
  while (local_string_list != NULL) {
    data = g_strdup(local_string_list->data);
    s_string_list_add_item(new_string_list, &count, data);
    g_free(data);
    local_string_list = local_string_list->next;
  }

  return new_string_list;
}
Beispiel #3
0
/*! \brief Get pin attributes
 *
 * This function takes a pointer to the OBJECT pin, and returns a list
 * of attribs found attached to the pin.  The returned list is a
 * STRING_LIST where the ->data holds a name=value string.
 * The algorithm is as follows:
 * -# Form refdes:pinnumber label for this pin.
 * -# Get row number of this refdes:pinnumber
 * -# Create a list of name=value pairs from entries in the pin_table
 *    on this row.
 * -# Return list of name=value pairs found.
 *
 * \param refdes Ref des string
 * \param pin Pin object
 * \returns name=value pair as a STRING_LIST
 */
STRING_LIST *s_toplevel_get_pin_attribs_in_sheet(char *refdes, OBJECT *pin)
{
    STRING_LIST *new_attrib_list;
    STRING_LIST *local_attrib_list;
    int i;
    int row = -1;
    int count = 0;
    char *pinnumber;
    char *row_label;
    char *name_value_pair;
    char *new_attrib_value;
    char *new_attrib_name;

#if DEBUG
    printf("-----  Entering s_toplevel_get_pin_attribs_in_sheet.\n");
#endif

    /* First find pos of this pin in the master pin list */
    /* first convert refdes, pin to refdes:pinno text string. Then call table_get_index.  */

    pinnumber = o_attrib_search_object_attribs_by_name (pin, "pinnumber", 0);

    if ( (refdes != NULL) && (pinnumber != NULL) ) {
        row_label = g_strconcat(refdes, ":", pinnumber, NULL);
    } else {
        fprintf(stderr,
                "In s_toplevel_get_pin_attribs_in_sheet, either refdes or pinnumber of object missing!\n");
        return NULL;
    }
    row = s_table_get_index(sheet_head->master_pin_list_head, row_label);

    /* Sanity check */
    if (row == -1) {
        /* we didn't find the item in the list */
        fprintf(stderr,
                "In s_toplevel_get_pin_attribs_in_sheet, we didn't find the refdes:pin in the master list!\n");
        return NULL;
    }

    /* Now get all attribs associated with this refdes (in TABLE, indexed
     * by position), and insert them into new_attrib_list.  */
    new_attrib_list = s_string_list_new();  /* init new_attrib_list */

    i = 0;
    local_attrib_list = sheet_head->master_pin_attrib_list_head;
    while (local_attrib_list != NULL) {  /* iterate over all possible attribs */
        new_attrib_name = g_strdup(local_attrib_list->data);  /* take attrib name from column headings */

        if ( ((sheet_head->pin_table)[row][i]).attrib_value ) {
            new_attrib_value = g_strdup( ((sheet_head->pin_table)[row][i]).attrib_value );
            name_value_pair = g_strconcat(new_attrib_name, "=", new_attrib_value, NULL);
            g_free(new_attrib_value);
        } else {
            name_value_pair = g_strconcat(new_attrib_name, "=", NULL);  /* empty attrib */
        }
        s_string_list_add_item(new_attrib_list, &count, name_value_pair);  /* add name=value to new list */
        g_free(new_attrib_name);
        g_free(name_value_pair);

        /* Sanity check */
        if (count != i+1) {
            /* for some reason, we have lost a name_value_pair somewhere . . .  */
            fprintf(stderr,
                    "In s_toplevel_get_pin_attribs_in_sheet, count != i!  Exiting . . . .\n");
            exit(-1);
        }

        /* iterate */
        i++;
        local_attrib_list = local_attrib_list->next;
    } /* while (local_attrib_list != NULL)  */

    return new_attrib_list;
}
Beispiel #4
0
/*! \brief Get the component attributes from the top level
 *
 * This function returns a list of attributes attached to obj_name = comp
 * refdes or netlist.
 * \param refdes component refdes to return values from
 * \returns a STRING_LIST where the data field holds a name=value string.
 */
STRING_LIST *s_toplevel_get_component_attribs_in_sheet(char *refdes)
{
    STRING_LIST *new_attrib_list;
    STRING_LIST *local_attrib_list;
    int i;
    int row = -1;
    int count = 0;
    char *name_value_pair;
    char *new_attrib_value;
    char *new_attrib_name;

#if DEBUG
    printf("-----  Entering s_toplevel_get_component_attribs_in_sheet.\n");
#endif


    /* First find pos of this refdes in the master list */
    row = s_table_get_index(sheet_head->master_comp_list_head, refdes);

    /* Sanity check */
    if (row == -1) {
        /* we didn't find the item in the list */
        fprintf(stderr,
                "In s_toplevel_get_component_attribs_in_sheet, we didn't find the refdes in the master list!\n");
        return NULL;
    }

    /* Now get all attribs associated with this refdes (in TABLE, indexed
     * by position), and insert them into new_attrib_list.  */
    new_attrib_list = s_string_list_new();  /* init new_attrib_list */

    i = 0;
    local_attrib_list = sheet_head->master_comp_attrib_list_head;
    while (local_attrib_list != NULL) {  /* iterate over all possible attribs */
        new_attrib_name = g_strdup(local_attrib_list->data);  /* take attrib name from column headings */

        if ( ((sheet_head->component_table)[row][i]).attrib_value ) {
            new_attrib_value = g_strdup( ((sheet_head->component_table)[row][i]).attrib_value );
            name_value_pair = g_strconcat(new_attrib_name, "=", new_attrib_value, NULL);
            g_free(new_attrib_value);
        } else {
            name_value_pair = g_strconcat(new_attrib_name, "=", NULL);  /* empty attrib */
        }
        s_string_list_add_item(new_attrib_list, &count, name_value_pair);  /* add name=value to new list */
        g_free(new_attrib_name);
        g_free(name_value_pair);

        /* Sanity check */
        if (count != i+1) {
            /* for some reason, we have lost a name_value_pair somewhere . . .  */
            fprintf(stderr,
                    "In s_toplevel_get_component_attribs_in_sheet, count != i!  Exiting . . . .\n");
            exit(-1);
        }

        /* iterate */
        i++;
        local_attrib_list = local_attrib_list->next;
    } /* while (local_attrib_list != NULL)  */

    return new_attrib_list;
}