<commit_before>//Commands
//gcc linklist.c -o linklist
//valgrind --leak-check=yes --verbose ./linklist


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

typedef enum retVal{
	unSuccessful = -1,
	Successful = 0
};

//self referential structre
//contains at least one member which points to object of same data
//type
//linked list can grow and shrink dynamically
#define EXIT 0
//uncomment this to make debug ON.
//#define DEBUG 1

#ifdef DEBUG
#define DBG(fmt, ...) \
            do { if (DEBUG) fprintf(stdout, "%3d:: IN %s\(\) :: "fmt" \n",__LINE__,__FUNCTION__, \
                ##__VA_ARGS__); } while (0)
#else
#define DBG(fmt, ...) 
#endif

#define PR(fmt, ...) \
            do { fprintf(stdout, " %3d:: IN %s\(\) :: "fmt" \n",__LINE__,__FUNCTION__, \
                ##__VA_ARGS__); } while (0)

#define ERR(fmt, ...) \
            do { fprintf(stderr, "ERROR Line %3d , IN %s\(\) :: "fmt" \n",__LINE__,__FUNCTION__, \
                ##__VA_ARGS__); } while (0)

#define	FREE_NODE(_NODE) do{	\
							free(_NODE->name); \
							free(_NODE->logid);	\
							free(_NODE->password);	\
							free(_NODE);	\
							}while(0)

typedef struct linklist
{
	char *logid;
	char *name;
	char *password;
	struct linklist *prev;
	struct linklist *next;
}linklist;

int choice_menu()
{
	int choice;
	printf("\n***************************\n");
	printf("1 : Print Linklist.\n");
	printf("2 : Print Linklist reverse.\n");
	printf("3 : Add node at start.\n");
	printf("4 : Add node at end.\n");
	printf("5 : Delete node from start.\n");
	printf("6 : Delete node from end.\n");
	printf("7 : Selected delete.\n");
	printf("8 : Match password.\n");
	printf("9 : Add node at n number.\n");
	printf("***************************");

	printf("\nEnter your choice : ");
	scanf("%d",&choice);
	return choice;
}

linklist *get_tail(linklist* head)
{
	linklist *tail;
	tail = head;
	while(tail->next != NULL)
	{
	tail = tail->next;
	}
	return tail;
}

void print_list(linklist *head)
{
	linklist *curr = head;
	if(head == NULL)
	{
		ERR("List is empty.");
	}
	while(curr != NULL)
	{
		PR("Name : %3s, ID : %3s, password : <PASSWORD>",curr->name,curr->logid,curr->password);
		curr = curr->next;
	}
}

void print_list_rev(linklist *head)
{
	linklist *curr = head;
	if(curr != NULL)
	{
	print_list_rev(curr->next);
	PR("Name : %3s, ID : %3s, password : <PASSWORD>",curr->name,curr->logid,curr->password);
	}
}

void scan_list(linklist *newnode)
{
	char buffer[128];
	printf("\nName :\t");
	scanf ("%s",buffer);
	newnode->name = (char *) malloc( (strlen(buffer) + 1) * sizeof(char) );
	strcpy(newnode->name,buffer);

	printf("ID :\t");
	scanf ("%s",buffer);
	newnode->logid = (char *) malloc( (strlen(buffer) + 1) * sizeof(char) );
	strcpy(newnode->logid,buffer);

	printf("Password :\t");
	scanf ("%s",buffer);
	newnode->password = (char *) malloc( (strlen(buffer) + 1) * sizeof(char) );
	strcpy(newnode->password,buffer);
}

linklist *create_node()
{
	linklist *new;
	new = (linklist *) malloc (sizeof(linklist));
	if(new != NULL)
	{
	new->prev = NULL;
	new->next = NULL;
	}
}

int linklist_length(linklist* head)
{<commit_msg>linklist updated<commit_after>//Commands
//gcc linklist.c -o linklist
//valgrind --leak-check=yes --verbose ./linklist


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

typedef enum {
	unSuccessful = -1,
	Successful = 0
}retVal;

//self referential structre
//contains at least one member which points to object of same data
//type
//linked list can grow and shrink dynamically
#define EXIT 0
//uncomment this to make debug ON.
//#define DEBUG 1

#ifdef DEBUG
#define DBG(fmt, ...)	do { if (DEBUG) fprintf(stdout, "%3d:: IN %s\() :: "fmt" \n",__LINE__,__FUNCTION__, \
	                ##__VA_ARGS__); } while (0)
#else
#define DBG(fmt, ...) 
#endif

#define PR(fmt, ...)	do { fprintf(stdout, " %3d:: IN %s\() :: "fmt" \n",__LINE__,__FUNCTION__, \
        	        ##__VA_ARGS__); } while (0)

#define ERR(fmt, ...)	do { fprintf(stderr, "ERROR Line %3d , IN %s\() :: "fmt" \n",__LINE__,__FUNCTION__, \
                	##__VA_ARGS__); } while (0)

#define	FREE_NODE(_NODE) do{	\
				free(_NODE->name); \
				free(_NODE->logid);	\
				free(_NODE->password);	\
				free(_NODE);	\
			}while(0)

typedef struct linklist
{
	char *logid;
	char *name;
	char *password;
	struct linklist *prev;
	struct linklist *next;
}linklist;

int choice_menu()
{
	int choice;
	printf("\n***************************\n");
	printf("1 : Print Linklist.\n");
	printf("2 : Print Linklist reverse.\n");
	printf("3 : Add node at start.\n");
	printf("4 : Add node at end.\n");
	printf("5 : Delete node from start.\n");
	printf("6 : Delete node from end.\n");
	printf("7 : Selected delete.\n");
	printf("8 : Match password.\n");
	printf("9 : Add node at n number.\n");
	printf("***************************");

	printf("\nEnter your choice : ");
	scanf("%d",&choice);
	return choice;
}

linklist *get_tail(linklist* head)
{
	linklist *tail;
	tail = head;
	while(tail->next != NULL)
	{
	tail = tail->next;
	}
	return tail;
}

void print_list(linklist *head)
{
	linklist *curr = head;
	if(head == NULL)
	{
		DBG("List is empty.");
	}
	while(curr != NULL)
	{
		PR("Name : %3s, ID : %3s, password : <PASSWORD>",curr->name,curr->logid,curr->password);
		curr = curr->next;
	}
}

void print_list_rev(linklist *head)
{
	linklist *curr = head;
	if(curr != NULL)
	{
	print_list_rev(curr->next);
	PR("Name : %3s, ID : %3s, password : <PASSWORD>",curr->name,curr->logid,curr->password);
	}
}

void scan_list(linklist *newnode)
{
	char buffer[128];
	printf("\nName :\t");
	scanf ("%s",buffer);
	newnode->name = (char *) malloc( (strlen(buffer) + 1) * sizeof(char) );
	strcpy(newnode->name,buffer);

	printf("ID :\t");
	scanf ("%s",buffer);
	newnode->logid = (char *) malloc( (strlen(buffer) + 1) * sizeof(char) );
	strcpy(newnode->logid,buffer);

	printf("Password :\t");
	scanf ("%s",buffer);
	newnode->password = (char *) malloc( (strlen(buffer) + 1) * sizeof(char) );
	strcpy(newnode->password,buffer);
}

linklist *create_node()
{
	linklist *new;
	new = (linklist *) malloc (sizeof(linklist));
	if(new != NULL)
	{
		new->prev = NULL;
		new->next = NULL;
	}
	return new;
}

int linklist_length(linklist* head)
{
{'fraction_non_alphanumeric': 0.20836002562459963, 'fraction_numerical': 0.009609224855861628, 'mean_word_length': 3.6225018504811253, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 57, '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': '5056292', 'n_tokens_mistral': 2450, 'n_tokens_neox': 2344, 'n_words': 571}