Sponsored Content
Full Discussion: Create a database in C
Top Forums Programming Create a database in C Post 302560683 by Errigour on Friday 30th of September 2011 01:49:01 PM
Old 09-30-2011
I didn't spam so youd answer faster.

I didn't spam so you would answer faster I just kept updating my post so
you would see that stuff before you replied. Stuff just hit me while I tried
to make this stuff work.

Anyways I have been using all the stuff you talked about. Could you just
look at my last modification of initialize descriptor and see if it will cause
errors or not.

I know that struct descr **p changes to what I want it to be
but I just wanted to know what you thought about making a linked
list of all the descriptors. I'm worried about the lines under the text
// I think I'm updating my descr_list after this line */

Code:
/* this is defined globally */
struct descr *descr_list = NULL;
/* These are defined before main */
struct descr
{
 int newfd;             /* Player socket                             */
 char char_name[11];    /* Character's name                          */
 char char_pass[25];    /* Character's password                      */
 short int sex;         /* Character's sex                           */
 short int state;       /* Maximum states allowed, 65536             */
 short int create_state /* Character creation state                  */
 struct queue *q;       /* Here to queue character input             */
 struct descr *next     /* Used to create a linked list              */
 struct descr *list;    /* Used to define the top of the linked list */
};
 
int initialize_descr(int newfd, struct descr **p)
{
 struct descr *d;
/* ok creating descriptor for struct descr **p */
 if(!(d = malloc(sizeof(struct descr))))
 {
  nonfatal("malloc failure initializing descr");
  return 0;
 }
 d->newfd = newfd;
 d->state = 1;
 if(!(d->q = malloc(sizeof(struct descr))))
 {
  nonfatal("malloc failure initializing descr queue");
  d->state = 0;
  return 0;
 }
 d->q->next = NULL;
 d->next = NULL;
/* *p = d works if I use a pointer to a descr structure
   initialize_descr(newfd, &init)
   init being
   struct descr *init; */
 *p = d;
 
// I think I'm updating my descr_list after this line */
 if(descr_list == NULL)
 {
  descr_list = d;
  descr_list->list = descr_list;
 }
 else
 {
  while(descr_list->next != NULL)
  {
   descr_list=descr_list->next;
  }
  descr_list->next = d;
  descr_list->next->list = descr_list->list;
  descr_list = descr_list->list;
 }
 return 1;
}
 
/* ok these are defined before I use the function initialize_desc 
they are before my main server loop that loops infinetly */
 descr_list->next = NULL; 
 descr_list->list = descr_list;
/* then I use the function just to make sure everything works the way I
   want it to */
struct descr *init;
/* newfd is just an open socket */
 initialize_descr(newfd, &init);

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

trying to create a virtual database..

:cool: I like Vibhory2 like the idea of tapping into the kernel.. although not as indepth as he/she... i want to create a virtual databse of a few ma chines with connectivity and defiinte knowledge to create it.. I havebeen working on the project for a year now.. ! before unix (1 year exactly) i... (20 Replies)
Discussion started by: moxxx68
20 Replies

2. UNIX for Advanced & Expert Users

create database on unix

how can i create database on unix from command line (without using DBCA) (2 Replies)
Discussion started by: gfhgfnhhn
2 Replies

3. Solaris

Can't create database after Oracle Database installation

I installed Oracle 10 software on Solaris 11 Express, everything was fine execpt I can't create database using dbca.rsp file. I populated file with following options. OPERATION_TYPE = "createDatabase" GDBNAME = "solaris_user.domain.com" SID = "solaris_user" TEMPLATENAME = "General... (0 Replies)
Discussion started by: solaris_user
0 Replies

4. Shell Programming and Scripting

Create database using Backup file

Hi, I have backup file of database in my server. I want to create a that database in the same Mysql Server. How can I do that? Please send the steps to create the database using backup file? Thanks a lot, (1 Reply)
Discussion started by: aish11
1 Replies

5. Programming

Creating a bash script that create/open database

Hi. I have two text files(tables) which include some information and I want to make some query codes using them. First of all, I want to create bash script that read this two tables, create/open database and insert data from files into database. #!/bin/bash while read line; do ... (1 Reply)
Discussion started by: rlaxodus
1 Replies

6. UNIX and Linux Applications

Really simple shell script to create oracle database

Hello , I am new in this forum and need your help as I am totally confused :confused: I read a lot of threads and tried to search a lot but did not get the exact answer to my question. I just want a simple (content wise may be long) shell script to create oracle database. In detail:... (5 Replies)
Discussion started by: rahoolm
5 Replies

7. Shell Programming and Scripting

Help with script to create users from database query

#!/bin/bash user=`mysql userList -uuserlist -puserlistpassword -s -N -e "SELECT userName FROM users WHERE activated='n'"` for i in $user; do useradd "$i" -m doneThis is what I have done so far. But obviously it still does not work. I'm trying to create users based on information stored in a... (5 Replies)
Discussion started by: bucketuk
5 Replies

8. UNIX for Dummies Questions & Answers

Create Alert for Database Problem

Hi all, I new to scripting and i need to know how to put the script when the capture goes down in the feeds database.. I tried with this "ps -ef | grep asn" command and it displaying the capture,apply time. But the alert we are receving now is replication is failed . So i need to develop the... (1 Reply)
Discussion started by: g.nanthagopal
1 Replies

9. AIX

Need a graphical interface on AIX server to create database

Hello, Please suggest me the ways how to get graphical interface on AIX server.I need to create oracle database for which I need graphical access. Best regards, Vishal (4 Replies)
Discussion started by: Vishal_dba
4 Replies

10. Shell Programming and Scripting

awk parsing file to create a database

Hi Guys, I have a list a hotels stored in many different text files. This list is kept in the following format: 20/03 Hotel: The Bear Hotel Honey Street Woodstock UK Tel:+44-xxxxxx Rate: 100 21/03 Hotel: The Bush Hotel Nice Street Farnham (4 Replies)
Discussion started by: freddie50
4 Replies
set_color(1)                                                           fish                                                           set_color(1)

NAME
set_color - set_color - set the terminal color set_color - set the terminal color Synopsis set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR] Description Change the foreground and/or background color of the terminal. COLOR is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal. o -b, --background Set the background color o -c, --print-colors Prints a list of all valid color names o -h, --help Display help message and exit o -o, --bold Set bold or extra bright mode o -u, --underline Set underlined mode o -v, --version Display version and exit Calling set_color normal will set the terminal color to whatever is the default color of the terminal. Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, set_color white will result in a grey font color, while set_color --bold white will result in a white font color. Not all terminal emulators support all these features. This is not a bug in set_color but a missing feature in the terminal emulator. set_color uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and may lack color information for terminals that support it. Download and install the latest version of ncurses and recompile fish against it in order to fix this issue. Version 1.23.1 Sun Jan 8 2012 set_color(1)
All times are GMT -4. The time now is 10:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy