Changeset 7372

Show
Ignore:
Timestamp:
02/20/07 00:50:24 (23 months ago)
Author:
BradNeuberg
Message:

Implementing C-based offline cache

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/dot/proxy/off.c

    r7369 r7372  
    6262                loadOfflineList(); 
    6363        } 
     64         
     65        addOfflineHost("bradneuberg.name"); 
     66        printf("Is new site offline: %d\n", isHostAvailableOffline("bradneuberg.name")); 
     67        fflush(stdout); 
     68        saveOfflineList(); 
    6469} 
    6570 
     
    7075int addOfflineHost(char host[]){ 
    7176        struct offline_list_entry *entry_ptr; 
     77        struct offline_list_entry *new_entry_ptr; 
    7278         
    7379        if(isHostAvailableOffline(host) == 1){ 
     
    7783         
    7884        /* instantiate an entry for this host */ 
    79         entry_ptr = (struct offline_list_entry *) 
     85        new_entry_ptr = (struct offline_list_entry *) 
    8086                                        malloc(sizeof(struct offline_list_entry)); 
    81         if(entry_ptr == NULL){ 
     87        if(new_entry_ptr == NULL){ 
    8288                do_log(L_ERROR, "No memory"); 
    8389                return 0; 
    8490        } 
    85         entry_ptr->host_ptr = (char *)malloc((unsigned) (strlen(host) + 1)); 
    86         if(entry_ptr->host_ptr == NULL){ 
     91        new_entry_ptr->host_ptr = (char *)malloc((unsigned) (strlen(host) + 1)); 
     92        if(new_entry_ptr->host_ptr == NULL){ 
    8793                do_log(L_ERROR, "No memory"); 
    8894                return 0; 
    8995        } 
    90         memcpy(entry_ptr->host_ptr, host, strlen(host) + 1); 
    91         entry_ptr->next_ptr = NULL; 
     96        memcpy(new_entry_ptr->host_ptr, host, strlen(host) + 1); 
     97        new_entry_ptr->next_ptr = NULL; 
    9298         
    9399        /* add it in the right place */ 
    94100        if(offline_list_ptr == NULL){ 
    95                 offline_list_ptr = entry_ptr; 
     101                offline_list_ptr = new_entry_ptr; 
    96102        }else{ 
    97103                /* shuffle along the list until we get to the end */ 
     
    100106                        entry_ptr = entry_ptr->next_ptr; 
    101107                } 
    102                 entry_ptr->next_ptr = entry_ptr; 
    103         } 
     108                entry_ptr->next_ptr = new_entry_ptr; 
     109        } 
     110         
     111        return 1; /* success */ 
    104112} 
    105113