Exemplo n.º 1
0
static mrb_value
hdb_put(mrb_state *mrb, mrb_value self)
{
  mrb_value key, value;
  mrb_bool sync;
  bool result = false;
  mrb_int args;
  void *kbuf, *vbuf;
  int ksize, vsize;
  mrb_int kint, vint;
  hdb_context *context = DATA_PTR(self);

  args = mrb_get_args(mrb, "oo|b", &key, &value, &sync);
  if (args == 2) {
    sync = true;
  }

  if (!get_content(key, &kint, &kbuf, &ksize)) {
    mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid type of key");
  }

  if (!get_content(value, &vint, &vbuf, &vsize)) {
    mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid type of value");
  }

  if (sync) {
    result = tchdbput(context->hdb, kbuf, ksize, vbuf, vsize);
  } else {
    result = tchdbputasync(context->hdb, kbuf, ksize, vbuf, vsize);
  }

  return mrb_bool_value(result);
}
Exemplo n.º 2
0
static void
parse_command (xmlNodePtr node, InputPadTableCmd *cmd)
{
    xmlNodePtr current;
    gboolean has_execl = FALSE;

    for (current = node; current; current = current->next) {
        if (current->type == XML_ELEMENT_NODE) {
            if (!g_strcmp0 ((char *) current->name, "label")) {
                if (current->children) {
                    get_content (current->children, &cmd->label, TRUE);
                } else {
                    g_error ("tag %s does not have child tags in the file %s",
                             (char *) current->name,
                             xml_file);
                }
            }
            if (!g_strcmp0 ((char *) current->name, "execl")) {
                if (current->children) {
                    get_content (current->children, &cmd->execl, FALSE);
                    has_execl = TRUE;
                } else {
                    g_error ("tag %s does not have child tags in the file %s",
                             (char *) current->name,
                             xml_file);
                }
            }
        }
    }
    if (!has_execl) {
        g_error ("tag %s does not find \"execl\" tag in file %s",
                 node->parent ? node->parent->name ? (char *) node->parent->name : "(null)" : "(null)",
                 xml_file);
    }
}
Exemplo n.º 3
0
//Функция инициализирует графику и все переменные
void init_manager(WINDOW ***win, char content[2][512][128], unsigned count[2], char patch[2][512], unsigned *active, unsigned *print, unsigned *select)
{
	//Инициализация графики
	initscr();
	cbreak();
	curs_set(0);
	noecho();
	keypad(stdscr, TRUE);
	
	//Выделение памяти
	(*win) = malloc(4 * sizeof(WINDOW *));
	
	//Инициализации переменных
	(*active) = LEFT;
	(*print) = 0;
	(*select) = 0;
	getcwd(patch[LEFT], 512);
	getcwd(patch[RIGHT], 512);
	count[LEFT] = get_content(patch[LEFT], content[LEFT]);
	count[RIGHT] = get_content(patch[RIGHT], content[RIGHT]);
	(*win)[BLEFT] = newwin(LINES, COLS / 2, 0, 0);
	(*win)[BRIGHT] = newwin(LINES, COLS / 2, 0, COLS / 2);
	(*win)[LEFT] = newwin(LINES - 2, (COLS / 2) - 2, 1, 1);
	(*win)[RIGHT] = newwin(LINES - 2, (COLS / 2) - 2, 1, (COLS / 2) + 1);
	
	refresh();
}
Exemplo n.º 4
0
std::size_t message::write(std::ostream& out,
    boost::system::error_code& ec, bool headers_only)
{
    // reset error_code
    ec.clear();

    // initialize write buffers for send operation using HTTP headers
    write_buffers_t write_buffers;
    prepare_buffers_for_send(write_buffers, true, false);

    // append payload content to write buffers (if there is any)
    if (!headers_only && get_content_length() > 0 && get_content() != NULL)
        write_buffers.push_back(boost::asio::buffer(get_content(), get_content_length()));

    // write message to the output stream
    std::size_t bytes_out = 0;
    for (write_buffers_t::const_iterator i=write_buffers.begin(); i!=write_buffers.end(); ++i) {
        const char *ptr = boost::asio::buffer_cast<const char*>(*i);
        size_t len = boost::asio::buffer_size(*i);
        out.write(ptr, len);
        bytes_out += len;
    }

    return bytes_out;
}
Exemplo n.º 5
0
std::size_t message::send(tcp::connection& tcp_conn,
                          boost::system::error_code& ec, bool headers_only)
{
    // initialize write buffers for send operation using HTTP headers
    write_buffers_t write_buffers;
    prepare_buffers_for_send(write_buffers, tcp_conn.get_keep_alive(), false);

    // append payload content to write buffers (if there is any)
    if (!headers_only && get_content_length() > 0 && get_content() != NULL)
        write_buffers.push_back(boost::asio::buffer(get_content(), get_content_length()));

    // send the message and return the result
    return tcp_conn.write(write_buffers, ec);
}
Exemplo n.º 6
0
void custom_ontrigger_logic(processor_session *ps, processor_context *ctx) {
  flow_file_record * ffr = get(ps, ctx);
  REQUIRE(ffr != nullptr);
  uint8_t * buffer = (uint8_t*)malloc(ffr->size* sizeof(uint8_t));
  get_content(ffr, buffer, ffr->size);
  REQUIRE(strncmp(reinterpret_cast<const char *>(buffer), test_file_content.c_str(), test_file_content.size()) == 0);

  attribute attr;
  attr.key = "filename";
  attr.value_size = 0;
  REQUIRE(get_attribute(ffr, &attr) == 0);
  REQUIRE(attr.value_size > 0);

  const char * custom_value = "custom value";

  REQUIRE(add_attribute(ffr, "custom attribute", (void*)custom_value, strlen(custom_value)) == 0);

  char prop_value[20];

  REQUIRE(get_property(ctx, "Some test propery", prop_value, 20) == 0);

  REQUIRE(strncmp("test value", prop_value, strlen(prop_value)) == 0);

  transfer_to_relationship(ffr, ps, SUCCESS_RELATIONSHIP);

  free_flowfile(ffr);
  free(buffer);
}
Exemplo n.º 7
0
static int load_file(const char* file_path, int offset_block, int blocks) {
    printf("Try to load:%s", file_path);
    if (blocks) {
        printf(", offset block:%d, blocks:%d\n", offset_block, blocks);
    } else {
        printf("\n");
    }
    bool ret = false;
    resource_content content;
    snprintf(content.path, sizeof(content.path), "%s", file_path);
    content.load_addr = 0;
    if (!get_content(&content)) {
        goto end;
    }
    if (!blocks) {
        if (!load_content(&content)) {
            goto end;
        }
    } else {
        void* data = malloc(blocks * BLOCK_SIZE);
        if (!data)
            goto end;
        if (!load_content_data(&content, offset_block, data, blocks)) {
            goto end;
        }
    }
    ret = true;
end:
    free_content(&content);
    return ret;
}
Exemplo n.º 8
0
/**
 * \brief Update level name.
 */
void ptb::frame_play_story::update_level_name()
{
  // Adjust the height of m_name_text in position_controls() to the height
  // of this font
  const bear::visual::writing w
    ( get_layer().get_level().get_globals().get_font
      ("font/level_name-42x50.fnt", 50),
      gettext(m_levels[m_index].get_id().c_str()) );

  m_name_text->set_size
    ( std::min(w.get_width(), get_content().width()), 50 );
  m_name_text->set_scene_element( bear::visual::scene_writing(0, 0, w) );
  m_name_text->set_position
    ( (get_content().width() - m_name_text->width()) / 2,
      m_thumb->top() + get_margin());
} // frame_play_story::update_level_name()
Exemplo n.º 9
0
static void
parse_keys (xmlNodePtr node, InputPadTable **ptable)
{
    xmlNodePtr current;
    gboolean has_keys = FALSE;

    for (current = node; current; current = current->next) {
        if (current->type == XML_ELEMENT_NODE) {
            if (!g_strcmp0 ((char *) current->name, "keysyms")) {
                (*ptable)->type = INPUT_PAD_TABLE_TYPE_KEYSYMS;
                if (current->children) {
                    get_content (current->children, &(*ptable)->data.keysyms, FALSE);
                    has_keys = TRUE;
                } else {
                    g_error ("tag %s does not have child tags in the file %s",
                             (char *) current->name,
                             xml_file);
                }
            }
        }
    }
    if (!has_keys) {
        g_error ("tag %s does not find \"keysyms\" tag in file %s",
                 node->parent ? node->parent->name ? (char *) node->parent->name : "(null)" : "(null)",
                 xml_file);
    }
}
Exemplo n.º 10
0
/*
处理静态内容
*/
void deal_static(int client_sock,char *path,int file_size){
	
	//send_head(client_sock,path);

	//FILE *file=fopen(path,"r");
	char *buf;
	char file[file_size];
	//对buf进行内存分配
	buf = (char *)malloc(file_size);
	//打开文件
	int fd = open(path,O_RDONLY);
	if(fd==-1){
		not_found(client_sock,path);
	}else{
		//发送头部
		send_head(client_sock,path);
		//获取内容
		get_content(buf,fd,file_size);
		//给客户端发送文件内容
		send(client_sock,buf,file_size,0);
	}
	
	//释放内容,这很重要
	free(buf);
	close(fd);
	return;

}
Exemplo n.º 11
0
/**
 * \brief Create the radio button group.
 * \param f The font to use for the text.
 */
bear::gui::radio_group*
ptb::frame_profiles::create_profiles_radio_buttons( bear::visual::font f )
{
  bear::gui::radio_group* const radio_group( new bear::gui::radio_group );
  radio_group->set_size
    ( std::numeric_limits<bear::gui::size_type>::max(),
      std::numeric_limits<bear::gui::size_type>::max() );

  m_profile_radio_buttons.resize(PTB_NUMBER_OF_PROFILES);

  for ( unsigned int i = 0; i < PTB_NUMBER_OF_PROFILES; ++i )
    {
      m_profile_radio_buttons[i] =
        new bear::gui::radio_button( get_radio_off(), get_radio_on(), f );
      m_profile_radio_buttons[i]->set_text( "Width fill placeholder" );

      allow_focus(*m_profile_radio_buttons[i]);
      radio_group->add_button(m_profile_radio_buttons[i], get_margin());
    }

  radio_group->fit();
  get_content().insert( radio_group );

  m_profile_radio_buttons.back()->check();

  return radio_group;
} // frame_profiles::create_profiles_radio_buttons()
Exemplo n.º 12
0
/**
 * grl_net_wc_request_finish:
 * @self: a #GrlNetWc instance
 * @result: The result of the request
 * @content: The contents of the resource
 * @length: (allow-none): The length of the contents or %NULL if it is not
 * needed
 * @error: return location for a #GError, or %NULL
 *
 * Finishes an asynchronous load of the file's contents.
 * The contents are placed in contents, and length is set to the size of the
 * contents string.
 *
 * The content address will be invalidated at the next request. So if you
 * want to keep it, please copy it into another address.
 *
 * Returns: %TRUE if the request was successfull. If %FALSE an error occurred.
 */
gboolean
grl_net_wc_request_finish (GrlNetWc *self,
                           GAsyncResult *result,
                           gchar **content,
                           gsize *length,
                           GError **error)
{
  GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (result);
  gboolean ret = TRUE;

  g_warn_if_fail (g_simple_async_result_get_source_tag (res) ==
                  grl_net_wc_request_async);

  void *op = g_simple_async_result_get_op_res_gpointer (res);

  if (g_simple_async_result_propagate_error (res, error) == TRUE) {
    ret = FALSE;
    goto end_func;
  }

  if (is_mocked ())
    get_content_mocked (self, op, content, length);
  else
    get_content(self, op, content, length);

end_func:
  if (is_mocked ())
    free_mock_op_res (op);
  else
    free_op_res (op);

  return ret;
}
Exemplo n.º 13
0
static mrb_value
hdb_assoc(mrb_state *mrb, mrb_value self)
{
  hdb_context *context = DATA_PTR(self);
  void *kbuf;
  int ksize;
  mrb_int kint;
  mrb_value ary;
  int sp;
  void *value;
  mrb_value key, result;

  mrb_get_args(mrb, "o", &key);

  if (!get_content(key, &kint, &kbuf, &ksize)) {
    return mrb_nil_value();
  }

  value = tchdbget(context->hdb, kbuf, ksize, &sp);
  if (value == NULL || sp <= 0) {
    if (value) {
      free(value);
    }
    return mrb_nil_value();
  }

  result = mrb_str_new(mrb, value, sp);
  free(value);

  ary = mrb_ary_new_capa(mrb, 2); 
  mrb_ary_push(mrb, ary, key);
  mrb_ary_push(mrb, ary, result);

  return ary; 
}
Exemplo n.º 14
0
static mrb_value
hdb_get(mrb_state *mrb, mrb_value self)
{
  hdb_context *context = DATA_PTR(self);
  mrb_value key, result;
  void *kbuf;
  int ksize;
  mrb_int kint;
  int sp = 0;
  void *value;


  mrb_get_args(mrb, "o", &key);

  if (!get_content(key, &kint, &kbuf, &ksize)) {
    mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid type of key");
  }

  value = tchdbget(context->hdb, kbuf, ksize, &sp);
  if (value == NULL || sp <= 0) {
    if (value) {
      free(value);
    }
    return mrb_nil_value();
  }

  result = mrb_str_new(mrb, value, sp);
  free(value);
 
  return result; 
}
Exemplo n.º 15
0
void FolderPost::Deserialize(Json::Value& root) {
    Post::Deserialize(root);

    Json::Value folder(Json::objectValue);
    get_content("folder", folder);
    folder_.set_foldername(folder.get("foldername", "").asString());
    folder_.set_parent_post_id(folder.get("parent_post", "").asString());
    folder_.set_folder_post_id(id());
}
Exemplo n.º 16
0
/**
 * \brief Insert a control in the list of activable controls.
 * \param c The control to insert in the list.
 */
void ptb::frame::insert_control( bear::gui::visual_component& c )
{
  get_content().insert(&c);

  m_controls.push_back(&c);

  if ( m_controls.size() == 1 )
    switch_to_control(0);
} // frame::insert_control()
Exemplo n.º 17
0
static void
parse_string (xmlNodePtr node, InputPadTableStr *str)
{
    xmlNodePtr current;
    gboolean has_label = FALSE;

    for (current = node; current; current = current->next) {
        if (current->type == XML_ELEMENT_NODE) {
            if (!g_strcmp0 ((char *) current->name, "label")) {
                if (current->children) {
                    get_content (current->children, &str->label, FALSE);
                    has_label = TRUE;
                } else {
                    g_error ("tag %s does not have child tags in the file %s",
                             (char *) current->name,
                             xml_file);
                }
            }
            if (!g_strcmp0 ((char *) current->name, "comment")) {
                if (current->children) {
                    get_content (current->children, &str->comment, TRUE);
                } else {
                    g_error ("tag %s does not have child tags in the file %s",
                             (char *) current->name,
                             xml_file);
                }
            }
            if (!g_strcmp0 ((char *) current->name, "rawtext")) {
                if (current->children) {
                    get_content (current->children, &str->rawtext, TRUE);
                } else {
                    g_error ("tag %s does not have child tags in the file %s",
                             (char *) current->name,
                             xml_file);
                }
            }
        }
    }
    if (!has_label) {
        g_error ("tag %s does not find \"label\" tag in file %s",
                 node->parent ? node->parent->name ? (char *) node->parent->name : "(null)" : "(null)",
                 xml_file);
    }
}
Exemplo n.º 18
0
/**
 * \brief Create the static text components.
 */
void ptb::frame_play_story::create_controls()
{
  m_thumb = new bear::gui::picture( get_default_thumb() );
  m_name_text = new bear::gui::scene_element();
  m_status_picture = new bear::gui::picture( get_status_picture() );

  get_content().insert( m_thumb );
  get_content().insert( m_name_text );
  get_content().insert( m_status_picture );

  m_second_player_status.energy = new horizontal_gauge
    ( get_layer().get_level().get_globals(), 100, "bar (light blue)",
      "bar (red)", "heart", true );

  m_first_player_status.energy = new horizontal_gauge
    ( get_layer().get_level().get_globals(), 100, "bar (green)",
      "bar (red)", "heart", true );

  create_player_component(m_first_player_status);
  create_player_component(m_second_player_status);
  create_bonus_component();

  bear::gui::visual_component* ok = create_ok_button();
  bear::gui::visual_component* back = create_back_button();
  bear::gui::visual_component* previous = create_previous_button();
  bear::gui::visual_component* next = create_next_button();

  position_controls( ok->top() + get_margin() );

  bear::gui::size_type sum_w
    ( 3 * get_margin() + ok->width() + back->width() + previous->width()
      + next->width() );

  const bear::gui::size_type w
    ( (m_bonus->width() + m_thumb->width() + 2*get_margin() - sum_w) / 3);

  back->set_left( ok->right() + w );
  previous->set_left( back->right() + w );
  next->set_right( m_status_picture->right() );

  ok->set_focus();

  fit( get_margin() );
} // frame_play_story::create_controls()
Exemplo n.º 19
0
void atom_parser::parse_feed(feed& f, xmlNode * rootNode) {
	if (!rootNode)
		throw exception(_("XML root node is NULL"));

	switch (f.rss_version) {
	case ATOM_0_3:
		ns = ATOM_0_3_URI;
		break;
	case ATOM_1_0:
		ns = ATOM_1_0_URI;
		break;
	case ATOM_0_3_NONS:
		ns = nullptr;
		break;
	default:
		ns = nullptr;
		break;
	}

	f.language = get_prop(rootNode, "lang");
	globalbase = get_prop(rootNode, "base", XML_URI);

	for (xmlNode * node = rootNode->children; node != nullptr; node = node->next) {
		if (node_is(node, "title", ns)) {
			f.title = get_content(node);
			f.title_type = get_prop(node, "type");
			if (f.title_type == "")
				f.title_type = "text";
		} else if (node_is(node, "subtitle", ns)) {
			f.description = get_content(node);
		} else if (node_is(node, "link", ns)) {
			std::string rel = get_prop(node, "rel");
			if (rel == "alternate") {
				f.link = newsbeuter::utils::absolute_url(globalbase, get_prop(node, "href"));
			}
		} else if (node_is(node, "updated", ns)) {
			f.pubDate = w3cdtf_to_rfc822(get_content(node));
		} else if (node_is(node, "entry", ns)) {
			f.items.push_back(parse_entry(node));
		}
	}

}
Exemplo n.º 20
0
size_t write_data(void *ptr,size_t size,size_t nmemb,void *stream)
{
	FILE *fp;
	int rs;
	get_content((char *)ptr);
	fp=fopen("/dev/null","w");
	rs=fwrite(ptr,size,nmemb,fp);
	fclose(fp);

	return rs;
}
Exemplo n.º 21
0
std::string rss_parser::get_xml_content(xmlNode * node) {
	xmlBufferPtr buf = xmlBufferCreate();
	std::string result;

	if (node->children) {
		for (xmlNodePtr ptr = node->children; ptr != NULL; ptr = ptr->next) {
			if (xmlNodeDump(buf, doc, ptr, 0, 0) >= 0) {
				result.append((const char *)xmlBufferContent(buf));
				xmlBufferEmpty(buf);
			} else {
				result.append(get_content(ptr));
			}
		}
	} else {
		result = get_content(node); // fallback
	}
	xmlBufferFree(buf);

	return result;
}
Exemplo n.º 22
0
void open_dir(char* name, char patch[2][512], char content[512][128], unsigned *count, unsigned active)
{
	struct stat info;
	
	stat(name, &info);
	if(info.st_mode == 16877)
	{
		chdir(name);
		getcwd(patch[active], 512);
		(*count) = get_content(patch[active], content);
	}
}
Exemplo n.º 23
0
/**
 * @brief HTTP::download
 * @return int
 */
int HTTP::download()
{
    initiateConnection(); // connection init
    send_request(); // send request with headers
    get_headers(); // get headers, find if chunked, redirection etc.
    std::string s =  get_content(); // save the content

    std::ofstream out("output.xml");
    out << s; // save to file
    out.close();

    return 0;
}
Exemplo n.º 24
0
/**
 *  tests fd() as well as chk_inst()
 */
static char * test_fd() {
    Logo good, b_varnum, b_inst, b_chk_inst;
    char *buffer;
    int ret;
    printf("Testing %s\n", __FUNCTION__);
    
    /* good input */
    good = setup(2, "FD 20");
    insert_line(good, "FD A");
    
    /* bad varnum */
    b_varnum = setup(1, "FD AB");
    /* bad instruction */
    b_inst = setup(1, "RT 20");
    /* test chk_inst error checking */
    b_chk_inst = setup(1, "FD");
    
    ret = fd(good);
    mu_assert("error, ret != 0", ret == 0);
    good->counter = good->counter + 1;
    /* set the variable */
    set_var("A", good->vars, 30.0);
    ret = fd(good);
    mu_assert("error, ret != 0", ret == 0);
    tear_down(good);
    
    /* expect postscript and test the output file */
    char str[STR_LENGTH] = "";
    char tmp[LINE_LENGTH];
    sprintf(tmp, "%.2f 0 rlineto\n", 20 * LOGO2PS_FACTOR);
    strcat(str, tmp);
    sprintf(tmp, "%.2f 0 rlineto\n", 30 * LOGO2PS_FACTOR);
    strcat(str, tmp);
    buffer = get_content(TEST_OUT);
    mu_assert("error, TEST_OUT is not as expected", 
              strcmp(buffer, str) == 0);
    free(buffer);
    
    ret = fd(b_varnum);
    mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR);
    tear_down(b_varnum);
    ret = fd(b_inst);
    mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR);
    tear_down(b_inst);
    ret = fd(b_chk_inst);
    mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR);
    tear_down(b_chk_inst);
    
    return 0;
}
Exemplo n.º 25
0
/**
 * \brief Create all bonus components.
 */
void ptb::frame_play_story::create_bonus_component()
{
  m_bonus =
    new bear::gui::horizontal_flow(3, 3, bear::visual::color_type("e50f0f"));
  get_content().insert( m_bonus );

  m_bonus->set_background_color(PTB_THEME_FACE);
  set_borders_down(*m_bonus);
  insert_control( *m_bonus );

  m_bonus_text = new bear::gui::static_text(get_font());
  insert( m_bonus_text );
  m_bonus_text->set_background_color(PTB_THEME_FACE);
  set_borders_down(*m_bonus_text);
} // frame_play_story::create_bonus_component()
Exemplo n.º 26
0
/**
 * \brief The focus has been set on the frame or one of its children.
 */
void ptb::frame::on_focused()
{
  const bear::gui::visual_component* c(get_content().get_focus());
  std::size_t i(0);
  bool stop(false);

  while ( !stop && (i!=m_controls.size()) )
    if ( m_controls[i] == c )
      stop = true;
    else
      ++i;

  if ( i!=m_current_control )
    switch_to_control(i);
} // frame::on_focus_on()
Exemplo n.º 27
0
bool NoteOfTheDay::has_changed(const gnote::Note::Ptr & note)
{
  const sharp::DateTime & date_time = note->create_date();
  const std::string original_xml
    = get_content(Glib::Date(
                    date_time.day(),
                    static_cast<Glib::Date::Month>(date_time.month()),
                    date_time.year()),
                  note->manager());

  return get_content_without_title(note->text_content())
           == get_content_without_title(
                gnote::utils::XmlDecoder::decode(original_xml))
         ? false
         : true;
}
Exemplo n.º 28
0
static mrb_value
hdb_check_key(mrb_state *mrb, mrb_value self)
{
  hdb_context *context = DATA_PTR(self);
  void *kbuf;
  int ksize;
  mrb_int kint;
  mrb_value key;

  mrb_get_args(mrb, "o", &key);

  if (!get_content(key, &kint, &kbuf, &ksize)) {
    return mrb_nil_value();
  }

  return mrb_bool_value(tchdbvsiz(context->hdb, kbuf, ksize) >= 0);
}
Exemplo n.º 29
0
static PyObject *xhttp(PyObject *self, PyObject *args)
{
	char *content = NULL;
	char *appid;
	char *secret_key;
	char *q;
	char *from;
	char *to;
	if(!PyArg_ParseTuple(args, "s|ssss", &appid, &secret_key, &q, &from, &to))
	{
		return NULL;
	}
	get_content(appid, secret_key, q, from, to, &content);
	
	return Py_BuildValue("s", content);
	if(content) free(content);
}
Exemplo n.º 30
0
static void update_leds(void) {
	// only display something with a valid clock content
	uint8_t on = (clock.state == VALID);
	uint8_t p = on ? (cycle_position() + GLOBAL_OFFSET)%(CYCLE_POS_CNT) : 0;
	// handle any daughter boards
	for (uint8_t i=0; i<ELEMS(daughters); i++) {
		uint8_t content = on ? get_content((p+daughters[i].offset)%CYCLE_POS_CNT) : 0;
		// invert the bitmask since LED are activated on LOW ports.
		if (daughters[i].shift) {
			shift_out(~content);
		} else {
			// directly connected
			LED_PORT = ~content;
		}
	}
	// activate the daughter board LEDs
	trigger_latch();
}