def get_field_infos(code, free_format):
    offset = 0
    field_infos = []
    lines = _clean_code(code)
    previous_offset = 0
    for row in process_cobol(lines, free_format):
        fi = PicFieldInfo()
        fi.name = row["name"]
        fi.level = row["level"]
        fi.pic = row["pic"]
        fi.occurs = row["occurs"]
        fi.redefines = row["redefines"]
        fi.indexed_by = row["indexed_by"]
        if fi.redefines:
            for fib in field_infos:
                if fib.name == fi.redefines:
                    offset = fib.offset
        if fi.level == 1:
            offset = 1
        if fi.level == 78:
            offset = 0
        if fi.level == 77:
            offset = 1
        fi.offset = offset
        if fi.level == 88:
            fi.offset = previous_offset
        else:
            previous_offset = offset
        field_infos.append(fi)
        if row['pic']:
            offset += row['pic_info']['length']
    return field_infos