void playlist_display (int argc, char * * argv) { int entries = get_playlist_length (); fauxdtool_report ("%d track%s.", entries, entries != 1 ? "s" : ""); int total = 0; for (int entry = 0; entry < entries; entry ++) { char * title = get_entry_title (entry); int length = get_entry_length (entry) / 1000; total += length; /* adjust width for multi byte characters */ int column = 60; for (const char * p = title; * p; p = g_utf8_next_char (p)) { int stride = g_utf8_next_char (p) - p; if (g_unichar_iswide (g_utf8_get_char (p)) || g_unichar_iswide_cjk (g_utf8_get_char (p))) column += (stride - 2); else column += (stride - 1); } char * fmt = g_strdup_printf ("%%4d | %%-%ds | %%d:%%.2d", column); fauxdtool_report (fmt, entry + 1, title, length / 60, length % 60); g_free (fmt); g_free (title); } fauxdtool_report ("Total length: %d:%.2d", total / 60, total % 60); }
static int address_to_data(entry_ptr_t ent) { int length; int offset; int son = get_digits(*(ent->data->number))+1; int soz = get_digits(*(ent->data->zipcode))+1; char nr[son]; char zip[soz]; offset = 5*(strlen(DATA_SEPARATOR)) + strlen(DATA_END); length = get_entry_length(ent) + offset; char line[length]; _dbgmsg("reserved %i characters for the line", length); strcpy(line, ent->data->firstname); strcat(line, DATA_SEPARATOR); strcat(line, ent->data->lastname); strcat(line, DATA_SEPARATOR); strcat(line, ent->data->street); strcat(line, DATA_SEPARATOR); sprintf(nr, "%i", *(ent->data->number)); strcat(line, nr); strcat(line, DATA_SEPARATOR); sprintf(zip, "%i", *(ent->data->zipcode)); strcat(line, zip); strcat(line, DATA_SEPARATOR); strcat(line, ent->data->city); strcat(line, DATA_END); _dbgmsg("created line \"%s\"", line); write_address(line); return 0; }
void playqueue_display (int argc, char * * argv) { int qlength = get_queue_length (); audtool_report ("%d queued tracks.", qlength); int total = 0; for (int qpos = 0; qpos < qlength; qpos ++) { int pos = get_queue_entry (qpos); char * title = get_entry_title (pos); int length = get_entry_length (pos) / 1000; total += length; /* adjust width for multi byte characters */ int column = 60; for (const char * p = title; * p; p = g_utf8_next_char (p)) { int stride = g_utf8_next_char (p) - p; if (g_unichar_iswide (g_utf8_get_char (p)) || g_unichar_iswide_cjk (g_utf8_get_char (p))) column += (stride - 2); else column += (stride - 1); } char * fmt = g_strdup_printf ("%%4d | %%4d | %%-%ds | %%d:%%.2d", column); audtool_report (fmt, qpos + 1, pos + 1, title, length / 60, length % 60); g_free (fmt); } audtool_report ("Total length: %d:%.2d", total / 60, total % 60); }
void playlist_song_length_frames (int argc, char * * argv) { int pos = check_args_playlist_pos (argc, argv); int length = get_entry_length (pos - 1); fauxdtool_report ("%d", length); }
void playlist_song_length (int argc, char * * argv) { int pos = check_args_playlist_pos (argc, argv); int length = get_entry_length (pos - 1) / 1000; fauxdtool_report ("%d:%.2d", length / 60, length % 60); }