summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/utils.c48
-rw-r--r--src/video.c49
2 files changed, 49 insertions, 48 deletions
diff --git a/src/utils.c b/src/utils.c
index d625fed..5391e6d 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -207,51 +207,3 @@ checkNumber (char *num)
return number;
}
-
-void
-printVideoInfo (char *format, Video *videos, int numberOfVideos)
-{
- if (format != NULL && strlen (format) > 0)
- {
- for (int i = 0; i < numberOfVideos; i++)
- {
- for (int j = 0; j < strlen (format); j++)
- {
- switch (format[j])
- {
- case 'a':
- printf ("%s", videos[i].author);
- break;
- case 'd':
- printf ("%s", videos[i].duration);
- break;
- case 'i':
- printf ("%s", videos[i].id);
- break;
- case 't':
- printf ("%s", videos[i].title);
- break;
- case 'R':
- printf ("\n");
- break;
- case 'T':
- printf ("\t");
- break;
- default:
- if (!isalpha (format[j]))
- {
- printf ("%c", format[j]);
- }
- }
- }
- printf ("\n");
- }
- }
- else
- {
- for (int i = 0; i < numberOfVideos; i++)
- {
- printf ("%s\t%s\n", videos[i].id, videos[i].title);
- }
- }
-}
diff --git a/src/video.c b/src/video.c
index 0e09437..e48245b 100644
--- a/src/video.c
+++ b/src/video.c
@@ -1,4 +1,5 @@
#include "../include/video.h"
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -36,6 +37,54 @@ createVideo (char *title, char *author, char *id, char *duration)
}
void
+printVideo (char *format, Video *videos, int numberOfVideos)
+{
+ if (format != NULL && strlen (format) > 0)
+ {
+ for (int i = 0; i < numberOfVideos; i++)
+ {
+ for (int j = 0; j < strlen (format); j++)
+ {
+ switch (format[j])
+ {
+ case 'a':
+ printf ("%s", videos[i].author);
+ break;
+ case 'd':
+ printf ("%s", videos[i].duration);
+ break;
+ case 'i':
+ printf ("%s", videos[i].id);
+ break;
+ case 't':
+ printf ("%s", videos[i].title);
+ break;
+ case 'R':
+ printf ("\n");
+ break;
+ case 'T':
+ printf ("\t");
+ break;
+ default:
+ if (!isalpha (format[j]))
+ {
+ printf ("%c", format[j]);
+ }
+ }
+ }
+ printf ("\n");
+ }
+ }
+ else
+ {
+ for (int i = 0; i < numberOfVideos; i++)
+ {
+ printf ("%s\t%s\n", videos[i].id, videos[i].title);
+ }
+ }
+}
+
+void
freeVideo (Video *v)
{
free (v->title);