Seng 265 — Introduction to Software Engineering Fall 2001 Assignment No
Total Page:16
File Type:pdf, Size:1020Kb
SEng 265 — Introduction to Software Engineering Fall 2001 Assignment No. 4 Note 1 This assignment is to be done individually. Note 2 Your assignment will be tested on aserver. Due date: Nov. 16, 2001, at the beginning of the class. This assignment is worth 20 points. This assignment is worth 8% of your total course mark. Clearly mark your lab section and student number on all submissions. Objectives After completing this assignment, you will have: learned the basics of perl and regular expressions. Introduction I have a large library of mp3s on one of my linux boxes. Because I am the retentive type of person, I organize them in the following way: For each band I create a directory whose name is the name of the band. Inside this directory I create one directory per each album that the band has released. The name of the directory starts with the year (4 digits number) in which it was released. Finally, inside each album directory, I name each mp3 file with the number of the song in the album, and its title. For example, the albums Boy (1980) of U2, and The Bends (1995) of Radiohead correspond to: U2/1980_Boy/04_Into_the_Heart.mp3 U2/1980_Boy/01_I_will_follow.mp3 U2/1980_Boy/02_Twilight.mp3 U2/1980_Boy/03_An_Cat_Dubh.mp3 U2/1980_Boy/06_Stories_for_Boys_2.mp3 U2/1980_Boy/05_Out_of_Control_2.mp3 U2/1980_Boy/08_A_Day_without_Me.mp3 U2/1980_Boy/07_The_Ocean_2.mp3 U2/1980_Boy/09_Another_Time_Another_Place.mp3 U2/1980_Boy/10_Electric_Co_2.mp3 U2/1980_Boy/11_Shadows_and_Tall_Trees_2.mp3 Radiohead/1995_The_Bends/10_Black_Star.mp3 Radiohead/1995_The_Bends/08_MyIron_Lung.mp3 Radiohead/1995_The_Bends/04_Fake_Plastic_Trees.mp3 Radiohead/1995_The_Bends/05_Bones.mp3 Radiohead/1995_The_Bends/13_Killer_Cars.mp3 Radiohead/1995_The_Bends/03_High_and_Dry.mp3 Radiohead/1995_The_Bends/14_How_Can_You_Be_Sure.mp3 1 Radiohead/1995_The_Bends/01_Planet_Telex.mp3 Radiohead/1995_The_Bends/02_The_Bends.mp3 Radiohead/1995_The_Bends/07_Just.mp3 Radiohead/1995_The_Bends/11_Sulk.mp3 Radiohead/1995_The_Bends/06_Nice_Dream.mp3 Radiohead/1995_The_Bends/09_Bullet_Proof_I_Wish.mp3 Radiohead/1995_The_Bends/12_Street_Spirit.mp3 My collection is getting to the point where it is difficult to find what I want to play. For example, I’d like to say: show me all the songs from 1995. Or show me all the songs by Pink Floyd in the 90’s. Or show me all the songs that include woman and women in their title. Your task, should you choose to accept it I want you to write the command: abbey road. This is its man page: abbey_road(1) NAME abbey_road - search for songs in a collection of mp3s SYNOPSIS abbey_road [OPTIONS]... filename [PATTERN] DESCRIPTION Search for PATTERN in the title of a song in a collection of mp3 filenames of the format: <Band>/<Year>_<Album Name>/<Song Number>_<Title>.mp3 filename file that contains the mp3s filenames. PATTERN PATTERN is an optional valid perl regular expression. abbey_road will search for that pattern in the names of all the songs in the file. For example: You can search for ’wi[a-z]h’ (wi followed by any character, followed by h) and expect as output: U2/1980_Boy/08_A_Day_without_Me.mp3 Radiohead/1995_The_Bends/09_Bullet_Proof_I_Wish.mp3 OPTIONS --casesensitive By default abbey_road is case insensitive. This option forces the search to be case sensitive. --band=PATTERN restric the search to the bands that match PATTERN 2 only. --band=’ˆu’ will search in bands whose name starts with a U (like U2). --band=who will restrict the search to bands that include ’who’ in their title: Guess Who, The Who. --album=PATTERN restric the search to albums that match PATTERN only. --album=boy will search only songs from albums that include the string boy in their title --year=PATTERN restric the search to years that match PATTERN only. --year=’199[5-7]’ will search only songs of albums that were released between 1995 and 1997. --songnumber=NUMBER search only for a song which is number NUMBER in the album. --song=3 will search only for the third song in an album. NOTES: Abbey_road does not read anything from standard input and writes its output to standard output. At the end it prints to standard error the number of matching songs, e.g.: End of search. 1 song(s) matching. Or: End of search. No songs matching. The search should be case insensitive unless otherwise specified. Inside the mp3s collection file, underscores (_) are used instead of spaces. abbey_road takes this into account. For instance: abbey_road --album=’the bends’ ’planet telex’ should output: Radiohead/1995_The_Bends/01_Planet_Telex.mp3 EXAMPLES: What is the fifth song of the album Boy: abbey_road --album=’ˆBoy$’ --number=5 my_mp3s.txt U2/1980_Boy/05_Out_of_Control_2.mp3 3 What songs were released in the 90’s whose title include the string ’be’: abbey_road --year=’199[0-9]’ my_mp3s.txt be Radiohead/1995_The_Bends/14_How_Can_You_Be_Sure.mp3 Radiohead/1995_The_Bends/02_The_Bends.mp3 AUTHOR Written by you. REPORTING BUGS Report bugs to <[email protected]>. COPYRIGHT Copyright 2001 Your Name Implementation Notes The same option cannot appear more than once in the same command line. For instance, you cannot say: abbey_road --album=’ˆBad$’ --number=3 --number=5 my_mp3s.txt There are no restrictions on how to implement this command but you should use a reasonable amount of memory and CPU (less than 100 Mbytes to scan a 1000 songs file, and terminate within few seconds, for instance). Your program can safely assume that all the input conforms to the expected format. You should follow our C coding standards (where applicable). Any disparity or question will be resolved in the bulletin board. You can find an example of an mp3 songs file from /home/seng265/assign4/mp3s.txt What to submit Submit your source code (abbey road) via CVS (see assignment 2) in the src directory of your module At the start of the class on the deadline, hand in a printed copy of your cvs commit script as well as a hard copy of your source code file. Remember, no line in your source code should exceed 80 characters long! and this assignment is to be done individually. 4.