1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#include <stdio.h>
/* This function fucking sucks and should use something else. I'll
* have to rewrite this shit function some day. But for now, it will
* do the job.
* TODO: Check for errors
*/
/* Be aware with buffer overflows, fscanf() */
int
get_tokens_from_file(char *filename, char *instance, char *client_id,
char *client_secret, char *access_token)
{
FILE *fp = fopen(filename,"r");
if(fp == NULL)
return -1;
fscanf(fp,"instance=%s\n",instance);
fscanf(fp,"client_id=%s\n",client_id);
fscanf(fp,"client_secret=%s\n",client_secret);
fscanf(fp,"access_token=%s\n",access_token);
return 0;
}
|