Plan 9 from Bell Labs’s /usr/web/sources/contrib/axel/music/mp3tag/mp3tag.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <u.h>
#include <libc.h>
#include "mp3tag.h"

void
usage(char* s)
{
	fprint(2, "mp3tag: %s\n", s);
	fprint(2, "usage: mp3tag file\n");
	exits("usage");
}

void
printidv1(Idv1* idv1)
{
	print("title:   %s\n", idv1->title);
	print("artist:  %s\n", idv1->artist);
	print("album:   %s\n", idv1->album);
	if(idv1->year[0])
		print("year:    %s\n", idv1->year);
	if(idv1->track > 0)
		print("track:   %d\n", idv1->track);
	if(idv1->genre[0])
		print("genre:   %s\n", idv1->genre);
	if(idv1->comment[0])
		print("comment: %s\n", idv1->comment);
}

void
main(int argc, char* argv[])
{
	Idv1 idv1;
	char* err;

	ARGBEGIN {
	default:
		usage(smprint("unknown option: %c", ARGC()));
	} ARGEND

	if(argc != 1)
		usage("need exactly one argument");

	err = readidv1(argv[0], &idv1);
	if(err && strcmp(err, "no tag") == 0) {
		exits(nil);
	} else if (err) {
		fprint(2, "mp3tag: %s: %s\n", argv[0], err);
		exits("readidv1");
	}

	printidv1(&idv1);

	exits(nil);
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.