
/*
					SysOp Userlog Editor
					--------------------
*/

#version        $50
#reserve        6
#copyright      "Ueditor.cmd    Copyright 1995 K-Products"
#address        $7000

#define         F_AUTOREAD      1
#define         F_NONSTOP       2
#define         F_CLEAR         4
#define         F_HOTKEY        8
#define         F_FILTER        16


#include        runtime.h
#include        bbs_pro.h

int             editing;                                                /* the user number we're editing */

int             next_new_user;                                  /* user to start "next new" search */
char    *error_message;


/*              layout of record for editing purposes   */
/*              -------------------------------------   */

char  e_inuse;
char  e_locked;
char  e_newuser;
char  e_handle [21];
char  e_name [21];
char  e_pword [16];
char  e_addr [21];
char  e_cityst [23];
char  e_zip [11];
char  e_country [11];
char  e_phone [13];
char  e_age;
char  e_cpu [16];
char  e_lstcall [14];
char  e_tlcall;
char  e_tlday;
char  e_mintoday;
int   e_lastread;
char  e_dlratio;
int   e_downs;
int   e_ups;
int   e_msgp;
int   e_emsent;
int   e_totcalls;
char  e_vw;
char  e_flags [2];
char  e_seclvl [4];
char  e_msgread [4];
char  e_msgpost [4];
char  e_msgedit [4];
char  e_msgdel [4];
char  e_msgprint [4];
char  e_sigread [4];
char  e_sigedit [4];
char  e_sigdel [4];
char  e_qscan [4];
char  e_lastmm;
char  e_lastdd;
char  e_lastyy;
char  e_pagesize;
int   e_node;
char  e_expmm;
char  e_expdd;
char  e_expyy;
char  e_filler [17];
char  end_of_record;



main()
{
	int x;
	if ( &end_of_record - &e_inuse != 256 ) {
		echose ("User record layout invalid!");
		return;
	}
	error_message = "       (c) 1995 K-Products";
	next_new_user = 10;
	if (length (parm1) > 0 && parm1 [1] == 'E') {
		parm1 [1] = '0';
		x = valc (parm1);
		if (x > 0 && x <= u_recsinuse) {
			edit_user ( x );
			return;
		}
	}
	while ( 1 ) {
		case ( main_menu() ) {
			'X'     :       return;
			'O'     :       if ( bbs_active )                       /* must be someone online */
						edit_online_user();
					else
						error_message = "Nobody is online!";
			'U'     :       edit_by_number();
			'H'     :       edit_by_handle();
			'R'     :       edit_by_real_name();
			'F'     :       edit_first_new_user();
			'C'     :       edit_next_new_user();
			'A'     :       add_new_user();
			'V'     :       edit_user ( 1 );
			'N'     :       edit_user ( 2 );                                /* records 1 - 10 are   */
			'P'     :       edit_by_phone();
			'1'     :       edit_user ( 3 );                                /*  special records..   */
			'2'     :       edit_user ( 4 );
			'3'     :       edit_user ( 5 );
			'4'     :       edit_user ( 6 );
			'5'     :       edit_user ( 7 );
			'6'     :       edit_user ( 8 );
			'7'     :       edit_user ( 9 );
			else:   error_message = "Invalid option!";
		}
	}
}



main_menu()
{
	char command [3];
	echo (125);
	cr_lf();
	echo (' ');
	echose (error_message);
	error_message = "";
	cr_lf();
	cr_lf();
	echose ("           Edit Which User?       v5.0");
	cr_lf();
	echose ("  [U] by User number  [F] First new");
	echose ("  [H] by Handle       [C] Next  new");
	echose ("  [R] by Real name    [A] Add new user");
	echose ("  [O] Online user     [P] by Phone #");
	cr_lf();
	echose ("  [V] Visitor rec   [1-7] Edit mask");
	echose ("  [N] New User rec    [X] Exit");
	cr_lf();
	echos  ("           Your choice: ");
	get_string ( command, 1, 0, 0);
	cr_lf();
	return ( toupper ( command [1] ) );
}



edit_online_user()
{
	edit_user ( 0 );
	update_status();
}


edit_by_number()
{
	int  x;
	char unum [6];
	echos ("Edit user number: ");
	get_string ( unum, 4, 1, 1 );
	if (length (unum) == 0) {
		error_message = "Aborted..";
		return;
	}
	x = valc (unum);
	if (x < 10 || x > u_recsinuse)
		error_message = "That user doesn't exist...";
	else if (x == usernum)
		error_message = "That user is online; use option [O]";
	else
		edit_user ( x );
}


edit_by_handle()
{
	int x;
	echose ("Enter a full or partial handle");
	echos  ("-> ");
	get_string (instr, 20, 0, 1);
	cr_lf();
	if (length(instr) == 0)
		return;
	x = find_user (t_handle, instr);
	if (x == 0)
		error_message = "User not found..";
	else
		edit_user (x);
}


edit_by_phone()
{
	int x;
	echose ("Enter a full or partial phone #");
	echos  ("-> ");
	get_string (instr, 13, 0, 1);
	if (length(instr) == 0)
		return;
	x = find_user (t_phone, instr);
	if (x == 0)
		error_message = "User not found..";
	else
		edit_user (x);
}


edit_by_real_name()
{
	int x;
	echose ("Enter a full or partial name");
	echos  ("-> ");
	get_string (instr, 20, 0, 1);
	cr_lf();
	if (length(instr) == 0)
		return;
	x = find_user (t_name, instr);
	if (x == 0)
		error_message = "User not found..";
	else
		edit_user (x);
}



edit_first_new_user()
{
	int x;
	next_new_user = 10;
	echos ("Searching...");
	MIOsuspend();
	x = find_next_new();
	MIOresume();
	if (x == 0)
		error_message = "No new users found..";
	else {
		edit_user (x);
		++next_new_user;
	}
}



edit_next_new_user()
{
	int x;
	echos ("Searching...");
	MIOsuspend();
	x = find_next_new();
	MIOresume();
	if (x == 0)
		error_message = "No more new users found..";
	else {
		edit_user (x);
		++next_new_user;
	}
}



add_new_user()
{
	int x;
	echos ("Searching for open slot...");
	x = first_free();
	if (x == 0) {
		if (u_recsinuse >= u_maxrecs)
			error_message = "No slots available...";
		else
			edit_user (u_recsinuse + 1);
	 }
	else
		edit_user (x);
}



edit_user ( int recno )
{
	int all_done;
	editing = recno;
	if ( editing == 0 )                                             /* editing on-line user?        */
		move_user_to_edit();
	else if (recno > u_recsinuse)                   /* new user to end of userlog? */
		clear_edit_area();
	else {
		if ( read_user_record (editing) != OK )
			return;
		move_temp_to_edit();
	}
	if ( editing > 0 && editing < 10 ) {                    /* a special record     */
		e_locked  = 1;                                                          /* always lock it       */
		e_newuser = 0;
		if ( editing == 1 )
			strcpy (e_handle, "* Visitor Record *");
		else if ( editing == 2 )
			strcpy (e_handle, "* New User Record *");
		else {
			strcpy (e_handle, "* Valid. Mask #x *");
			e_handle [16] = editing - 2 + '0';
		}
	}
	all_done = 0;
	while ( all_done == 0 ) {
		case ( editing_main_menu () ) {
			'X'     :       all_done = 1;
			'T'     :       edit_textual_data();
			'U'     :       edit_usage_data();
			'P' :   edit_parm_data();
			'C'     :       edit_command_security();
			'M'     :       edit_message_security();
			'F'     :       edit_file_security();
			'D'     :       if ( e_inuse )
						e_inuse = 0;
					else
						e_inuse = 1;
			'L'     :       if ( e_locked )
						e_locked = 0;
					else
						e_locked = 1;
			'1'     :       apply_mask ( 3 );
			'2'     :       apply_mask ( 4 );
			'3'     :       apply_mask ( 5 );
			'4'     :       apply_mask ( 6 );
			'5'     :       apply_mask ( 7 );
			'6'     :       apply_mask ( 8 );
			'7'     :       apply_mask ( 9 );
		}
	}
	e_newuser = 0;                                                  /* not a new user anymore       */
	echos ("Save any changes just made? ");
	if ( y_or_n() == 'Y' ) {
		error_message = "User record updated...";
		if ( editing == 0 )                                     /* editing on-line user?        */
			move_edit_to_user();
		else {                                                          /* no, must write to disk       */
			move_edit_to_temp();
			write_user_record (editing);
		}
	 }
	else
		error_message = "Changes NOT saved to disk...";
}



editing_main_menu()
{
	char command [3];
	echo (125);
	edit_header ();
	cr_lf();
	echose ("              Edit What?");
	cr_lf();
	echose ("  [T] Textual data    [L] Lock user  ");
	echose ("  [U] Usage data      [D] Delete user");
	echose ("  [P] Parm data     [1-7] Apply mask ");
	echose ("  [C] Command sec.                   ");
	echose ("  [M] Message sec.    [X] Exit       ");
	echose ("  [F] File sec.");
	cr_lf();
	echos  ("          Your choice: ");
	get_string ( command, 1, 0, 0 );
	cr_lf();
	return ( toupper ( command [1] ) );
}




edit_header ()
{
	cr_lf();
	echos ("Editing: ");
	echos (e_handle);
	echos (" (#");
	echoc (editing);
	echos (")");
	cr_lf();
	echos (" Status: ");
	if ( e_inuse )
		echos ("Active/");
	else
		echos ("DELETED/");
	if ( e_newuser )
		echos ("New User/");
	else
		echos ("Validated/");
	if ( e_locked )
		echos ("LOCKED");
	else
		echos ("Unlocked");
	cr_lf();
}




edit_textual_data()
{
	byte replot, all_done;
	char command [8];
	replot = 1;
	all_done = 0;
	while ( all_done == 0 ) {
		if ( replot ) {
			replot = 0;
			show_textual_data();
		}
		cr_lf();
		echos ("A-K, Ok, or LIST: ");
		get_string (command, 4, 0, 1);
		cr_lf();
		if (length(command) == 0 || strcmpi(command,"LIST") == 0)
			++replot;
		else if (strcmpi (command, "ok") == 0)
			++all_done;
		else {
			case ( toupper(command[1]) ) {
				'A'     :       {       echos ("New handle: ");
							get_string (e_handle, 20, 0, 1);        }
				'B'     :       {       echos ("New name: ");
							get_string (e_name, 20, 0, 1);          }
				'C'     :       {       echos ("New address: ");
							get_string (e_addr, 20, 0, 1);          }
				'D'     :       {       echos ("New city, state: ");
							get_string (e_cityst, 22, 0, 1);        }
				'E'     :       {       echos ("Zip/Postal code: ");
							get_string (e_zip, 10, 0, 0);           }
				'F'     :       {       echos ("New country: ");
							get_string (e_country, 10, 0, 0);       }
				'G'     :       {       echos ("New phone: ");
							get_string (e_phone, 12, 0, 0);         }
				'H'     :       {       echos ("Computer type: ");
							get_string (e_cpu, 15, 0, 0);           }
				'I'     :       {       echos ("New age: ");
							e_age = get_byte();                     }
				'J'     :       {       echos ("New password: ");
							get_string (e_pword, 15, 0, 1);         }
				'K'     :       {       echos ("Expires Month: ");
							e_expmm = get_byte();
							cr_lf();
							echos ("          Day: ");
							e_expdd = get_byte();
							cr_lf();
							echos ("         Year: ");
							e_expyy = get_byte();
							cr_lf();                                }
				'L'     :       {   if  (s_node == 47)
							echos (" Pro Node Number: ");
						    if  (s_node == 47)
							e_node = get_card();
						    if  (s_node == 53)
							echos (" Pro Node Number: ");
						    if  (s_node == 53)
							e_node = get_card();
						    if  (s_node == 230)
							echos (" Pro Node Number: ");
						    if  (s_node == 230)
							e_node = get_card();
						    if  (s_node == 1)
							echos (" Pro Node Number: ");
						    if  (s_node == 1)
							e_node = get_card();
						    if  (s_node == 349)
							echos (" Pro Node Number: ");
						    if  (s_node == 349)
							e_node = get_card();
							
							cr_lf ()                               }
			}
		}
	}
}




show_textual_data()
{
	echo (125);
	edit_header();
	cr_lf();
	echos ("[A]    Handle: ");              echose(e_handle);
	echos ("[B] Real Name: ");              echose(e_name);
	echos ("[C]   Address: ");              echose(e_addr);
	echos ("[D]      City: ");              echose(e_cityst);
	echos ("[E]  Zip Code: ");              echose(e_zip);
	echos ("[F]   Country: ");              echose(e_country);
	echos ("[G]     Phone: ");              echose(e_phone);
	echos ("[H]  Computer: ");              echose(e_cpu);
	echos ("[I]       Age: ");              echobe(e_age);
	echos ("[J]  Password: ");              echose(e_pword);
	echos ("[K]   Expires: ");
	if (e_expmm < 10) echo ('0');
	echob (e_expmm);
	echo ('-');
	if (e_expdd < 10) echo ('0');
	echob (e_expdd);
	echo ('-');
	if (e_expyy < 10) echo ('0');
	echobe(e_expyy);
	if (s_node == 53) echos ("[L]  Serial #: ");
	if (s_node == 53) echoce(e_node);
	if (s_node == 47) echos ("[L]  Serial #: ");
	if (s_node == 47) echoce(e_node);
	if (s_node == 230) echos ("[L]  Serial #: ");
	if (s_node == 230) echoce(e_node);
	if (s_node == 349) echos ("[L]  Serial #: ");
	if (s_node == 349) echoce(e_node);
	if (s_node == 1) echos ("[L]  Serial #: ");
	if (s_node == 1) echoce(e_node);

}




edit_usage_data()
{
	byte replot, all_done;
	char command [8];
	replot = 1;
	all_done = 0;
	while ( all_done == 0 ) {
		if ( replot ) {
			replot = 0;
			show_usage_data();
		}
		cr_lf();
		echos ("A-K, Ok, or LIST: ");
		get_string (command, 4, 0, 1);
		cr_lf();
		if (length(command) == 0 || strcmpi(command,"LIST") == 0)
			++replot;
		else if (strcmpi (command, "ok") == 0)
			++all_done;
		else {
			case ( toupper(command[1]) ) {
				'A'     :       e_tlcall   = get_a_byte();
				'B'     :       e_tlday    = get_a_byte();
				'C'     :       e_mintoday = get_a_byte();
				'D'     :       e_downs    = get_a_card();
				'E'     :       e_ups      = get_a_card();
				'F'     :       e_dlratio  = get_a_byte();
				'G'     :       e_lastread = get_a_card();
				'H'     :       e_msgp     = get_a_card();
				'I'     :       e_emsent   = get_a_card();
				'J'     :       e_totcalls = get_a_card();
				'K'     : {     echos ("New value: ");
						get_string (e_lstcall, 13, 0, 0);       }
			}
		}
	}
}



show_usage_data()
{
	echo (125);
	edit_header();
	cr_lf();
	echos ("   [A] Time/call : ");  echobe(e_tlcall);
	echos ("   [B] Time/day  : ");  echobe(e_tlday);
	echos ("   [C] Mins today: ");  echobe(e_mintoday);
	echos ("   [D] Downloads : ");  echoce(e_downs);
	echos ("   [E] Uploads   : ");  echoce(e_ups);
	echos ("   [F] DL ratio  : ");  echob (e_dlratio);      echose(":1");
	echos ("   [G] Last read : ");  echoce(e_lastread);
	echos ("   [H] Msg posted: ");  echoce(e_msgp);
	echos ("   [I] Email sent: ");  echoce(e_emsent);
	echos ("   [J] # of calls: ");  echoce(e_totcalls);
	echos ("   [K] Last call : ");  echose(e_lstcall);
}


edit_parm_data()
{
	byte replot, all_done;
	char command [8];
	replot = 1;
	all_done = 0;
	while ( all_done == 0 ) {
		if ( replot ) {
			replot = 0;
			show_parm_data();
		}
		cr_lf();
		echos ("A-H, Ok, or LIST: ");
		get_string (command, 4, 0, 1);
		cr_lf();
		if (length(command) == 0 || strcmpi(command,"LIST") == 0)
			++replot;
		else if (strcmpi (command, "ok") == 0)
			++all_done;
		else {
			++replot;
			case ( toupper(command[1]) ) {
				'A'     :       if (e_vw == 40)
							e_vw = 80;
						else
							e_vw = 40;
				'B'     :       e_flags [0] = e_flags [0] ^ F_AUTOREAD;
				'C'     :       e_flags [0] = e_flags [0] ^ F_CLEAR;
				'D'     :       e_flags [0] = e_flags [0] ^ F_HOTKEY;
				'E'     :       e_flags [0] = e_flags [0] ^ F_NONSTOP;
				'F'     :       e_pagesize = get_a_byte();
				'G'     :       e_flags [0] = e_flags [0] ^ F_FILTER;
				'H'     :       get_security_levels ( &e_qscan );
			}
		}
	}
}



show_parm_data()
{
	echo (125);
	edit_header();
	cr_lf();
	echos ("   [A] Video screen width      : ");    echobe(e_vw);
	echos ("   [B] Auto-read Email at logon: ");    show_flag(F_AUTOREAD);
	echos ("   [C] Clear screen after msg  : ");    show_flag(F_CLEAR);
	echos ("   [D] Hotkey 1-key commands   : ");    show_flag(F_HOTKEY);
	echos ("   [E] Non-stop quickscan mode : ");    show_flag(F_NONSTOP);
	echos ("   [F] Message view page length: ");    echobe (e_pagesize);
	echos ("   [G] Filter uppercase letters: ");    show_flag(F_FILTER);
	echose("   [H] Quick-scan settings");
	level_header();
	echos  ("      ");
	show_levels (e_qscan);
}




show_flag (byte flag)
{
	if (e_flags [0] & flag)
		echose ("On");
	else
		echose ("Off");
}



edit_command_security()
{
	echo (125);
	edit_header();
	cr_lf();
	cr_lf();
	echose ("       Which command levels can this");
	echose ("             user execute?");
	cr_lf();
	echose ("           (Y, N, or Return)");
	get_security_levels ( &e_seclvl );
}




edit_message_security()
{
	byte replot, all_done;
	char command [8];
	replot = 1;
	all_done = 0;
	while ( all_done == 0 ) {
		if ( replot ) {
			echo (125);
			edit_header();
			cr_lf();
			cr_lf();
			replot = 0;
			echose ("     What message base actions can");
			echose ("         this user perform?");
			level_header();
			echos  ("A] Rd ");      show_levels (e_msgread);
			echos  ("B] Wr ");      show_levels (e_msgpost);
			echos  ("C] Ed ");      show_levels (e_msgedit);
			echos  ("D] De ");      show_levels (e_msgdel);
			echos  ("E] Pr ");      show_levels (e_msgprint);
		}
		cr_lf();
		echos ("A-E, Ok, or LIST: ");
		get_string (command, 4, 0, 1);
		cr_lf();
		if (length(command) == 0 || strcmpi(command,"LIST") == 0)
			++replot;
		else if (strcmpi (command, "ok") == 0)
			++all_done;
		else {
			case ( toupper(command[1]) ) {
				'A'     :       get_security_levels ( &e_msgread );
				'B'     :       get_security_levels ( &e_msgpost );
				'C'     :       get_security_levels ( &e_msgedit );
				'D'     :       get_security_levels ( &e_msgdel  );
				'E'     :       get_security_levels ( &e_msgprint);
			}
		}
	}
}



edit_file_security()
{
	byte replot, all_done;
	char command [8];
	replot = 1;
	all_done = 0;
	while ( all_done == 0 ) {
		if ( replot ) {
			echo (125);
			edit_header();
			cr_lf();
			cr_lf();
			replot = 0;
			echose ("     What file SIG actions can");
			echose ("         this user perform?");
			level_header();
			echos  ("A] Rd ");      show_levels (e_sigread);
			echos  ("B] Ed ");      show_levels (e_sigedit);
			echos  ("C] De ");      show_levels (e_sigdel);
		}
		cr_lf();
		echos ("A-C, Ok, or LIST: ");
		get_string (command, 4, 0, 1);
		cr_lf();
		if (length(command) == 0 || strcmpi(command,"LIST") == 0)
			++replot;
		else if (strcmpi (command, "ok") == 0)
			++all_done;
		else {
			case ( toupper(command[1]) ) {
				'A'     :       get_security_levels ( &e_sigread );
				'B'     :       get_security_levels ( &e_sigedit );
				'C'     :       get_security_levels ( &e_sigdel  );
			}
		}
	}
}




get_security_levels ( char *sec_field )
{
	byte idx, ch;
	level_header();
	echos  (" Now: ");
	show_levels ( sec_field );
	echos  (" New: ");
	for (idx = 1; idx < 33; ++idx) {
		do {
			ch = tolower (get_key());
		} while (ch != 'y' && ch != 'n' && ch != 155);
		echo (ch);
		if (ch == 155)
			break;
		if (ch == 'y')
			set_lvl (sec_field, idx);
		else
			clr_lvl (sec_field, idx);
	}
}


level_header()
{
	cr_lf();
	echose ("               1    1    2    2    3");
	echose ("      ----5----0----5----0----5----0--");
}



show_levels (char *sec_field)
{
	byte idx;
	for (idx = 1; idx < 33; ++idx) {
		if (sec_lvl (sec_field, idx))
			echo ('y');
		else
			echo ('.');
	}
	cr_lf();
}


apply_mask ( int maskno )
{
	char junk [2];
	if ( read_user_record (maskno) != OK )
			return;
	e_tlcall = t_tlcall;
	e_tlday  = t_tlday;
	e_dlratio = t_dlratio;
#asm {
		ldy     #0
.app:   lda     t_seclvl,y
	sta     e_seclvl,y
	iny
	cpy     #36
	bne     .app
	}
	cr_lf();
	echos ("Set user's expiration date to 1 year\from today? ");
	if (y_or_n() == 'Y') {
		e_expmm   = cur_month;
		e_expdd   = cur_day;
		e_expyy   = cur_year + 1;
		echose ("Expiration date updated");
	}
	cr_lf();
	echos ("Edit mask applied; press <return> ");
	get_string (junk, 1, 0, 1);
}


find_user (char *user_field; char *match)
{
	int idx, x;
	echos ("Searching...");
	MIOsuspend();
	close_ulog();
	if ( open_ulog() != OK ) {
		MIOresume();
		return(0);
	}
	for (idx = 10; idx <= u_recsinuse; ++idx) {
		if ( read_user ( idx ) != OK ) {
			close_ulog();
			MIOresume();
			return(0);
		}
		if (pos (user_field, match) > 0) {
			MIOresume();
			for (x=0; x < 12; ++x) {
				echo (126);
				echo (' ');
				echo (126);
			}
			echos("Edit ");
			echos(user_field);
			echos("? ");
			if (y_or_n() == 'Y') {
				MIOsuspend();
				close_ulog();
				MIOresume();
				return(idx);
			 }
			else {
				echos("Searching...");
				MIOsuspend();
			}
		}
	}
	close_ulog();
	return(0);
}


find_next_new ()
{
	close_ulog();
	if ( open_ulog() != OK )
		return(0);
	while (next_new_user <= u_recsinuse) {
		if ( read_user ( next_new_user ) != OK ) {
			close_ulog();
			return(0);
		}
		if (t_inuse > 0 && t_newuser > 0) {
			close_ulog();
			return(next_new_user);
		}
		++next_new_user;
	}
	close_ulog();
	return(0);
}



/*======================================================================*
 *                                                                                                                                              *
 *              Read the user number specified into the temporary record area.  *
 *              Returns 1 if successful, 0 if error occurs.                                             *
 *                                                                                                                                              *
 *======================================================================*/

read_user_record ( int recno )
{
	byte error_occurred;
	if ( ck_range ( recno ) != OK ) {
		error_message = "That user number is invalid!";
		return;
	}
	MIOsuspend();
	close_ulog();
	error_occurred = 1;                                                             /* assume error */
	if ( open_ulog() == OK )
		if ( read_user ( recno ) == OK )
			error_occurred = 0;                                             /* it worked OK */
	close_ulog ();
	MIOresume();
	if ( error_occurred ) {
		error_message = "Error reading Userlog!";
		return ( 0 );
    }
	return ( 1 );
}



/*======================================================================*
 *                                                                                                                                              *
 *              Write the user number specified from the temporary record area. *
 *                                                                                                                                              *
 *======================================================================*/

write_user_record ( int recno )
{
	byte error_occurred;
	MIOsuspend();
	close_ulog();
	error_occurred = 1;                                                             /* assume error */
	if ( open_ulog() == OK )
		if ( write_user ( recno ) == OK )
			error_occurred = 0;                                             /* it worked OK */
	close_ulog ();
	MIOresume();
	if ( recno == 1 )                                                               /* visitor record?      */
		move_temp_to_visitor();
	else if ( recno == 2 )                                                  /* new user record      */
		move_temp_to_new_user();
	if ( error_occurred ) {
		error_message = "Error writing to Userlog!";
		return ( 0 );
    }
	return ( 1 );
}


get_a_byte()
{
	byte x;
    echos ("New value: ");
	x = get_byte();
	cr_lf();
	return (x);
}


get_a_card()
{
	card x;
	echos ("New value: ");
	x = get_card();
	cr_lf();
	return (x);
}




move_user_to_edit()
{
#asm {
			ldy             #0
.loop:          lda             u_inuse,y
			sta             e_inuse,y
			iny
			bne             .loop
	}
}


move_temp_to_edit()
{
#asm {
			ldy             #0
.loop:          lda             t_inuse,y
			sta             e_inuse,y
			iny
			bne             .loop
	}
}


move_edit_to_user()
{
#asm {
			ldy             #0
.loop:          lda             e_inuse,y
			sta             u_inuse,y
			iny
			bne             .loop
	}
}


move_edit_to_temp()
{
#asm {
			ldy             #0
.loop:          lda             e_inuse,y
			sta             t_inuse,y
			iny
			bne             .loop
	}
}



move_temp_to_visitor()
{
#asm {
			ldy             #0
.loop:          lda             t_inuse,y
			sta             vis_rec,y
			iny
			bne             .loop
	}
}



move_temp_to_new_user()
{
#asm {
			ldy             #0
.loop:          lda             t_inuse,y
			sta             new_rec,y
			iny
			bne             .loop
	}
}


clear_edit_area()
{
#asm {
			ldy             #0
			tya
.loop:          sta             e_inuse,y
			iny
			bne             .loop
	}
}

