165 lines
4.1 KiB
Markdown
165 lines
4.1 KiB
Markdown
```c
|
|
// Main
|
|
int main(int argc, char *argv[])
|
|
{
|
|
/*
|
|
// ===================================
|
|
// Example of using 'PullPostData()'
|
|
// ===================================
|
|
|
|
// Init array of six strings
|
|
// Pull data of postID '1' into 'result'
|
|
char *result[6];
|
|
PullPostData(result, 42, NULL);
|
|
|
|
// Foreach in result
|
|
for (int i = 0; i < sizeof(result)/sizeof(result[0]); i++)
|
|
{
|
|
// Print contents on a new line
|
|
printf("%s\n", result[i]);
|
|
}
|
|
|
|
// ===================================
|
|
*/
|
|
|
|
/*
|
|
// ===================================
|
|
// Example of using 'PullAuthorData()'
|
|
// ===================================
|
|
|
|
// Init array of four strings
|
|
// Pull data of authorID '1' into 'result'
|
|
char *result[4];
|
|
PullAuthorData(result, 1, NULL);
|
|
|
|
// Foreach in result
|
|
for (int i = 0; i < sizeof(result)/sizeof(result[0]); i++)
|
|
{
|
|
// Print contents on a new line
|
|
printf("%s\n", result[i]);
|
|
}
|
|
// ===================================
|
|
*/
|
|
|
|
/*
|
|
// ===================================
|
|
// Example of using 'PostIDs()'
|
|
// ===================================
|
|
|
|
// Generate array of IDs
|
|
int *postIDs;
|
|
int count1 = PostIDs(&postIDs, NULL);
|
|
|
|
// Loop until element is negative i.e. the last
|
|
for (int i = 0; i < count1; ++i)
|
|
{
|
|
// Print contents on a new line
|
|
printf("%d\n", postIDs[i]);
|
|
}
|
|
|
|
// Free the memory
|
|
free(postIDs);
|
|
|
|
// ===================================
|
|
*/
|
|
|
|
/*
|
|
// ===================================
|
|
// Example of using 'ActivePostIDs()'
|
|
// ===================================
|
|
|
|
// Generate array of IDs
|
|
int *activePostIDs;
|
|
int count2 = ActivePostIDs(&activePostIDs, NULL);
|
|
|
|
// Loop until element is negative i.e. the last
|
|
for (int i = 0; i < count2; ++i)
|
|
{
|
|
// Print contents on a new line
|
|
printf("%d\n", activePostIDs[i]);
|
|
}
|
|
|
|
// Free the memory
|
|
free(activePostIDs);
|
|
|
|
// ===================================
|
|
*/
|
|
|
|
/*
|
|
// ===================================
|
|
// Example of using 'AuthorIDs()'
|
|
// ===================================
|
|
|
|
// Generate array of IDs
|
|
int *authorIDs;
|
|
int count3 = AuthorIDs(&authorIDs, NULL);
|
|
|
|
// Loop until element is negative i.e. the last
|
|
for (int i = 0; i < count3; ++i)
|
|
{
|
|
// Print contents on a new line
|
|
printf("%d\n", authorIDs[i]);
|
|
}
|
|
|
|
// Free the memory
|
|
free(authorIDs);
|
|
|
|
// ===================================
|
|
*/
|
|
|
|
/*
|
|
// ===================================
|
|
// Example of using 'PullPostDescriptions()'
|
|
// ===================================
|
|
|
|
// Generate array of IDs
|
|
int *IDs;
|
|
int *authors;
|
|
int *dates;
|
|
char *Titles[255];
|
|
int count4 = PullPostDescriptions(&IDs, &Titles, &authors, &dates, NULL);
|
|
|
|
// Loop until element is negative i.e. the last
|
|
for (int i = 0; i < count4; ++i)
|
|
{
|
|
// Print contents on a new line
|
|
printf("%d %s %d %d\n", IDs[i], Titles[i], authors[i], dates[i]);
|
|
}
|
|
|
|
// Free the memory
|
|
free(IDs);
|
|
free(authors);
|
|
free(dates);
|
|
|
|
// ===================================
|
|
*/
|
|
|
|
// Open the connection
|
|
MYSQL *con = conn2maria();
|
|
|
|
// AddPost return the inserted rows, NULL pointer for no tags, 0 for size
|
|
//
|
|
//int tags[] = {1, 2, 3};
|
|
//printf("%d", AddPost("Something", 2, "2020-01-01", "Ssdjshdjahdkjomething", tags, sizeof(tags), con));
|
|
|
|
//AssignTag(6, 42, con);
|
|
//EditPost(69, "HEY", "THERE BUDDY", con);
|
|
//printf("%d\n", AddTag("Test", con));
|
|
//DeleteTag(7, con);
|
|
//RetractTag(1, 1, con);
|
|
//EditTag(5, "Projects", con);
|
|
//AddAuthor("Me", "Meson", "email@me.com", con);
|
|
//ChangeAuthor(93, 1, con);
|
|
//TogglePost(81, con);
|
|
//printf("%s\n", IsEnabled(81, con) ? "True" : "False");
|
|
//AddFilePost(1, "/home/adam/Documents/html/linuxenv.html", con);
|
|
//EditFilePost("/home/adam/Documents/html/linuxenv.html", 1, con);
|
|
//BlogWrite(con);
|
|
//BlogEdit(69, con);
|
|
|
|
// =================================
|
|
|
|
exit(0);
|
|
}
|
|
```
|