90 lines
2.0 KiB
C
90 lines
2.0 KiB
C
/* mudUtils.c - Utilities for Multithreaded Universal Daemon (MUD)*/
|
|
|
|
/* Copyright 1984-2007, 2010 Wind River Systems, Inc. */
|
|
|
|
/*
|
|
modification history
|
|
--------------------
|
|
01g,28apr10,m_z eliminate compile warning
|
|
01f,29jan10,m_z VxWorks 64-bit support
|
|
(WIND00193649)
|
|
01e,24feb07,msa Correct the apigen comments so they match the actual routines
|
|
and correct any apigen errors that may occur.
|
|
01d,02jan04,jws add mudlib.h include
|
|
01c,18dec03,adb included private/mudLibP.h
|
|
01b,02may03,jws remove assert()'s
|
|
01a,06sep01,jc written.
|
|
*/
|
|
|
|
/*
|
|
DESCRIPTION
|
|
|
|
Put a Multithreaded Universal Daemon in your life!
|
|
*/
|
|
/* include C standard library */
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
/* include OSAL */
|
|
#include "wm.h"
|
|
|
|
/* include public interface to mud */
|
|
#include "memPoolLib.h"
|
|
#include "private/mudLibP.h"
|
|
|
|
#include "mudLib.h" /* this is needed !! */
|
|
#include "mudUtils.h" /* this is needed !! */
|
|
|
|
/**************************************************************************
|
|
*
|
|
* readLineFromSocket - Read a line from a socket.
|
|
*
|
|
* Read a single LF (\n) terminated line from a socket and terminate
|
|
* it with a NULL
|
|
*
|
|
* RETURNS: OK, or ERROR.
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
STATUS readLineFromSocket
|
|
(
|
|
MUD_SOCKET sock,
|
|
char * buffer,
|
|
#ifndef _WRS_CONFIG_LP64
|
|
ubyte4 sizebuf
|
|
#else
|
|
ubyte8 sizebuf
|
|
#endif
|
|
)
|
|
{
|
|
char oneChar;
|
|
#ifndef _WRS_CONFIG_LP64
|
|
sbyte4 bytesRead;
|
|
ubyte4 bytesMsg;
|
|
#else
|
|
sbyte8 bytesRead;
|
|
ubyte8 bytesMsg;
|
|
#endif
|
|
STATUS status;
|
|
|
|
bytesMsg = 0;
|
|
|
|
/* read as much as we can from the socket, and send an acknowledgement */
|
|
|
|
wmnetSocketBlocking (sock, TRUE);
|
|
do
|
|
{
|
|
if (OK != (status = wmnetTcpRead (sock, &oneChar, 1, &bytesRead)))
|
|
return status;
|
|
|
|
buffer[bytesMsg] = oneChar;
|
|
bytesMsg++;
|
|
} while (('\n' != oneChar) && (bytesMsg <= sizebuf));
|
|
|
|
buffer[bytesMsg] = 0; /* terminate string */
|
|
return OK;
|
|
}
|
|
|
|
/* eof mudUtils.c */
|