<commit_before>/*
 *
 * Copyright (c) 2014 <NAME>.
 *
 * This library is free software; 
 * you can redistribute it and/or modify
 * it under the terms of the MIT license. 
 * See COPYING for details.
 *
 */

#ifndef _STDIO_H_
#include <stdio.h>
#endif

#ifndef _STDLIB_H_
#include <stdlib.h>
#endif

#ifndef _STDBOOL_H_
#include <stdbool.h>
#endif

#ifndef _STRING_H_
#include <string.h>
#endif

#ifndef __CURL_CURL_H
#include <curl/curl.h>
#endif

#include "error_desc.h"
#include "http_methods.h"
#include "oauth.h"

void
initDir() {
        dir = realloc(dir, strlen(strcat(getenv("HOME"), "/.tweet")) + 1);
        dir = strcat(getenv("HOME"), "/.tweet");
}

/*** Functions for getting Twitter credentials from file ***/
char *
getConsumerKey() {
        char *buff = malloc(50*sizeof(char));
printf("%s\n", strcat(dir, "/consumerkey"));
	FILE *fp = fopen(strcat(getenv("HOME"), "/.tweet/consumerkey"), "r");
	if (fp == NULL) {
	 	perror("Read Error:");
	}
        else {
	        fscanf(fp, "%s", buff);
	        //printf("%s\n", buff);
	        fclose(fp);
        }
	return buff;
}
char *
getConsumerSecret() {
        char *buff = malloc(50*sizeof(char));
printf("%s\n", strcat(dir, "/consumersecret"));
        FILE *fp = fopen(strcat(getenv("HOME"), "/.tweet/consumersecret"), "r");
        if (fp == NULL) {
                perror("Read Error:");
        }
        else {
                fscanf(fp, "%s", buff);
                //printf("%s\n", buff);
                fclose(fp);
        }
        return buff;
}
char *
getUserToken() {
        char *buff = malloc(50*sizeof(char));
printf("%s\n", strcat(dir, "/usertoken"));
        FILE *fp = fopen(strcat(getenv("HOME"), "/.tweet/usertoken"), "r");
        if (fp == NULL) {
                perror("Read Error:");
        }
        else {
                fscanf(fp, "%s", buff);
                //printf("%s\n", buff);
                fclose(fp);
        }
        return buff;
}
char *
getUserSecret() {
        char *buff = malloc(50*sizeof(char));
printf("%s\n", strcat(dir, "/usersecret"));
        FILE *fp = fopen(strcat(getenv("HOME"), "/.tweet/usersecret"), "r");
        if (fp == NULL) {
                perror("Read Error:");
        }<commit_msg>Working initDir function, memory hack?<commit_after>/*
 *
 * Copyright (c) 2014 <NAME>.
 *
 * This library is free software; 
 * you can redistribute it and/or modify
 * it under the terms of the MIT license. 
 * See COPYING for details.
 *
 */

#ifndef _STDIO_H_
#include <stdio.h>
#endif

#ifndef _STDLIB_H_
#include <stdlib.h>
#endif

#ifndef _STDBOOL_H_
#include <stdbool.h>
#endif

#ifndef _STRING_H_
#include <string.h>
#endif

#ifndef __CURL_CURL_H
#include <curl/curl.h>
#endif

#include "error_desc.h"
#include "http_methods.h"
#include "oauth.h"

void
initDir() {
        dir = realloc(dir, strlen(strcat(getenv("HOME"), "/.tweet")) + 1);
        dir = getenv("HOME");
}

/*** Functions for getting Twitter credentials from file ***/
char *
getConsumerKey() {
        char *buff = malloc(50*sizeof(char));

printf("%s\n", dir);
printf("%s\n", strcat(dir, "/consumerkey"));

	FILE *fp = fopen(strcat(dir, "/consumerkey"), "r");
	if (fp == NULL) {
	 	perror("Read Error:");
	}
        else {
	        fscanf(fp, "%s", buff);
	        //printf("%s\n", buff);
	        fclose(fp);
        }
	return buff;
}
char *
getConsumerSecret() {
        char *buff = malloc(50*sizeof(char));
printf("%s\n", strcat(dir, "/consumersecret"));
        FILE *fp = fopen(strcat(dir, "/consumersecret"), "r");
        if (fp == NULL) {
                perror("Read Error:");
        }
        else {
                fscanf(fp, "%s", buff);
                //printf("%s\n", buff);
                fclose(fp);
        }
        return buff;
}
char *
getUserToken() {
        char *buff = malloc(50*sizeof(char));
printf("%s\n", strcat(dir, "/usertoken"));
        FILE *fp = fopen(strcat(dir, "/usertoken"), "r");
        if (fp == NULL) {
                perror("Read Error:");
        }
        else {
                fscanf(fp, "%s", buff);
                //printf("%s\n", buff);
                fclose(fp);
        }
        return buff;
}
char *
getUserSecret() {
        char *buff = malloc(50*sizeof(char));
printf("%s\n", strcat(dir, "/usersecret"));
        FILE *fp = fopen(strcat(dir, "/usersecret"), "r");
        if (fp == NULL) {
                perror("Read Error:");
        }
{'fraction_non_alphanumeric': 0.18510106745400864, 'fraction_numerical': 0.0059050647285941405, 'mean_word_length': 2.3490494296577946, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '294551', 'n_tokens_mistral': 1586, 'n_tokens_neox': 1506, 'n_words': 355}