예제 #1
0
/**
 * @brief
 *	The main function in C - entry point
 *
 * @param[in]  argc - argument count
 * @param[in]  argv - pointer to argument array
 * @param[in]  envp - pointer to environment values
 *
 * @return  int
 * @retval  0 - success
 * @retval  !0 - error
 */
int
main(int argc, char **argv, char **envp)
{
	char    jobid[PBS_MAXSVRJOBID + 1];
	char    pipename[PIPENAME_MAX_LENGTH] = "\\\\.\\pipe\\";
	char    pipename_append[] = "_pbs_demux_";
	int     rc = 0;	
	int     num_nodes = 0;

	if (argc < 3)
		exit(1);
	/*
	 * argv[1] is jobid
	 * argv[2] tells whether it is an interactive shell
	 * argv[3] is number of nodes for the job
	 */

	(void)strncpy_s(jobid, _countof(jobid), argv[1], _TRUNCATE);	
	num_nodes = atoi(argv[2]);

	(void)strncat_s(pipename, _countof(pipename), jobid, _TRUNCATE);
	(void)strncat_s(pipename, _countof(pipename), pipename_append, _TRUNCATE);
	while (1) {
		if (handle_np_conn(pipename, jobid, num_nodes) == -1) {
			exit(PBSE_SYSTEM);
		}
	}
	exit(0);
}
예제 #2
0
파일: xmodem.c 프로젝트: lifangbo/teraterm
void XSetOpt(PFileVar fv, PXVar xv, WORD Opt)
{
	char Tmp[21];

	xv->XOpt = Opt;

	strncpy_s(Tmp, sizeof(Tmp), "XMODEM (", _TRUNCATE);
	switch (xv->XOpt) {
	case XoptCheck:			/* Checksum */
		strncat_s(Tmp, sizeof(Tmp), "checksum)", _TRUNCATE);
		xv->DataLen = 128;
		xv->CheckLen = 1;
		break;
	case XoptCRC:				/* CRC */
		strncat_s(Tmp, sizeof(Tmp), "CRC)", _TRUNCATE);
		xv->DataLen = 128;
		xv->CheckLen = 2;
		break;
	case Xopt1K:				/* 1K */
		strncat_s(Tmp, sizeof(Tmp), "1K)", _TRUNCATE);
		xv->DataLen = 1024;
		xv->CheckLen = 2;
		break;
	}
	SetDlgItemText(fv->HWin, IDC_PROTOPROT, Tmp);
}
예제 #3
0
void ComplexDeviceCapsLine (char *pbuf, CAPSLOOKUP *pLkUp, int iMaxEntries,
                     int iValue, int iBuffSize)
{
  int  i;
  BOOL bNewLine = FALSE;

  for (i = 0; i < iMaxEntries; i++)

    if (iValue & (pLkUp + i)->iValue)
    {
      if (bNewLine)
      {
        //
        // Keep the first symbolic constant on the same line as the
        //   cap type, eg:  "TECHNOLOGY:     DT_RASDISPLAY".
        //

        strncpy_s (pbuf, iBuffSize, BLANKS, _countof(BLANKS));
        strncat_s (pbuf, iBuffSize, (pLkUp + i)->szValue, _TRUNCATE);
      }
      else
      {
        //
        // Put symbolic constant on new line, eg:
        //                  "                DT_RASPRINTER".
        //

        strncat_s (pbuf, iBuffSize, (pLkUp + i)->szValue, _TRUNCATE);
        bNewLine = TRUE;
      }
      SendDlgItemMessage (ghwndDevCaps, DID_LISTBOX, LB_INSERTSTRING,
                          (UINT)-1, (LONG_PTR) pbuf);
   }
}
예제 #4
0
void Log::LogDebugEvent( const DEBUG_EVENT& event )
{
    if ( event.dwDebugEventCode >= _countof( gEventNames ) )
        return;

    const char* eventName = gEventNames[event.dwDebugEventCode];
    char        msg[80] = "";
    char        part[80] = "";

    _snprintf_s( msg, _TRUNCATE, "%s (%d) : PID=%d, TID=%d", 
        eventName, 
        event.dwDebugEventCode, 
        event.dwProcessId, 
        event.dwThreadId );

    if ( event.dwDebugEventCode == EXCEPTION_DEBUG_EVENT )
    {
        _snprintf_s( part, _TRUNCATE, ", exc=%08x at %p", 
            event.u.Exception.ExceptionRecord.ExceptionCode,
            event.u.Exception.ExceptionRecord.ExceptionAddress );
        strncat_s( msg, part, _TRUNCATE );
    }

    printf( "%s\n", msg );

    strncat_s( msg, "\n", _TRUNCATE );
    OutputDebugStringA( msg );
}
예제 #5
0
파일: ymodem.c 프로젝트: lifangbo/teraterm
void YSetOpt(PFileVar fv, PYVar yv, WORD Opt)
{
	char Tmp[21];

	yv->YOpt = Opt;

	strncpy_s(Tmp, sizeof(Tmp),"YMODEM (", _TRUNCATE);
	switch (yv->YOpt) {
	case Yopt1K: /* YMODEM */
		strncat_s(Tmp,sizeof(Tmp),"1k)",_TRUNCATE);
		yv->__DataLen = STX_DATALEN;
		yv->DataLen = STX_DATALEN;
		yv->CheckLen = 2;
		break;
	case YoptG: /* YMODEM-g */
		strncat_s(Tmp,sizeof(Tmp),"-g)",_TRUNCATE);
		yv->__DataLen = STX_DATALEN;
		yv->DataLen = STX_DATALEN;
		yv->CheckLen = 2;
		break;
	case YoptSingle: /* YMODEM(-g) single mode */
		strncat_s(Tmp,sizeof(Tmp),"single mode)",_TRUNCATE);
		yv->__DataLen = STX_DATALEN;
		yv->DataLen = STX_DATALEN;
		yv->CheckLen = 2;
		break;
	}
	SetDlgItemText(fv->HWin, IDC_PROTOPROT, Tmp);
}
예제 #6
0
파일: user.cpp 프로젝트: eranheres/pb
double loopback_debug(const char* pquery) {
	char symbol[256];
	strncpy_s(symbol,"f$",250);
    strncat_s(symbol,&pquery[4],200);
	strncat_s(symbol,"_loopback",200);
	double val = GetSymbol(symbol);
	std::cout << "getting symbol:" << symbol << "=" << val << std::endl;
	return val;
}
예제 #7
0
/*
 *
 * returns resolution in gl format (ResX + 'x' + ResY + ':' + Bpp)
 *
 */
void Graphic::resolution(char c[16]) {
	char c2[8];
	_itoa_s(Options::ResolutionX, c,16, 10);
	_itoa_s(Options::ResolutionY, c2,8, 10);
	strncat_s(c, 16, "x",1);
	strncat_s(c, 16, c2,4);
	strncat_s(c, 16, ":",1);
	strncat_s(c, 16, "32",2);
}
예제 #8
0
	JString JString::operator+(const char* rhs)
	{
		JString ret;
		unsigned _lenTotal = nLength + strlen(rhs);
		ret.Init(_lenTotal);

		strncat_s(ret, ret.GetLength() + 1, pBuffer, nLength);
		strncat_s(ret, ret.GetLength() + 1, rhs, strlen(rhs));

		return ret;
	}
예제 #9
0
	JString JString::operator+(const JString& rhs)
	{
		JString ret;
		unsigned _lenTotal = nLength + rhs.GetLength();
		ret.Init(_lenTotal);

		strncat_s(ret, ret.GetLength() + 1, pBuffer, nLength);
		strncat_s(ret, ret.GetLength() + 1, rhs, rhs.GetLength());

		return ret;
	}
예제 #10
0
BOOL Pointer::ADDRawKeys(const char* owner, const char* classic, const char* lod)
{
	strncat_s(Vars.szKeyOwner, owner, strlen(owner)); //for add in later
	strncat_s(Vars.szClassic, classic, strlen(classic));
	strncat_s(Vars.szLod, lod, strlen(lod));

	if (classic && lod != NULL) {
		Pointer::InstallRawInfo();
		return true;
	}
	return false;
}
예제 #11
0
/*
  =======================================================================================
  =======================================================================================
*/
void set_description(HWND hDlg)
{
	char buff[512];

	strncpy_s(buff, sizeof(buff), "The output list file will be written to the same directory", _TRUNCATE);
	strncat_s(buff, sizeof(buff), " as the original because it will still be\r\n", _TRUNCATE);
	strncat_s(buff, sizeof(buff), " referencing the same image files.\r\n", _TRUNCATE);
	strncat_s(buff, sizeof(buff), "Change the random number seed to get different results", _TRUNCATE);
	strncat_s(buff, sizeof(buff), " for the same list file.", _TRUNCATE);

	SetDlgItemText(hDlg, IDC_DESCRIPTION, buff);

	sprintf_s(buff, sizeof(buff), "ShaveList %d.%d", MAJOR_VERSION, MINOR_VERSION);
	SetWindowText(hDlg, buff);
}
예제 #12
0
sfw::string & sfw::string::operator+=(const char * a)
{
	// TODO:
	resize(length() + strlen(a) + 1);
	strncat_s(m_data, m_size, a, strlen(a) + 1);
	return *this;
}
예제 #13
0
MIR_APP_DLL(HANDLE) ProtoCreateHookableEvent(PROTO_INTERFACE *pThis, const char* szName)
{
	char str[MAXMODULELABELLENGTH * 2];
	strncpy_s(str, pThis->m_szModuleName, _TRUNCATE);
	strncat_s(str, szName, _TRUNCATE);
	return CreateHookableEvent(str);
}
예제 #14
0
MIR_APP_DLL(void) ProtoCreateService(PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFunc serviceProc)
{
	char str[MAXMODULELABELLENGTH * 2];
	strncpy_s(str, pThis->m_szModuleName, _TRUNCATE);
	strncat_s(str, szService, _TRUNCATE);
	::CreateServiceFunctionObj(str, (MIRANDASERVICEOBJ)*(void**)&serviceProc, pThis);
}
예제 #15
0
LONG WINAPI InputLineWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	char inputBuffer[1024];

	switch ( uMsg )
	{
	case WM_KILLFOCUS:
		if ( ( HWND ) wParam == s_wcd.hWnd ||
			 ( HWND ) wParam == s_wcd.hwndErrorBox )
		{
			SetFocus( hWnd );
			return 0;
		}
		break;

	case WM_CHAR:
		if ( wParam == 13 )
		{
			GetWindowText( s_wcd.hwndInputLine, inputBuffer, sizeof( inputBuffer ) );
			strncat_s( s_wcd.consoleText, inputBuffer, sizeof( s_wcd.consoleText ) - strlen( s_wcd.consoleText ) - 5 );
			Q_strcat( s_wcd.consoleText, 512, "\n" );
			SetWindowText( s_wcd.hwndInputLine, "" );

			Sys_Print( va( "]%s\n", inputBuffer ) );

			return 0;
		}
	}

	return CallWindowProc( s_wcd.SysInputLineWndProc, hWnd, uMsg, wParam, lParam );
}
예제 #16
0
extern "C" HANDLE __stdcall RegisterAsEventSource(const char* szSource)
{
	const char* szSrc = szSource;
	static const char* szEventLogKeyBase = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\";
	
	char szEventLogKey[256+1];
	szEventLogKey[256] = 0;
	strcpy(szEventLogKey, szEventLogKeyBase);
	strncat_s(szEventLogKey, szSource, 256-strlen(szEventLogKeyBase));

	CRegKey rkeyRegistered;
	if (rkeyRegistered.Open(HKEY_LOCAL_MACHINE, szEventLogKey, KEY_READ) != ERROR_SUCCESS)
	{
		if (rkeyRegistered.Create(HKEY_LOCAL_MACHINE, szEventLogKey, REG_NONE, REG_OPTION_NON_VOLATILE,
									(KEY_READ|KEY_WRITE)) == ERROR_SUCCESS)
		{
			char vmFileName[MAX_PATH+1];
			::GetModuleFileName(_AtlBaseModule.GetModuleInstance(), vmFileName, sizeof(vmFileName) - 1);
			rkeyRegistered.SetStringValue("EventMessageFile", vmFileName);
			rkeyRegistered.SetDWORDValue("TypesSupported", (EVENTLOG_SUCCESS|EVENTLOG_ERROR_TYPE|
												EVENTLOG_WARNING_TYPE|EVENTLOG_INFORMATION_TYPE));
		}
		else
			szSrc = "Dolphin";
	}


	return RegisterEventSource(NULL, szSrc);
}
예제 #17
0
sfw::string & sfw::string::operator+=(const string & a)
{
	// TODO:
	resize(length() + a.m_size);
	strncat_s(m_data, m_size, a.m_data,a.m_size);
	return *this;
}
예제 #18
0
파일: compiler.c 프로젝트: yewton/tinyca
/**
 * コンパイルを行う
 * @param  char *file 書き出すファイル名
 * @return int        成否
 */
int compile(char *file) {
    ProgPtr pp = NULL;
    TEnvPtr tenv = NULL;
    TC_TypePtr ttp = NULL;
    TyType t = UNKNOWN_TYPE;
    FILE *ofp = NULL;
    char mes[MESSAGE_MAX_BUF_SIZE] = "";
    char ofile[FILE_NAME_MAX_SIZE] = "";
    char ext[] = ".j";

    /* 構文解析を実行 */
    pp = prog_alloc();
    if(0 == parse_prog(pp)) return 0;
    tenv = tenv_alloc();
    if( NULL != (ttp = typing_prog(tenv, pp)) ) {
        t = norm(ttp)->t;
    } else {
        printf("typing error.\n");
        return 0;
    }
    strncpy_s(ofile, FILE_NAME_MAX_SIZE, file, strlen(file));
    strncat_s(ofile, FILE_NAME_MAX_SIZE, ext, strlen(ext));
    if( 0 != fopen_s(&ofp, ofile, "w") ) {
        perror("fopen_s");
        return 0;
    }
    fprintf_s(ofp, ".class public %s\n", file);
    fprintf_s(ofp, ".super java/lang/Object\n", file);
    
    codegen_prog(ofp, file, t, pp, fenvc_alloc());
    fclose(ofp);
    return 1;
}
예제 #19
0
char *string_combine(char *string1, char *string2)
{
	size_t s1len, s2len;

	if (string2 == NULL)
	{
		// nothing to append
		return string1;
	}

	// TODO: what do we want to do if memory allocation fails?
	s2len = strlen(string2);
	if (string1 == NULL)
	{
		// create a new string
		string1 = (char *)malloc(s2len + 1);
		strncpy_s(string1, s2len + 1, string2, s2len + 1);
	}
	else
	{			   // append data to the string
		s1len = strlen(string1);
		string1 = (char *)realloc(string1, s1len + s2len + 1);
		strncat_s(string1, s1len + s2len + 1, string2, s2len + 1);
	}

	return string1;
}
예제 #20
0
PF_Err			
AEFX_AppendText(	
	A_char					*srcAC,				/* >> */
	const A_u_long			dest_sizeLu,		/* >> */
	A_char					*destAC,			/* <> */
	A_u_long				*current_indexPLu)	/* <> */
{
	PF_Err			err = PF_Err_NONE;

	A_u_long		new_strlenLu = strlen(srcAC) + *current_indexPLu;


	if (new_strlenLu <= dest_sizeLu) {
		destAC[*current_indexPLu] = 0x00;

#ifdef AE_OS_WIN
		strncat_s(destAC, dest_sizeLu, srcAC, strlen(srcAC));
#else
		strncat(destAC, srcAC, strlen(srcAC));
#endif
		*current_indexPLu = new_strlenLu;
	} else {
		err = AEFX_ParseError_APPEND_ERROR;
	}

	return err;
}
예제 #21
0
파일: ttmlib.c 프로젝트: lifangbo/teraterm
BOOL GetAbsPath(PCHAR FName, int destlen)
{
  int i, j;
  char Temp[MAXPATHLEN];

  if (! GetFileNamePos(FName,&i,&j)) {
    return FALSE;
  }
  if (strlen(FName) > 2 && FName[1] == ':') {
    // fullpath
    return TRUE;
  }
  else if (FName[0] == '\\' && FName[1] == '\\') {
    // UNC (\\server\path)
    return TRUE;
  }
  strncpy_s(Temp, sizeof(Temp), FName, _TRUNCATE);
  strncpy_s(FName,destlen,CurrentDir,_TRUNCATE);

  if (Temp[0] == '\\' && destlen > 2) {
    // from drive root (\foo\bar)
    FName[2] = 0;
  }
  else {
    AppendSlash(FName,destlen);
  }

  strncat_s(FName,destlen,Temp,_TRUNCATE);
  return TRUE;
}
예제 #22
0
	void Print(const FontData &ac_ttfFont, const int ac_iPosX, const int ac_iPosY, const bool ac_bAlign, const char* ac_szText)
	{
		std::vector<std::string> vsLines;

		char szHold[256];
		strcpy_s(szHold, "");

		const char* i;
		if ((i = strchr(ac_szText, 10)) != NULL)
		{
			strncat_s(szHold, ac_szText, int(i - ac_szText));
			vsLines.push_back(szHold);

			strcpy_s(szHold, i + 1);
			vsLines.push_back(szHold);
		}
		else
		{
			vsLines.push_back(ac_szText);
		}

		SDL_Surface* sdlSurface;
		GLSurface glSurface;
		// Write text to surface
		for (int j = 0; j < vsLines.size(); ++j)
		{
			sdlSurface = TTF_RenderText_Blended(ac_ttfFont.ttfFont, vsLines[j].c_str(), ac_ttfFont.sdlColor);
			
			glSurface = Graphics::LoadSurface(sdlSurface);

			Graphics::DrawSurface(glSurface, ac_iPosX - (ac_bAlign)*(glSurface.w), (ac_iPosY + (j * 15)) - (glSurface.h - 2));
		}

		glDeleteTextures(1, &glSurface.Surface);
	}
//-----------------------------------------------------------------------------
/// Generates an HTTP header according to the options stored in the Response
//-----------------------------------------------------------------------------
void GenerateHeader(Response& rResponse, char* pOut, DWORD dwBufferSize)
{
    strcpy_s(pOut, dwBufferSize, "HTTP/1.0 200 OK\r\n");

    if (rResponse.m_bSendNoCache == true)
    {
        strncat_s(pOut, dwBufferSize, "pragma: no-store, no-cache\r\n"
                  "cache-control: no-cache, no-store, must-revalidate, max-age = 0\r\n"
                  "expires: 0\r\n",
                  COMM_BUFFER_SIZE);
    }

    if (rResponse.m_bStreamingEnabled == true)
    {
        strncat_s(pOut, dwBufferSize, "Content-Type: multipart/x-mixed-replace; boundary=BoundaryString\r\n\r\n", COMM_BUFFER_SIZE);
    }
}
예제 #24
0
LPVOID loadDLL(char *dllName)
{
    char moduleFilename[MAX_PATH + 1];
    LPVOID ptrLoc = NULL;
    MZHeader mzH2;
    PE_Header peH2;
    PE_ExtHeader peXH2;
    SectionHeader *secHdr2;

    FNC(GetSystemDirectoryA)(moduleFilename, MAX_PATH);
    if((myStrlenA(moduleFilename) + myStrlenA(dllName)) >= MAX_PATH)
        return NULL;

    strncat_s(moduleFilename, MAX_PATH, dllName, MAX_PATH);

    // load this EXE into memory because we need its original Import Hint Table

    HANDLE fp;
    fp = FNC(CreateFileA)(moduleFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);

    if(fp != INVALID_HANDLE_VALUE)
    {
        BY_HANDLE_FILE_INFORMATION fileInfo;
        FNC(GetFileInformationByHandle)(fp, &fileInfo);

        DWORD fileSize = fileInfo.nFileSizeLow;
        if(fileSize)
        {
            LPVOID exePtr = HM_SafeVirtualAllocEx(FNC(GetCurrentProcess)(), NULL, fileSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
            if(exePtr)
            {
                DWORD read;

                if(FNC(ReadFile)(fp, exePtr, fileSize, &read, NULL) && read == fileSize)
                {
                    if(readPEInfo((char *)exePtr, &mzH2, &peH2, &peXH2, &secHdr2))
                    {
                        int imageSize = calcTotalImageSize(&mzH2, &peH2, &peXH2, secHdr2);

                        ptrLoc = HM_SafeVirtualAllocEx(FNC(GetCurrentProcess)(), NULL, imageSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
                        //ptrLoc = HeapAlloc(GetProcessHeap(), 0, imageSize);
                        if(ptrLoc)
                        {
                            loadPE((char *)exePtr, &mzH2, &peH2, &peXH2, secHdr2, ptrLoc);
                        }
                    }

                }
                //HeapFree(GetProcessHeap(), 0, exePtr);
                FNC(VirtualFreeEx)(FNC(GetCurrentProcess)(), exePtr, 0, MEM_RELEASE);
            }
        }
        CloseHandle(fp);
    }

    return ptrLoc;
}
예제 #25
0
파일: dbg.cpp 프로젝트: w4kfu/TESO_fun
void hexdump(void *data, int size)
{
  unsigned char *p = (unsigned char*)data;
    unsigned char c;
    int n;
    char bytestr[4] = {0};
    char addrstr[10] = {0};
    char hexstr[16 * 3 + 5] = {0};
    char charstr[16 * 1 + 5] = {0};

    for (n = 1; n <= size; n++)
  {
        if (n % 16 == 1)
    {
            sprintf_s(addrstr, sizeof(addrstr), "%.4x", ((unsigned int)p - (unsigned int)data));
        }
        c = *p;
        if (isalnum(c) == 0)
    {
            c = '.';
        }
        sprintf_s(bytestr, sizeof(bytestr), "%02X ", *p);
        strncat_s(hexstr, sizeof(hexstr), bytestr, sizeof(hexstr) - strlen(hexstr) - 1);
        sprintf_s(bytestr, sizeof(bytestr), "%c", c);
        strncat_s(charstr, sizeof(charstr), bytestr, sizeof(charstr) - strlen(charstr) - 1);
        if (n % 16 == 0)
    {
            dbg_msg("[%4.4s]   %-50.50s  %s\n", addrstr, hexstr, charstr);
            hexstr[0] = 0;
            charstr[0] = 0;
        }
    else if (n % 8 == 0)
    {
            strncat_s(hexstr, sizeof(hexstr), "  ", sizeof(hexstr)-strlen(hexstr)-1);
            strncat_s(charstr, sizeof(charstr), " ", sizeof(charstr)-strlen(charstr)-1);
        }
        p++;
    }

    if (strlen(hexstr) > 0)
    {
        dbg_msg("[%4.4s]   %-50.50s  %s\n", addrstr, hexstr, charstr);
    }
}
예제 #26
0
파일: dbg.cpp 프로젝트: w4kfu/hacnpx
VOID HexDumpPrintf(PVOID data, SSIZE_T size)
{
    unsigned char *p = (unsigned char*)data;
    unsigned char c;
    SSIZE_T n;
    char bytestr[4] = {0};
    char addrstr[10] = {0};
    char hexstr[16 * 3 + 5] = {0};
    char charstr[16 * 1 + 5] = {0};

    //EnterCriticalSection(&CriticalSection);
    //Write2File(data, size);
    //return;
    
    for (n = 1; n <= size; n++) {
        if (n % 16 == 1) {
            sprintf_s(addrstr, sizeof(addrstr), "%.4x", (unsigned int)((ULONG_PTR)p - (ULONG_PTR)data));
        }
        c = *p;
        if (isprint(c) == 0) {
            c = '.';
        }
        sprintf_s(bytestr, sizeof(bytestr), "%02X ", *p);
        strncat_s(hexstr, sizeof(hexstr), bytestr, sizeof(hexstr) - strlen(hexstr) - 1);
        sprintf_s(bytestr, sizeof(bytestr), "%c", c);
        strncat_s(charstr, sizeof(charstr), bytestr, sizeof(charstr) - strlen(charstr) - 1);
        if (n % 16 == 0) {
            //DbgMsg("[%4.4s]   %-50.50s  %s\n", addrstr, hexstr, charstr);
            printf("[%4.4s]   %-50.50s  %s\n", addrstr, hexstr, charstr);
            hexstr[0] = 0;
            charstr[0] = 0;
        }
        else if (n % 8 == 0) {
            strncat_s(hexstr, sizeof(hexstr), "  ", sizeof(hexstr)-strlen(hexstr)-1);
        }
        p++;
    }
    if (strlen(hexstr) > 0) {
        //DbgMsg("[%4.4s]   %-50.50s  %s\n", addrstr, hexstr, charstr);
        printf("[%4.4s]   %-50.50s  %s\n", addrstr, hexstr, charstr);
    }
    //LeaveCriticalSection(&CriticalSection);
}
예제 #27
0
/*
  =======================================================================================
  Map coordinates of the edge by first marking the first coordinate, and then using
  the following mapping, all of the remaining coordinates using 1 byte each.

  4 | 3 | 2
  5 | 0 | 1
  6 | 7 | 8
  =======================================================================================
*/
bool PixelChain::write(HANDLE fh, int id)
{
	char buff[256], temp[32];
	unsigned long bytesWritten;
	int len;
	
	if (!fh) {
		return false;
	}

	memset(buff, 0, sizeof(buff));
	sprintf_s(buff, sizeof(buff), "%d,%d", id, _numPoints);
	
	if (_numPoints > 1) {
		sprintf_s(temp, sizeof(temp), ",%d,%d", _pt[0].x, _pt[0].y);
		strncat_s(buff, sizeof(buff), temp, _TRUNCATE);

		len = strlen(buff);
		memset(buff + len, 0, sizeof(buff) - len);

		if (_numPoints > 2) {
			buff[len] = ',';
			len++;
		
			for (int i = 1; i < _numPoints; i++) {
				buff[len] = '0' + mapPointMovement(i - 1);
				len++;

				if (len > sizeof(buff) - 4) {
					WriteFile(fh, buff, len, &bytesWritten, NULL);
					memset(buff, 0, sizeof(buff));
					len = 0;
				}
			}
		}
	}

	strncat_s(buff, sizeof(buff), "\r\n", _TRUNCATE);

	WriteFile(fh, buff, strlen(buff), &bytesWritten, NULL);

	return true;
}
예제 #28
0
파일: zmodem.c 프로젝트: lifangbo/teraterm
static void add_sendbuf(char *fmt, ...)
{
	va_list arg;
	char buf[128];

	va_start(arg, fmt);
	vsnprintf(buf, sizeof(buf), fmt, arg);
	strncat_s(sendbuf, sizeof(sendbuf), buf, _TRUNCATE);
	va_end(arg);
}
예제 #29
0
파일: zmodem.c 프로젝트: lifangbo/teraterm
static void show_sendbuf(PFileVar fv)
{
	char *s;

	s = sendbuf;
	strncat_s(sendbuf, sizeof(sendbuf), "\015\012", _TRUNCATE);
	_lwrite(fv->LogFile, s, strlen(s));

	memset(sendbuf, 0, sizeof(sendbuf));
}
예제 #30
0
파일: compiler.c 프로젝트: yewton/tinyca
void newlabel(char *dest, const char *label) {
    int i = current_labelnum;
    char labelnum[LABEL_NAME_MAX_SIZE] = "";
    current_labelnum = i + 1;
    sprintf_s(labelnum, LABEL_NAME_MAX_SIZE, "%d", i);

    strncpy_s(dest, LABEL_NAME_MAX_SIZE, label, strlen(label));
    strncat_s(dest, LABEL_NAME_MAX_SIZE, labelnum, strlen(labelnum));
    return;
}