summaryrefslogblamecommitdiffstats
path: root/friendfinder/read_file.c
blob: b8e7fbbd3c2da6ea645bf5a6ce930deff0fea9ef (plain) (tree)
1
2
3
4
5
6
7
8
9

                   

                      
 
                           
 

                     

                        


                                                                                        
                  
 
                                      
 










                                                                     
                                                  


                            
                            
                                    
 
                    


                                                                                        
                    
  




                                    
 










                                                                        
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "read_file.h"

struct key_data* read_key()
{
	FILE *fr;    
        
   	int key_value;
	char key_string;

	struct key_data *keyd = (struct key_data*) malloc(sizeof(struct key_data));
   	keyd->key = (char*) malloc(sizeof(char) * 300);  //supports max keylength of 300
	int i = 0;

   	fr = fopen ("key.pem", "rt"); 

	if (fr == NULL)
	{
		printf("READ_FILE: key could not have been read \n");
		return NULL;
	}	
	
	if (fr != NULL)
	{
		while((key_value = fgetc(fr)) != EOF)
		{
			key_string = (char) key_value;
			keyd->key[i] = key_string;
			i++;
		}	
	}
	keyd->key[i] = '\0';
	keyd->key_length = i;// - 1;

   	fclose(fr); 
	
	//printf("keyd->key %s :: keyd->key_length %i \n", keyd->key, keyd->key_length);
	
	return keyd;
} 
/*
void write_png(DmtxImage *img)
{
	FILE *fw;  
 	fw = fopen("file.txt", "w");

	if (fw == NULL)
	{
		printf("READ_FILE: image could not have been wrote \n");
		return;
	}
	
	if (fw != NULL)
		{
			
		}
}*/