Ejemplo n.º 1
0
  void MetaGenericEvent::debug()
  {
    switch(metaType())
      {
      case MIDI_METAEVENT_PORT:
	cout << "\tMIDI Port" << endl;
	cout << "\t\tPort: " << paramUInt(0) << endl;
	break;
      case MIDI_METAEVENT_TIMESIGNATURE:
	cout << "\tTime Signature" << endl;
	cout << "\t\tNumerator: " << paramUInt(0) << endl;
	cout << "\t\tDenominator: " << paramUInt(1) << endl;
	cout << "\t\tMetronome: " << paramUInt(2) << endl;
	cout << "\t\t32nds: " << paramUInt(3) << endl;
	break;
      case MIDI_METAEVENT_KEYSIGNATURE:
	cout << "\tKey Signature" << endl;
	cout << "\t\tKey: " << paramInt(0) << endl;
	cout << "\t\tScale: " << paramUInt(1) << endl;
	break;
      case MIDI_METAEVENT_ENDOFTRACK:
	cout << "\tEnd of Track" << endl;
	break;
      default:
	cout << "\tGeneric Meta Event 0x" << setbase(16) << (unsigned int)metaType() << endl;
	for(int i=0;i<_dataLength;i++)
	  {
	    cout << "\t\t0x" << setbase(16) << paramInt(i) << endl;
	  }
	break;
      }
  }
Ejemplo n.º 2
0
ostream& ostream::operator<<(const void* ptr)
{
	unsigned oldbase = getbase();
	setbase(BS_HEX);
	size_t addr = (size_t)ptr;
	*this << addr;
	setbase(oldbase);
	return *this;
}
Ejemplo n.º 3
0
static char * proc_args(int argc, char *const argv[])
{
    int optc;

    while ((optc = getopt_long(argc, argv, "o:f:hv", longopts, NULL)) != -1) {
        switch (optc) {
        case 'o':
            setbase(optarg);
            break;
        case 'f':
            setfam(optarg);
            break;
        case 'v':
            print_version();
            exit(EXIT_SUCCESS);
            break;
        case 'h':
            print_help();
            exit(EXIT_SUCCESS);
            break;
        default:
            break;
        }
    }

    if (optind == argc)
        usage();

    return argv[optind];
}
void printhex(string fileName,int pageNo)
{
	ifstream fd;
	fd.open(fileName.c_str(),ios::binary);
	if(!fd)
	{
		cerr<<"\n File does not exist.....";
		return;
	}
	fd.seekg(0,ifstream::end);
	long size = fd.tellg();
	int no_pages = size/PAGESIZE;
	fd.seekg((pageNo-1)*PAGESIZE,ifstream::beg);
	//unsigned char *buffer = new unsigned char[PAGESIZE];
	char *buf = new char[PAGESIZE];
	fd.read(buf,PAGESIZE);
	unsigned char *buffer = reinterpret_cast<unsigned char *>(buf);
	//fd.read(buffer,PAGESIZE);
	for(int i=0; i<size; i+=16)
	{
		cout<<setfill('0')<<setw(4)<<setbase(16)<<i<<"  ";
		
		for(int j=0;j<16;j++){
			cout<<setfill('0')<<setw(2)<<hex<<int(buffer[i+j]);
			cout<<" ";
		}
		cout<<setbase(10);
		cout<<endl;
	}
	/*printf("\n");
	for(int i=0;i<size;i+=16)
	{
		printf("%04x ",i);
		for(int j=0;j<16;j++)
			printf("%02x ",(unsigned char)*(buf+i+j));
		printf("  ");
		for(int j=0;j<16;j++)
			printf("%c",isprint(*(buf+i+j))?*(buf+i+j):'.');
		printf("\n");
	}*/
	fd.close();
	delete buf;
}
Ejemplo n.º 5
0
string int_to_string(int value, int base, bool prefix)
{
	stringstream conv;
	if (prefix) {
		switch (base) {
		case 2: conv << "0b"; break;
		case 8: conv << "0"; break;
		case 16: conv << "0x"; break;
		}
	}
	conv << setbase(base) << value;

	string result;
	conv >> result;
	return result;
}
Ejemplo n.º 6
0
BOOL CConfig::SetLoginInfo( LPCTSTR strUserId, LPCTSTR strPw, EStreamType eStreamType )
{
	BOOL bResult = TRUE;
	bResult &= this->WriteConfig( CONFIG_ENTRY_USER, strUserId );
	bResult &= this->WriteConfig( CONFIG_ENTRY_STREAMTYPE, eStreamType );

	// 加密密码。
	int nPasswordByteLen = ( _tcslen( strPw ) + 1 ) * sizeof( strPw[0] );
	// 补齐。
	const int nEncLenUnit = 16;
	int nBufByteLen = ( nPasswordByteLen / nEncLenUnit + 1 ) * nEncLenUnit;
	unsigned char *pDateBuf = new unsigned char[ nBufByteLen ];
	_tcscpy( (LPTSTR)pDateBuf, strPw );

	tean_enc( s_EncKey, (char*)pDateBuf, nBufByteLen );

	// 将加密后的密码看作16进制数字写入配置文件。
	tstring strSavePw;
    
	for ( int i=0; i<nBufByteLen; ++i )
	{
        tstringstream ssSavePw;
		//		Log() << pDateBuf[i] ;
		//TCHAR tmpBuf[10] = {0};
		//_stprintf( tmpBuf,  _T("%02X" ), pDateBuf[i] );
        ssSavePw << setbase( 16 ) << (void*)(int)pDateBuf[i];
        tstring strTmp = ssSavePw.str();
        strTmp = strTmp.substr( strTmp.length() -2 );
		strSavePw += strTmp;
	}

	
//	Log() << endl;




	bResult &= this->WriteConfig( CONFIG_ENTRY_PW, strSavePw.c_str() );

	delete[] pDateBuf;
	pDateBuf = NULL;

	return ( TRUE == bResult);
}
Ejemplo n.º 7
0
// UpDownWndProc:
//
LRESULT CALLBACK UpDownWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    RECT rc;
    int i;
    PUDSTATE np = (PUDSTATE)GetWindowInt(hwnd, 0);

    if (np) {
        if ((uMsg >= WM_MOUSEFIRST) && (uMsg <= WM_MOUSELAST) &&
            (np->ci.style & UDS_HOTTRACK) && !np->fTrackSet) {

            TRACKMOUSEEVENT tme;

            np->fTrackSet = TRUE;

            tme.cbSize = sizeof(tme);
            tme.hwndTrack = np->ci.hwnd;
            tme.dwFlags = TME_LEAVE;

            TrackMouseEvent(&tme);
        }
    }

    switch (uMsg)
    {

    case WM_MOUSEMOVE:
        UD_OnMouseMove(np, lParam);
        break;

    case WM_MOUSELEAVE:
        np->fTrackSet = FALSE;
        UD_Invalidate(np, np->uHot, FALSE);
        np->uHot = UD_HITNOWHERE;
        break;

    case WM_LBUTTONDOWN:
    {
        // Don't set a timer if on the middle border
        BOOL bTimeIt = TRUE;

        if (np->hwndBuddy && !IsWindowEnabled(np->hwndBuddy))
            break;

        SetCapture(hwnd);
        getint(np);

        switch (np->uClass)
        {
        case CLASS_EDIT:
        case CLASS_LISTBOX:
            SetFocus(np->hwndBuddy);
            break;
        }

        switch(UD_HitTest(np, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) {
        case UD_HITDOWN:
            np->bDown = TRUE;
            squish(np, FALSE, TRUE);
            break;

        case UD_HITUP:
            np->bDown = FALSE;
            squish(np, TRUE, FALSE);
            break;

        case UD_HITNOWHERE:
            bTimeIt = FALSE;
            break;
        }

        if (bTimeIt)
        {
            SetTimer(hwnd, 1, GetProfileInt(TEXT("windows"), TEXT("CursorBlinkRate"), 530), NULL);
            bump(np);
        }
        break;
    }

    case WM_TIMER:
    {
        POINT pt;

        if (GetCapture() != hwnd)
        {
            goto EndScroll;
        }

        SetTimer(hwnd, 1, 100, NULL);

        GetWindowRect(hwnd, &rc);
        if (np->ci.style & UDS_HORZ) {
            i = (rc.left + rc.right) / 2;
            if (np->bDown)
            {
                rc.right = i;
            }
            else
            {
                rc.left = i;
            }
        } else {
            i = (rc.top + rc.bottom) / 2;
            if (np->bDown)
            {
                rc.top = i;
            }
            else
            {
                rc.bottom = i;
            }
        }
        InflateRect(&rc, (g_cxFrame+1)/2, (g_cyFrame+1)/2);
        GetCursorPos(&pt);
        if (PtInRect(&rc, pt))
        {
            squish(np, !np->bDown, np->bDown);
            bump(np);
        }
        else
        {
            squish(np, FALSE, FALSE);
        }
        break;
    }

    case WM_LBUTTONUP:
        if (np->hwndBuddy && !IsWindowEnabled(np->hwndBuddy))
            break;

        if (GetCapture() == hwnd)
        {
EndScroll:
            squish(np, FALSE, FALSE);
            ReleaseCapture();
            KillTimer(hwnd, 1);

            if (np->uClass == CLASS_EDIT)
                Edit_SetSel(np->hwndBuddy, 0, -1);

                        if (np->ci.style & UDS_HORZ)
                            FORWARD_WM_HSCROLL(np->ci.hwndParent, np->ci.hwnd,
                                      SB_ENDSCROLL, np->nPos, SendMessage);
                        else
                            FORWARD_WM_VSCROLL(np->ci.hwndParent, np->ci.hwnd,
                                      SB_ENDSCROLL, np->nPos, SendMessage);
        }
        break;

    case WM_ENABLE:
        InvalidateRect(hwnd, NULL, TRUE);
        break;

    case WM_WININICHANGE:
        if (np && (!wParam ||
            (wParam == SPI_SETNONCLIENTMETRICS) ||
            (wParam == SPI_SETICONTITLELOGFONT))) {
            InitGlobalMetrics(wParam);
            unachor(np);
            anchor(np);
        }
        break;

    case WM_PRINTCLIENT:
    case WM_PAINT:
        PaintUpDownControl(np, (HDC)wParam);
        break;

    case UDM_SETRANGE:
        np->nUpper = GET_X_LPARAM(lParam);
        np->nLower = GET_Y_LPARAM(lParam);
        nudge(np);
        break;

    case UDM_GETRANGE:
        return MAKELONG(np->nUpper, np->nLower);

    case UDM_SETBASE:
        // wParam: new base
        // lParam: not used
        // return: 0 if invalid base is specified,
        //         previous base otherwise
        return (LRESULT)setbase(np, (UINT)wParam);

    case UDM_GETBASE:
        return np->nBase;

    case UDM_SETPOS:
    {
        int iNewPos = GET_X_LPARAM(lParam);
        if (compare(np, np->nLower, np->nUpper, DONTCARE) < 0) {

            if (compare(np, iNewPos, np->nUpper, DONTCARE) > 0) {
                iNewPos = np->nUpper;
            }

            if (compare(np, iNewPos, np->nLower, DONTCARE) < 0) {
                iNewPos = np->nLower;
            }
        } else {
            if (compare(np, iNewPos, np->nUpper, DONTCARE) < 0) {
                iNewPos = np->nUpper;
            }

            if (compare(np, iNewPos, np->nLower, DONTCARE) > 0) {
                iNewPos = np->nLower;
            }
        }

        i = np->nPos;
        np->nPos = iNewPos;
        setint(np);
#ifdef ACTIVE_ACCESSIBILITY
        MyNotifyWinEvent(EVENT_OBJECT_VALUECHANGE, np->ci.hwnd, OBJID_CLIENT, 0);
#endif
        return (LRESULT)i;
    }

    case UDM_GETPOS:
        return getint(np);

    case UDM_SETBUDDY:
        return setbuddy(np, (HWND)wParam);

    case UDM_GETBUDDY:
        return (LRESULT)(int)np->hwndBuddy;

    case UDM_SETACCEL:
            if (wParam == 0)
                return(FALSE);
            if (wParam >= NUM_UDACCELS)
            {
                HANDLE npPrev = (HANDLE)np;
                np = (PUDSTATE)LocalReAlloc((HLOCAL)np, sizeof(UDSTATE)+(wParam-NUM_UDACCELS)*sizeof(UDACCEL),
                    LMEM_MOVEABLE);
                if (!np)
                {
                    return(FALSE);
                }
                else
                {
                    SetWindowInt(hwnd, 0, (int)np);

                    if ((np->ci.style & UDS_ARROWKEYS) && np->hwndBuddy)
                    {
                        SetWindowSubclass(np->hwndBuddy, ArrowKeyProc, 0,
                            (DWORD)np);
                    }
                }
            }

            np->nAccel = wParam;
        for (i=0; i<(int)wParam; ++i)
        {
                np->udAccel[i] = ((LPUDACCEL)lParam)[i];
        }
        return(TRUE);

    case UDM_GETACCEL:
        if (wParam > np->nAccel)
        {
            wParam = np->nAccel;
        }
        for (i=0; i<(int)wParam; ++i)
        {
            ((LPUDACCEL)lParam)[i] = np->udAccel[i];
        }
        return(np->nAccel);

    case WM_NOTIFYFORMAT:
        return CIHandleNotifyFormat(&np->ci, lParam);

    case WM_CREATE:
        // Allocate the instance data space.
        np = (PUDSTATE)LocalAlloc(LPTR, sizeof(UDSTATE));
        if (!np)
            return -1;

        SetWindowInt(hwnd, 0, (int)np);

            #define lpCreate ((CREATESTRUCT FAR *)lParam)

        CIInitialize(&np->ci, hwnd, lpCreate);

        // np->fUp =
        // np->fDown =
            // np->fUnsigned =
            // np->fSharedBorder =
            // np->fSunkenBorder =
        //  FALSE;

        if (lpCreate->dwExStyle & WS_EX_CLIENTEDGE)
            np->fSunkenBorder = TRUE;

        np->nBase = BASE_DECIMAL;
        np->nUpper = 0;
        np->nLower = 100;
        np->nPos = 0;
        np->hwndBuddy = NULL;
        np->uClass = CLASS_UNKNOWN;

            np->nAccel = NUM_UDACCELS;
            np->udAccel[0].nSec = 0;
            np->udAccel[0].nInc = 1;
        np->udAccel[1].nSec = 2;
            np->udAccel[1].nInc = 5;
            np->udAccel[2].nSec = 5;
            np->udAccel[2].nInc = 20;

        /* This does the pickbuddy and anchor
         */
        setbuddy(np, NULL);
        setint(np);
        break;

    case WM_DESTROY:
        if (np) {
            if (np->hwndBuddy)
            {
                // Make sure that our buddy is unsubclassed.
                DebugMsg(DM_ERROR, TEXT("UpDown Destroyed while buddy subclassed"));
                np->fUpDownDestroyed = TRUE;
            }
            else
                LocalFree((HLOCAL)np);
            SetWindowInt(hwnd, 0, 0);
        }
        break;

    default:
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }

    return 0L;
}
Ejemplo n.º 8
0
int invoke(char * args[]){
	int i = 0;
	int j = 0;	
	int fileDescriptor;
	int standardOut;	
	int aux;
	int background = 0;	
	char *args_aux[256];	
	while ( args[j] != NULL){
		if ( (strcmp(args[j],">") == 0) || (strcmp(args[j],"<") == 0) || (strcmp(args[j],"&") == 0)){
			break;
		}
		args_aux[j] = args[j];
		j++;
	}
	if(strcmp(args[0],"exit") == 0) exit(0);
 	else if (strcmp(args[0],"pwd") == 0){
		if (args[j] != NULL){
			if ( (strcmp(args[j],">") == 0) && (args[j+1] != NULL) ){
				fileDescriptor = open(args[j+1], O_CREAT | O_TRUNC | O_WRONLY, 0600); 
				standardOut = dup(STDOUT_FILENO); 	
				dup2(fileDescriptor, STDOUT_FILENO); 
				close(fileDescriptor);
				printf("%s\n", getcwd(currentDirectory, 1024));
				dup2(standardOut, STDOUT_FILENO);
			}
		}else{
			printf("%s\n", getcwd(currentDirectory, 1024));
		}
	} 
	else if (strcmp(args[0],"clear") == 0) system("clear");
	else if (strcmp(args[0],"cd") == 0) changeDirectory(args);
	else if (strcmp(args[0],"environ") == 0){
		if (args[j] != NULL){
			if ( (strcmp(args[j],">") == 0) && (args[j+1] != NULL) ){
				fileDescriptor = open(args[j+1], O_CREAT | O_TRUNC | O_WRONLY, 0600); 
				standardOut = dup(STDOUT_FILENO);
				dup2(fileDescriptor, STDOUT_FILENO); 
				close(fileDescriptor);
				setbase(args,0);
				dup2(standardOut, STDOUT_FILENO);
			}
		}else{
			setbase(args,0);
		}
	}

	else if (strcmp(args[0],"setenv") == 0) setbase(args,1);
	else if (strcmp(args[0],"unsetenv") == 0) setbase(args,2);
	else{
		while (args[i] != NULL && background == 0){
			if (strcmp(args[i],"&") == 0){
				background = 1;
			}else if (strcmp(args[i],"|") == 0){
				processpipes(args);
				return 1;
			}else if (strcmp(args[i],"<") == 0){
				aux = i+1;
				if (args[aux] == NULL || args[aux+1] == NULL || args[aux+2] == NULL ){
					printf("check input arguments\n");
					return -1;
				}else{
					if (strcmp(args[aux+1],">") != 0){
						printf("Usage: Expected '>' and found %s\n",args[aux+1]);
						return -2;
					}
				}
				fileIO(args_aux,args[i+1],args[i+3],1);
				return 1;
			}			
			else if (strcmp(args[i],">") == 0){
				if (args[i+1] == NULL){
					printf("check input arguments\n");
					return -1;
				}
				fileIO(args_aux,NULL,args[i+1],0);
				return 1;
			}
			i++;
		}
		fireprogram(args_aux,background);
		
	}
return 1;
}
Ejemplo n.º 9
0
	Rfid::RfidStatusCode Rfid::listen(void)
	{
		(*_pLinkToConsole)->printLog("start void Rfid::listen(void)");

		uint8_t SN[10];
		uint8_t SN_len=0;

		uint8_t use_gpio=1;
		uint8_t gpio=18;

		uint16_t CType=0;

		int tmp, i;
		char status;
		char str[255];
		char *p;
		char sn_str[23];

		while(_statusCode == RfidStatusCode::NONE)
		{
			status = find_tag(&CType);

			if(status==TAG_NOTAG)
			{
				usleep(200000);
				continue;
			}
			else if((status!=TAG_OK) && (status!=TAG_COLLISION))
			{
				continue;
			}

			if(select_tag_sn(SN, &SN_len)!=TAG_OK)
			{
				continue;
			}

			p=sn_str;
			for(tmp=0; tmp<SN_len; tmp++)
			{
				sprintf(p, "%02x", SN[tmp]);
				p+=2;
			}
			*(p++)=0;

			/*
			if(use_gpio){
				bcm2835_gpio_write(gpio, HIGH);
			}
			*/

			_outStream << "Tag found ";
			_outStream << "[type: " << setfill('0') << setw(4) << setbase(16) << CType << ", ";
			_outStream << "SNlen: " << setbase(10) << int(SN_len) << ", ";
			_outStream << "SN: " << int(SN) << "] ";
			_outStream << "SN: " << sn_str;
			(*_pLinkToConsole)->printOut(&_outStream);

			string serial(sn_str);
			rfidSignal(serial);

			p=str;
			PcdHalt();
			if (use_gpio){
				bcm2835_gpio_write(gpio, LOW);
			}
		}

		(*_pLinkToConsole)->printLog("end void Rfid::listen(void)");
	}
Ejemplo n.º 10
0
void main(void)
 {
   cout << setbase(8) << 255 << '\n';
   cout << setbase(10) << 255 << '\n';
   cout << setbase(16) << 255 << '\n';
 }
/// <summary>
/// <para name='Name'>ResolveDisplayName</para>
/// <para name='Purpose'>Get an email address from a Display Name</para>
/// </summary>
/// <param name='szName'>Display Name to resolve</param>
/// <param name='szEmailAddress'>[out] Returned email address</param>
/// <returns>HRESULT</returns>
/// <remarks>
/// <para name='Notes'></para>
/// <para name='Author'>Kenn Guilstorf</para>
/// <para name='LastModified'>28Jan2016</para>
/// </remarks>
STDMETHODIMP ZybraxiSoft::CMailbox::ResolveDisplayName(TSTRING szName, TSTRING &szEmailAddress)
{
	HRESULT hr = S_OK;
	LPADRBOOK lpAdrBook = NULL;
	LPADRLIST lpAdrList = NULL;
	TSTRING szEX = TSTRING(_T("EX"));
	bool isExchange = false;

	enum
	{
		prDISPLAY_NAME,
		NUM_PROPS
	};

	// Check to make sure we have something in szName
	if (szName.empty() || szName.size() <= 0)
	{
		hr = MAPI_E_INVALID_PARAMETER;
		goto EXIT;
	}

	// Log what we're trying to resolve
	m_log << output::both << level::Informational <<
		"Attempting to resolve '" << szName.c_str() << "'" << endl;

	// Open the address book
	// See: https://msdn.microsoft.com/en-us/library/office/cc815381.aspx
	if (SUCCEEDED(hr = m_lpSession->OpenAddressBook(
		NULL,				// ulUIParam [may be NULL]
		NULL,				// lpInterface [may be NULL; returns IAddrBook:IMAPIProp]
		NULL,				// ulFlags [NULL means no flags]
		&lpAdrBook)))		// lppAdrBook [out]
	{
		// Allocate the address list
		// Note: I like to use 'this' so I know which functions I'm responsible
		//       for if I ever have to work on this...
		if (SUCCEEDED(hr = this->AllocAdrList(
			NUM_PROPS,
			&lpAdrList)))
		{
			// Even though we succeeded, do a check to make sure we have
			//  an address list
			if (lpAdrList)
			{
				lpAdrList->cEntries = 1;	// only looking for 1 entry
				lpAdrList->aEntries[0].cValues = NUM_PROPS;		// Number of props

				// Set the SPropValue to whom we're looking for
				lpAdrList->aEntries[0].rgPropVals[prDISPLAY_NAME].ulPropTag =
					PR_DISPLAY_NAME;
				lpAdrList->aEntries[0].rgPropVals[prDISPLAY_NAME].Value.LPSZ =
					(LPTSTR)szName.c_str();

				// Let's try to resolve the name now
				if (SUCCEEDED(hr = lpAdrBook->ResolveName(
					0L,
					MAPI_UNICODE,
					NULL,
					lpAdrList)))
				{
					m_log << output::both << level::Informational <<
						"Resolve name yielded " <<
						lpAdrList->aEntries[0].cValues <<
						" properties." << endl;

					for (UINT i = 0; i < lpAdrList->aEntries[0].cValues; i++)
					{
						// Store the property so I don't have to type so much...
						SPropValue spvCurrent = lpAdrList->aEntries[0].rgPropVals[i];

						m_log << output::both << level::Informational <<
							"Found Property '0x" <<
							setfill(_T('0')) << setw(8) << setbase(16) <<
							spvCurrent.ulPropTag << "'";

						switch (spvCurrent.ulPropTag)
						{
						case PR_ADDRTYPE:
							if (szEX.compare(spvCurrent.Value.LPSZ) == 0)
								isExchange = true;
							break;
						case PR_DISPLAY_NAME:
							m_log << ": " << spvCurrent.Value.LPSZ;
							break;
						case PR_EMAIL_ADDRESS:
							m_log << ": " << spvCurrent.Value.LPSZ;
							szEmailAddress = TSTRING(spvCurrent.Value.LPSZ);
							break;
						default:
							if (((spvCurrent.ulPropTag & 0x1f) == 0x1f) ||
								((spvCurrent.ulPropTag & 0x1e) == 0x1e))
								m_log << ": " << spvCurrent.Value.LPSZ;
							break;
						}

						m_log << endl;
					}

					if (!isExchange || (szEmailAddress.empty()))
					{
						hr = MAPI_E_NOT_FOUND;
						goto CLEANUP;
					}
				}
				else
				{
					FATAL(_T("lpAdrBook->ResolveName()"), hr);
					goto CLEANUP;
				}
			}
		}
		else
		{
			FATAL(_T("AllocAdrList()"), hr);
			goto CLEANUP;
		}
	}
	else
	{
		FATAL(_T("OpenAddressBook()"), hr);
	}

CLEANUP:
	if (lpAdrList)
	{
		FreePadrlist(lpAdrList);
		lpAdrList = NULL;
	}

	if (lpAdrBook)
	{
		lpAdrBook->Release();
		lpAdrBook = NULL;
	}

EXIT:
	return hr;
}
Ejemplo n.º 12
0
  void ChannelEvent::debug()
  {
    switch(_command)
      {
      case MIDI_CHEVENT_INVALID:
	cout << "\tInvalid MIDI Channel Event" << endl;
	break;
      case MIDI_CHEVENT_NOTEOFF:
	cout << "\tEnd Note " << setbase(10) << _param1 << endl;
	cout << "\t\tVelocity: " << setbase(10) << _param2 << endl;
	break;
      case MIDI_CHEVENT_NOTEON:
	cout << "\tStart Note " << setbase(10) << _param1 << endl;
	cout << "\t\tVelocity: " << setbase(10) << _param2 << endl;
	break;
      case MIDI_CHEVENT_NOTEAFTERTOUCH:
	cout << "\tNote Aftertouch" << setbase(10) << _param1 << endl;
	cout << "\t\tValue: " << setbase(10) << _param2 << endl;
	break;
      case MIDI_CHEVENT_CONTROLLER:
	cout << "\tController Event" << endl;
	cout << "\t\tChannel: " << setbase(10) << _channel << endl;
	cout << "\t\tType: 0x" << setbase(16) << _param1 << endl;
	cout << "\t\tValue: 0x" << setbase(16) << _param2 << endl;
	break;
      case MIDI_CHEVENT_PROGRAMCHANGE:
	cout << "\tProgram Change to " << setbase(10) << _param1 << endl;
	break;
      case MIDI_CHEVENT_CHANNELAFTERTOUCH:
	cout << "\tChannel Aftertouch" << endl;
	cout << "\t\tValue: " << setbase(10) << _param1 << endl;
	break;
      case MIDI_CHEVENT_PITCHBEND:
	cout << "\tPitch Bend" << endl;
	cout << "\t\tPitch Value (MSB): " << setbase(10) << _param1 << endl;
	cout << "\t\tPitch Value (LSB): " << setbase(10) << _param2 << endl;
	break;
      default:
	cout << "\tUnknown MIDI Channel Event" << endl;
	cout << "\t\tCommand: 0x" << setbase(16) << (unsigned int)_command << endl;
	cout << "\t\tChannel: " << setbase(10) << _channel << endl;
	cout << "\t\tParam 1: 0x" << setbase(16) << _param1 << endl;
	cout << "\t\tParam 2: 0x" << setbase(16) << _param2 << endl;
	break;
      }   
  }
Ejemplo n.º 13
0
bool write(std::ostream & out, const mp_world & world, const Options & opts){

  // converting some fields from UTF8 to default codepage
  // setting CodePage to default_codepage;

  string codepage="1251";
  codepage=world.Opts.get("CodePage", codepage);     // override by file setting
  codepage=opts.get("mp_out_codepage", codepage); // override by user setting
  IConv cnv("CP" + codepage);

  for (vector<string>::const_iterator c = world.Comment.begin();
       c!=world.Comment.end(); c++) out << ";" << cnv.from_utf8(*c) << "\n";
//cerr <<"Name" << world.Name << "->" << cnv.from_utf8(world.Name) << "\n";
  out << setprecision(6) << fixed
      << "\r\n[IMG ID]"
      << "\r\nID="              << world.ID
      << "\r\nName="            << cnv.from_utf8(world.Name);

  // we need options to be printed in right order (Levels before Level0...)
  Options lopts=world.Opts; //copy options

  const char* names[] = {"ID","Name","Elevation","Preprocess","CodePage",
    "LblCoding","TreSize","TreMargin","RgnLimit","POIIndex","Levels",
    "Level0","Level1","Level2","Level3","Level4","Level5","Level6",
    "Zoom0","Zoom1","Zoom2","Zoom3","Zoom4","Zoom5","Zoom6"};

  for (int i=0; i<sizeof(names)/sizeof(char*); i++){
    if (lopts.count(names[i])>0){
      if (strcmp(names[i],"CodePage")==0)
        out << "\r\nCodePage=" << codepage; // use our new codepage
      else
        out << "\r\n" << names[i] << "=" << cnv.from_utf8(lopts[names[i]]);
      lopts.erase(names[i]);
    }
  }
  // other options
  for (Options::const_iterator o=lopts.begin(); o!=lopts.end(); o++){
    out << "\r\n" << o->first << "=" << cnv.from_utf8(o->second);
  }

  out << "\r\n[END-IMG ID]\r\n";

  for (mp_world::const_iterator i=world.begin(); i!=world.end(); i++){
    for (vector<string>::const_iterator c = i->Comment.begin();
         c!=i->Comment.end(); c++) out << ";" << cnv.from_utf8(*c) << "\n";
    out << "\r\n[" << i->Class << "]"
        << "\r\nType=0x"     << setbase(16) << i->Type << setbase(10);
    if (i->Label != "") out << "\r\nLabel=" << cnv.from_utf8(i->Label);
    if (i->EL != 0)     out << "\r\nEndLevel=" << i->EL;

    for (Options::const_iterator o=i->Opts.begin(); o!=i->Opts.end(); o++){
      out << "\r\n" << o->first << "=" << cnv.from_utf8(o->second);
    }

    for (dMultiLine::const_iterator l=i->begin(); l!=i->end(); l++){
      out << "\r\nData" << i->BL << "="; 
      for (int j=0; j<l->size(); j++){
        out << ((j!=0)?",":"") << "(" 
            << (*l)[j].y << "," << (*l)[j].x << ")";
      }
    }

    out << "\r\n[END]\r\n";
  }
  return true;
}