<commit_before>/***************************************************************
 *
 * Copyright (C) 1990-2007, Condor Team, Computer Sciences Department,
 * University of Wisconsin-Madison, WI.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you
 * may not use this file except in compliance with the License.  You may
 * obtain a copy of the License at
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ***************************************************************/


#include "condor_common.h"
#include "condor_debug.h"
#include "fileinfo2.h"
#include "network2.h"
#include "gen_lib.h"
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;

FileInformation::FileInformation()
{
  head = NULL;
  tail = NULL;
  num_files = 0;
}


FileInformation::~FileInformation()
{
  DeleteFileInfo();
}


void FileInformation::DeleteFileInfo()
{
  file_info_node* p;
  file_info_node* trail;

  p = head;
  while (p != NULL)
    {
      trail = p;
      p = p->next;
      delete trail;
      num_files--;
    }
  head = NULL;
  tail = NULL;
}


int FileInformation::RemoveFileInfo(file_info_node* d_ptr)
{
	if (d_ptr) {
		if ((head == d_ptr) && (tail == d_ptr)) {
			head = NULL;
			tail = NULL;
        } else if (head == d_ptr) {
			head = head->next;
			head->prev = NULL;
        } else if (tail == d_ptr) {
			tail = tail->prev;
			tail->next = NULL;
        } else {
			d_ptr->prev->next = d_ptr->next;
			d_ptr->next->prev = d_ptr->prev;
        }
		delete d_ptr;
    }
	num_files--;
	return (REMOVED_FILE);
}


file_info_node* FileInformation::AddFileInfo(struct in_addr machine_IP,
					     const char*    owner_name,
					     const char*    file_name,
					     u_lint         file_size,
					     file_state     state,
					     time_t*        last_modified_ptr)
{
  file_info_node* n;
  char*           temp_name;

  n = new file_info_node;
  if (n == NULL)
    {
	  dprintf(D_ALWAYS, 
			  "ERROR: unable to allocate memory for the file information\n");
      exit(DYNAMIC_ALLOCATION);
    }
  memcpy((char*) &n->data.machine_IP, &machine_IP, sizeof(struct in_addr));
  temp_name = GetIPName(machine_IP);
  strncpy(n->data.machine_IP_name, temp_name, MAX_MACHINE_NAME_LENGTH);
  strncpy(n->data.owner_name, owner_name, MAX_NAME_LENGTH);
  strncpy(n->data.file_name, file_name, MAX_CONDOR_FILENAME_LENGTH);
  n->data.size = file_size;
  n->data.last_modified_time = time(NULL);
  n->data.state = state;
  n->next = NULL;
  if (head == NULL)
    {
      head = n;
      tail = n;
      n->prev = NULL;<commit_msg>Fix constipation problem with #2584<commit_after>/***************************************************************
 *
 * Copyright (C) 1990-2007, Condor Team, Computer Sciences Department,
 * University of Wisconsin-Madison, WI.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you
 * may not use this file except in compliance with the License.  You may
 * obtain a copy of the License at
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ***************************************************************/


#include "condor_common.h"
#include "condor_debug.h"
#include "fileinfo2.h"
#include "network2.h"
#include "gen_lib.h"
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;

FileInformation::FileInformation()
{
  head = NULL;
  tail = NULL;
  num_files = 0;
}


FileInformation::~FileInformation()
{
  DeleteFileInfo();
}


void FileInformation::DeleteFileInfo()
{
  file_info_node* p;
  file_info_node* trail;

  p = head;
  while (p != NULL)
    {
      trail = p;
      p = p->next;
      delete trail;
      num_files--;
    }
  head = NULL;
  tail = NULL;
}


int FileInformation::RemoveFileInfo(file_info_node* d_ptr)
{
	if (d_ptr) {
		if ((head == d_ptr) && (tail == d_ptr)) {
			head = NULL;
			tail = NULL;
        } else if (head == d_ptr) {
			head = head->next;
			head->prev = NULL;
        } else if (tail == d_ptr) {
			tail = tail->prev;
			tail->next = NULL;
        } else {
			d_ptr->prev->next = d_ptr->next;
			d_ptr->next->prev = d_ptr->prev;
        }
		delete d_ptr;
    }
	num_files--;
	return (REMOVED_FILE);
}


file_info_node* FileInformation::AddFileInfo(struct in_addr machine_IP,
					     const char*    owner_name,
					     const char*    file_name,
					     u_lint         file_size,
					     file_state     state,
					     time_t*        last_modified_ptr)
{
  file_info_node* n;
  const char*           temp_name;

  n = new file_info_node;
  if (n == NULL)
    {
	  dprintf(D_ALWAYS, 
			  "ERROR: unable to allocate memory for the file information\n");
      exit(DYNAMIC_ALLOCATION);
    }
  memcpy((char*) &n->data.machine_IP, &machine_IP, sizeof(struct in_addr));
  temp_name = GetIPName(machine_IP);
  strncpy(n->data.machine_IP_name, temp_name, MAX_MACHINE_NAME_LENGTH);
  strncpy(n->data.owner_name, owner_name, MAX_NAME_LENGTH);
  strncpy(n->data.file_name, file_name, MAX_CONDOR_FILENAME_LENGTH);
  n->data.size = file_size;
  n->data.last_modified_time = time(NULL);
  n->data.state = state;
  n->next = NULL;
  if (head == NULL)
    {
      head = n;
      tail = n;
      n->prev = NULL;
{'fraction_non_alphanumeric': 0.15819306080384749, 'fraction_numerical': 0.005839917554105119, 'mean_word_length': 3.189208633093525, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4722610', 'n_tokens_mistral': 2054, 'n_tokens_neox': 1911, 'n_words': 506}