diff options
author | rafa_99 <raroma09@gmail.com> | 2021-08-30 14:38:01 +0100 |
---|---|---|
committer | rafa_99 <raroma09@gmail.com> | 2021-08-30 14:38:01 +0100 |
commit | b731bcbf8eada98e647b3d7a5944f65cba78edb7 (patch) | |
tree | cf8e0ce5f4c52e46e971acbd4857c2ca038b83df /video.c |
Initial development of queryt files
Diffstat (limited to 'video.c')
-rw-r--r-- | video.c | 49 |
1 files changed, 49 insertions, 0 deletions
@@ -0,0 +1,49 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "video.h" + +Video createVideo(char *title, char *author, char *id, char *description, time_t duration) +{ + Video video; + + if (title != NULL && strlen(title) > 0) + { + video.title = (char *) calloc(TITLE + 1, sizeof(char)); + strcpy(video.title, title); + } + + if (author != NULL && strlen(author) > 0) + { + video.author = (char *) calloc(AUTHOR + 1, sizeof(char)); + strcpy(video.author, author); + } + + if (id != NULL && strlen(id) > 0) + { + video.id = (char *) calloc(VIDEOID + 1, sizeof(char)); + strcpy(video.id, id); + } + + if (description != NULL && strlen(description) > 0) + { + video.description = (char *) calloc(DESCRIPTION + 1, sizeof(char)); + strcpy(video.description, description); + } + else + { + video.description = (char *) calloc(1, sizeof(char)); + } + + video.duration = duration; + + return video; +} + +void freeVideo(Video *v) +{ + free(v->title); + free(v->author); + free(v->id); + free(v->description); +} |