home *** CD-ROM | disk | FTP | other *** search
- /* *
- * *
- * Copyright 1987, 1988, 1989 Netwise, Inc. *
- * All Rights Reserved *
- * This software contains information which is proprietary to and a trade *
- * secret of Netwise, Inc. It is not to be used, reproduced, or disclosed *
- * except as authorized in your license agreement. *
- * *
- * Restricted Rights Legend *
- * Use, duplication, or disclosure by the Government is subject to *
- * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in *
- * Technical Data and Computer Software clause at 252.227-7013, or the *
- * equivalent Government clause for other agencies. *
- * Contractor: Netwise, Inc., Boulder, CO 80301 USA *
- * *
- */
- /*
- * File: tutorial\server\rproc.c
- *
- * This example runs in the following environment:
- * NetWare RPC 1.0, NetWare 2.1 or higher, DOS 3.3
- *
- * This file contains the remote procedures for the tutorial example.
- *
- */
-
- #include <stdio.h>
- #include "database.h" /* server header file,
- created by RPC compiler */
-
- int recerr; /* external variable used by append_record */
-
- static struct employee_record database_record[MAXREC+1];
-
- void
- init()
- {
- /* Database initialization procedure; executes as a local
- * procedure of the server program
- */
- database_record[0].employee_name[0] = '\0';
- }
-
- int
- shut_down_server()
- {
- /* Procedure added to allow client program to
- * terminate server program when user exits
- */
- extern int shut_down;
-
- /* shut_down set to TRUE tells server control program
- * that server program is to terminate
- */
- shut_down = TRUE;
- return(SUCCESS);
- }
-
- int
- get_record (name, record_ptr)
- char name[NAMESIZE]; /* employee name */
- struct employee_record **record_ptr; /* upon return, set to ptr
- * to employee record */
- {
- /* retrieve an employee record from the database */
-
- struct employee_record *ptr;
-
- ptr = database_record;
- while (ptr->employee_name[0] != '\0') {
- if (strcmp(ptr->employee_name, name))
- ptr++;
- else {
- *record_ptr = ptr;
- return (SUCCESS);
- }
- }
- /* set value of record pointer to NULL to indicate that
- * no structure is being returned
- */
- *record_ptr = NULL;
- return (ERROR);
- }
-
- int
- append_record (record_ptr)
- struct employee_record *record_ptr; /* ptr to record to add */
- {
- /* add an employee record to the database */
-
- struct employee_record *ptr;
-
- /* look through database for duplicate employee names
- * or numbers, and find room for a new record
- */
- ptr = database_record;
- while (ptr->employee_name[0] != '\0') {
- if (strcmp(ptr->employee_name,
- record_ptr->employee_name) == 0) {
- recerr = OLDNAME;
- return (ERROR);
- }
- if (record_ptr->employee_type == PERMANENT) {
- if (ptr->employee_info.employee_id ==
- record_ptr->employee_info.employee_id) {
- recerr = OLDNUM;
- return (ERROR);
- }
- }
- if (++ptr > &database_record[MAXREC]) {
- recerr = DBFULL;
- return (ERROR);
- }
- }
-
- /* add employee record to database */
- *ptr = *record_ptr;
- (++ptr)->employee_name[0] = '\0';
- return (SUCCESS);
- }
-