Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Publication get_publication(char* command)
- {
- char *authorsStr = NULL, *idsStr = NULL;
- Publication p = malloc(sizeof(Publication));
- List author = NULL, bibliography = NULL;
- if(p == NULL)
- {
- printf("Allocation error\n");
- exit(-1);
- }
- command += 2;
- p->position = position_from_str_to_int(trim(strtok(command, "|")));
- p->id = trim(strtok(NULL, "|"));
- p->title = trim(strtok(NULL, "|"));
- authorsStr = strtok(NULL, "|");
- idsStr = strtok(NULL, "|");
- authorsStr = strtok(authorsStr, "&");
- while(authorsStr != NULL)
- {
- authorsStr = trim(authorsStr);
- author = add_to_list(author, authorsStr);
- authorsStr = strtok(NULL, "&");
- }
- idsStr = strtok(idsStr, "&");
- while(idsStr != NULL)
- {
- idsStr = trim(idsStr);
- bibliography = add_to_list(bibliography, idsStr);
- idsStr = strtok(NULL, "&");
- }
- p->authors = author;
- p->bibliography = bibliography;
- printf("%d\n", p->position);
- printf("%s\n", p->id);
- printf("%s\n", p->title);
- printf("%s\n", p->authors->value);
- printf("%s\n", p->authors->next->value);
- printf("%s\n", p->bibliography->value);
- printf("%s\n", p->bibliography->next->value);
- return p;
- }
Add Comment
Please, Sign In to add comment