aboutsummaryrefslogblamecommitdiffstats
path: root/libidc.c
blob: 0c25e07f9c1d25b41f774eebdd50007cc67ad965 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                                          
                


















































                                                                                                  
                      



                                          

                                                                    





                                                               
                                                                                                                   
                                                    
                           

                                             
                   
                   









                                                                                                                       
                 




                                                                            










                                                                                   
            

















                                           
                   
               
                
                
                
                

                         






                                                                                                   

                                                                                                    
                                                                                   
                                          
                     
                     
                   
               
                                                   

                                   
                       
                                                                                       
                           

                                                                                      

                                        



                                                   
       
     
                           
                                                                     


                      
                                                         

                                                                                                       
                                                                                                                 


                                               



                                 

                                               

                 
                                                    
                                                                      





                                                                          
                                                 

                                                                                                                                      
                                             
                                                

                                                  
                                                                                                    

                                                                                                                                    


                    
                                                                      
                  
                                                                  
                                  

                                                                                          
                

                                                                                    
                   
         

                         
       

                                                                           
                         



                                                       
       



                                                                                                





                            
                                                                   

                                                                         
                                                                                   
                                                    
                                                                                    


                                                                     



                                                                                                    



                                                                                                               
         


                                                 






















































                                                                    
//what data type to use for storing all of the shit?
//hashtable with hash == fd?

//should I use FILE *, or fd, or write functions for both?

#define _GNU_SOURCE //I want memmem out of string.h
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>

//#define CHUNK 4096
#include "idc.h"

#define TSIZE 65536

/* might not put this function in here... or maybe I will, but not use it.
char *read_line_hack(FILE *fp,int len) {
 short in;
 char *t;
 errno=0;
 switch(in=fgetc(fp)) {
  case '\n':
   t=malloc(len+1);
   t[len]=0;
   return t;
  case -1:
   if(errno == EAGAIN) return 0;
   if(feof(fp)) {
    fprintf(stderr,"# reached EOF. exiting.\n");
    exit(0);
   }
   fprintf(stderr,"# some other error happened while reading. %d %d\n",EAGAIN,errno);
   perror("hackvr");
   exit(1);
  default: //we need to check the last strlen(delim) bytes for delim to indicate end of line-read.
   if((t=read_line_hack(fp,len+1))) t[len]=in;
   break;
 }
 return t;
}
*/


/* in line.h
struct shit {
  //I need to choose which of these two.
  //FILE *fp;
  int fd;
  char *backlog;
  int blsize;
  int bllen;
  char buffer[CHUNK];//THIS IS *NOT* NULL TERMINATED.

  char *delim;
  //other stuffs?
//  union {
  void (*line_handler)(struct shit *me,char *line);//function pointer to the handler. ???
//    (void *line_handler_fd)(int fd,char *)
//  };//???
  void *extra_info;//extra info that I don't care to name atm
};
*/

struct idc_global idc;

int update_shits() {
  //loop over all shits and find the maxfd
  int i;
  for