Esempio n. 1
0
Exit_Data :: ~Exit_Data( )
{
  record_delete( sizeof( exit_data ), MEM_EXIT );

  free_string( name,     MEM_EXIT );
  free_string( keywords, MEM_EXIT );
}
Esempio n. 2
0
ban_data :: ~ban_data( )
{
  free_string( name, MEM_BAN );

  record_delete( sizeof( ban_data ), MEM_BAN );
  remove( ban_list, this );
};
Esempio n. 3
0
Help_Data :: ~Help_Data( )
{
  int pos;

  record_delete( sizeof( help_data ), MEM_HELP ); 
  free_string( name, MEM_HELP );
  free_string( text, MEM_HELP );
  free_string( immortal, MEM_HELP );

  for( pos = 0; pos < max_help; pos++ )
    if( help_list[pos] == this ) {
      remove( help_list, max_help, pos );
      break;
      }
}
Esempio n. 4
0
/* bool delete_record(id, table_name, sid) */
static int cc_delete_record(lua_State* L)
{
	int id;
	int64_t sid;
	const char* table_name;
	bool retcode;
	database_handler_t* database_handler;
	worker_handler_t* handler = find_handler_by_stack(L);
	int args = lua_gettop(L);
	if (args < 3)
	{
		error_log("`%s` parameter lack:%d\n", __FUNCTION__, args);
		return 0;
	}

	if (!lua_isnumber(L, -args))
	{
		error_log("`%s` parameter error:%s\n", __FUNCTION__, lua_typename(L, lua_type(L, -args)));
		return 0;
	}

	if (!lua_isstring(L, -(args-1)))
	{
		error_log("`%s` parameter error:%s\n", __FUNCTION__, lua_typename(L, lua_type(L, -(args-1))));
		return 0;
	}

	if (!lua_isnumber(L, -(args-2)))
	{
		error_log("`%s` parameter error:%s\n", __FUNCTION__, lua_typename(L, lua_type(L, -(args-2))));
		return 0;
	}

	id = lua_tointeger(L, -args);
	table_name = lua_tostring(L, -(args-1));
	sid = lua_tonumber(L, -(args-2));
	database_handler = hash_table_find(handler->database_table, id);
	if (!database_handler)
	{
		error_log("`%s` not found database:%d\n", __FUNCTION__, id);
		return 0;
	}
	retcode = record_delete(database_handler, table_name, sid);
	lua_pushboolean(L, retcode ? 1 : 0);

	return 1;
}
Esempio n. 5
0
Wizard_Data :: Wizard_Data(char* name) : player_data(name) 
{
  record_new(sizeof(wizard_data), MEM_WIZARD);
  record_delete(sizeof(player_data), MEM_PLAYER);

  valid        = WIZARD_DATA;

  action_edit  = NULL;
  adata_edit   = NULL;
  room_edit    = NULL;
  mpdata_edit  = NULL;
  mprog_edit   = NULL;
  oextra_edit  = NULL;
  opdata_edit  = NULL;
  oprog_edit   = NULL;
  player_edit  = NULL;
  quest_edit   = NULL;
  obj_edit     = NULL;
  mob_edit     = NULL;
  exit_edit    = NULL;

  custom_edit  = 0;
  rtable_edit  = -1;
  list_edit    = 0;
  office       = 0;
  wizinvis     = 0;

  vzero(table_edit, 2);

  bamfin       = empty_string;
  bamfout      = empty_string;
  level_title  = empty_string;

  build_chan   = NULL;
  imm_talk     = NULL;
  god_talk     = NULL;
  avatar       = NULL;

  vzero(permission, 2);
}
Esempio n. 6
0
int bbsfdel_main(void)
{
	if (!loginok)
		return BBS_ELGNREQ;
	char *user = getparm("u");
	if (*user != '\0') {
		char file[HOMELEN];
		sethomefile(file, currentuser.userid, "friends");
		record_t r;
		if (record_open(file, O_RDWR, &r) < 0)
			return BBS_EINTNL;
		override_t key;
		strlcpy(key.id, user, sizeof(key.id));
		override_t *ptr =
				record_search(&r, &key, sizeof(key), lsearch, cmp_override);
		if (ptr != NULL)
			record_delete(&r, ptr, sizeof(*ptr));
		record_close(&r);
	}
	printf("Location: fall\n\n");
	return 0;
}
Esempio n. 7
0
static void buffer_delete_bytes_internal(long len, bool move_after)
{
	view_reset_preferred_x(view);
	if (len == 0)
		return;

	// check if all newlines from EOF would be deleted
	if (would_delete_last_bytes(len)) {
		struct block_iter bi = view->cursor;
		unsigned int u;

		if (buffer_prev_char(&bi, &u) && u != '\n') {
			// no newline before cursor
			if (--len == 0) {
				begin_change(CHANGE_MERGE_NONE);
				return;
			}
		}
	}
	record_delete(do_delete(len), len, move_after);

	if (buffer->views.count > 1)
		fix_cursors(block_iter_get_offset(&view->cursor), len, 0);
}
Esempio n. 8
0
File: undo.c Progetto: yinsuhu/emacs
void
record_change (ptrdiff_t beg, ptrdiff_t length)
{
  record_delete (beg, make_buffer_string (beg, beg + length, true), false);
  record_insert (beg, length);
}
Esempio n. 9
0
Share_Data :: ~Share_Data()
{
  record_delete(sizeof(share_data), MEM_SHDATA);
}
Esempio n. 10
0
Wizard_Data :: ~Wizard_Data()
{
  record_delete(sizeof(wizard_data), MEM_WIZARD);
  record_new(sizeof(player_data), MEM_PLAYER);
}
Esempio n. 11
0
Player_Data :: ~Player_Data()
{
  record_delete(sizeof(player_data), MEM_PLAYER);
  player_list -= this;
}
Esempio n. 12
0
Obj_Clss_Data :: ~Obj_Clss_Data( )
{
  record_delete( sizeof( obj_clss_data ), MEM_OBJ_CLSS );
}
Esempio n. 13
0
Obj_Data :: ~Obj_Data( )
{
  record_delete( sizeof( obj_data ), MEM_OBJECT );
  obj_list -= this;
}
Esempio n. 14
0
void
record_change (EMACS_INT beg, EMACS_INT length)
{
  record_delete (beg, make_buffer_string (beg, beg + length, 1));
  record_insert (beg, length);
}
Esempio n. 15
0
void do_ban( char_data* ch, char* argument )
{
  account_data*   account;
  ban_data*           ban;
  pfile_data*       pfile  = NULL;
  int               flags;
  int                   i;
  bool              first  = TRUE;
  const char*        name;
  player_data*     victim;

  if( !get_flags( ch, argument, &flags, "srn", "Ban" ) )
    return;

  if( is_set( &flags, 2 ) ) {
    if( *argument == '\0' ) {
      if( badname_array == NULL ) {
        send( ch, "The badname array is empty.\n\r" );
        }
      else {
        display_array( ch, "Bad Name Array", &badname_array[0],
          &badname_array[1], max_badname );
        }
      return;
      }
    i = pntr_search( badname_array, max_badname, argument );
    if( is_set( &flags, 1 ) ) {
      if( i < 0 ) {
        send( ch, "The name '%s' wasn't in the badname array.\n\r",
          argument );
        }
      else {
        record_delete( sizeof( char* ), MEM_BADNAME );
        remove( badname_array, max_badname, i );
        send( ch, "Name removed from badname array.\n\r" );
        save_badname( );
        }
      }
    else {
      if( i > 0 ) {
        send( ch, "The name '%s' is already in the badname array.\n\r",
          argument );
        }
      else if( check_parse_name( ch->link, argument ) ) {
        i = -i-1;
        record_new( sizeof( char* ), MEM_BADNAME );
        name = alloc_string( argument, MEM_BADNAME );
        insert( badname_array, max_badname, name, i );
        send( ch, "The name '%s' is added to the badname array.\n\r",
          name );
        save_badname( );
        }
      }
    return;
    }

  if( is_set( &flags, 0 ) ) {
    if( *argument == '\0' ) {
      page_title( ch, "Banned Sites" );
      for( ban = ban_list; ban != NULL; ban = ban->next )
        page( ch, "%s\n\r", ban->name );
      return;
      }
    if( !is_set( &flags, 1 ) ) {
      for( ban = ban_list; ban != NULL; ban = ban->next ) {
        if( !strcasecmp( argument, ban->name ) ) {
          send( "That site is already banned!\n\r", ch );
          return;
          }
        }
      ban        = new ban_data;
      ban->name  = alloc_string( argument, MEM_BAN );
      save_banned( );
      send( ch, "Ok.\n\r" );
      }
    else {
      for( ban = ban_list; ban != NULL; ban = ban->next ) {
        if( !strcasecmp( argument, ban->name ) ) {
          delete ban;
          save_banned();
          send( ch, "Ok.\n\r" );
          return;
          }
        }
      send( ch, "Site is not banned.\n\r" );
      }
    return;
    }

  if( *argument == '\0' ) {
    page_title( ch, "Banned Accounts" );
    for( i = 0; i < max_account; i++ )
      if( account_list[i]->banned != -1 ) 
        display_account( ch, account_list[i], first );
    return;
    }

  if( ( account = account_arg( argument ) ) == NULL ) {
    if( ( pfile = player_arg( argument ) ) == NULL ) {
      send( ch, "No such account or player.\n\r" );
      return;
      }
    if( ( account = pfile->account ) == NULL ) {
      send( ch, "That player doesn't have an account which makes banning\
 it difficult.\n\r" );
      return;
      }
    }
Esempio n. 16
0
void menu()
{
 emp_rec ser_emp;
 int c=0,emp_no;
 long pos;
 FILE * fp,* eno,* delemp;
 if((fp=fopen("emp.dat","rb+"))==NULL)
 	{
	printf("Error 1: Problem with main file opening.\n");
	exit(ferror(fp));
	}
if((eno=fopen("empno.dat","rb+"))==NULL)
	{
	printf("Error 2: Problem with employee no file.\n");
	exit(ferror(fp));
	}
if((delemp=fopen("delemp.dat","rb+"))==NULL)
	{
	printf("Error 3: Problem with deleted employee file.\n");
	delemp=fopen("delemp.dat","wb+");
	}


	

 while(c!=6)
 	{
	printf("\t\t\t\t Menu for Employee Record Base\n");
	printf("\t\t\t1.Employee Record Insertion\n");
	printf("\t\t\t2.Employee Record Search\n");
	printf("\t\t\t3.Employee Record Update\n");
	printf("\t\t\t4.Employee Record Delete\n");
	printf("\t\t\t5.Display All Employees\n");
	printf("\t\t\t6.Exit the program.\n");

	printf("\t\t\t\t Enter your choice:");
	scanf("%d",&c);
		switch(c)
		{
			case 1:
				record_insert(fp,eno);
				break;
			case 2:
				printf("Enter the employee no to search:");
				scanf("%d",&emp_no);
				if((pos=record_search(fp,emp_no))==-1)
				   printf("Employee does not exist.\n");
				else
				{
				   printf("Employee exists.\n");
				   fseek(fp,pos,SEEK_SET);
				   fread(&ser_emp,sizeof(emp_rec),1,fp);
	printf("\t\t\tDetails of Employee No: %d\n",ser_emp.emp_no);
	printf("\tEmployee Name:%s\n",ser_emp.emp_name);
	printf("\tEmployee Salary:%lf",ser_emp.emp_sal);
	printf("\tEmployee Address:%s\n",ser_emp.emp_add);
	printf("\tEmployee Mobile:%s\n",ser_emp.emp_mobile);
				}
				break;
			case 3:
				record_update(fp);
				break;
			case 4:
				record_delete(fp,delemp);
				break;
			case 5:
				fseek(fp,0,SEEK_END);
				pos=ftell(fp);
				fseek(fp,0,SEEK_SET);
				while((pos!=ftell(fp))&&(!feof(fp)))
				{
				fread(&ser_emp,sizeof(emp_rec),1,fp);
				if(ser_emp.emp_no!=-1)
				{
	printf("\t\t\tDetails of Employee No: %d\n",ser_emp.emp_no);
	printf("\tEmployee Name:%s\n",ser_emp.emp_name);
	printf("\tEmployee Salary:%lf",ser_emp.emp_sal);
	printf("\tEmployee Address:%s\n",ser_emp.emp_add);
	printf("\tEmployee Mobile:%s\n",ser_emp.emp_mobile);
	printf("\n\n");		}	

				}
				break;
			case 6:
				printf("Exiting...and closing the files\n");
				fclose(fp);
				fclose(eno);
				fclose(delemp);
				break;
		}


	}

}