示例#1
0
/*
	ReloadString()

	Ricarica dal registro il valore stringa associato alla chiave, aggiornando l'elemento
	corrispondente della lista.
*/
LPCSTR CConfig::ReloadString(LPCSTR lpcszRootKey,LPCSTR section,LPCSTR name,LPCSTR defaultvalue/*=NULL*/)
{
	char key[_MAX_PATH+1];
	static char value[_MAX_PATH+1];
	LONG reg;

	memset(key,'\0',sizeof(key));
	_snprintf(key,sizeof(key)-1,"%s\\%s",lpcszRootKey,section);
	memset(value,'\0',sizeof(value));

	m_pRegistry->Attach(HKEY_CURRENT_USER);

	if((reg = m_pRegistry->Open(HKEY_CURRENT_USER,key))==ERROR_SUCCESS)
	{
		memset(value,'\0',sizeof(value));
		DWORD valuesize = sizeof(value);
		if(m_pRegistry->QueryValue(value,name,&valuesize)!=ERROR_SUCCESS)
		{
			if(defaultvalue)
				strcpyn(value,defaultvalue,sizeof(value));
			else
				memset(value,'\0',sizeof(value));
			m_pRegistry->SetValue(value,name);
		}

		strcpyn(value,(char*)UpdateString(section,name,value),sizeof(value));
		
		m_pRegistry->Close();
	}

	m_pRegistry->Detach();

	return(value);
}
示例#2
0
void StartButtonInit(int height)
{
  Picture *p = NULL;
  int pw;

  /* some defaults */
  if (StartName  == NULL) UpdateString(&StartName, "Start");
  if (StartPopup == NULL) UpdateString(&StartPopup, "StartMenu");
  if (StartIconName == NULL) UpdateString(&StartIconName, "mini-start.xpm");

  p = GetPicture(dpy, Root, IconPath, PixmapPath, StartIconName);

  StartButton = (Button *)ButtonNew(StartName, p, BUTTON_UP, 0);
  if (p != NULL) pw = p->width+3; else pw = 0;
  StartButtonWidth = XTextWidth(ButtonFont, StartName, strlen(StartName)) + pw + 14;
  StartButtonHeight = height;
}
示例#3
0
文件: Start.c 项目: att/uwin
void StartButtonInit(int height)
{
  Picture *p = NULL;
  int pw;

  /* some defaults */
  if (StartName  == NULL)
    UpdateString(&StartName, "Start");
  if (StartPopup == NULL)
    UpdateString(&StartPopup, "StartMenu");
  if (StartIconName == NULL)
    UpdateString(&StartIconName, "mini-start.xpm");

  /** FIXME: what should the colour limit be?
      I put in -1, which apparently imposes NO limit.
  **/
  p = GetPicture(dpy, win, ImagePath, StartIconName, -1);

  StartButton = (Button *)ButtonNew(StartName, p, BUTTON_UP,0);
  if (p != NULL) pw = p->width+3; else pw = 0;
  StartButtonWidth = XTextWidth(ButtonFont, StartName, strlen(StartName)) +
    pw + 14;
  StartButtonHeight = height;
}
示例#4
0
void VDPositionControlW32::InternalSetPosition(VDPosition pos, VDPositionControlEventData::EventType eventType) {
	if (pos < mRangeStart)
		pos = mRangeStart;
	if (pos > mRangeEnd)
		pos = mRangeEnd;

	if (pos != mPosition) {
		mPosition = pos;
		RecalcThumbRect(pos, true);
		UpdateString();

		VDPositionControlEventData eventData;
		eventData.mPosition = mPosition;
		eventData.mEventType = eventType;
		mPositionUpdatedEvent.Raise(this, eventData);
	}
}
示例#5
0
void VDPositionControlW32::SetRange(VDPosition lo, VDPosition hi, bool updateNow) {
	if (lo != mRangeStart || hi != mRangeEnd) {
		mRangeStart = lo;
		mRangeEnd = hi;
		if (mPosition < mRangeStart)
			mPosition = mRangeStart;
		if (mPosition > mRangeEnd)
			mPosition = mRangeEnd;
		if (mSelectionStart < mRangeStart)
			mSelectionStart = mRangeStart;
		if (mSelectionEnd > mRangeEnd)
			mSelectionEnd = mRangeEnd;

		RecomputeMetrics();
		UpdateString();
	}
}
示例#6
0
	void AddPages(int nPage)
	{
		if( nPage <= 0 )
			return;

		if( m_nFirstPageInGroup == 0 )
		{
			m_nCurrentPage = m_nFirstPageInGroup = nPage;
		}
		else if( nPage == ( m_nCurrentPage + 1 ) )
		{
			m_nCurrentPage = nPage;
		}
		else
		{
			UpdateString();

			m_nCurrentPage = m_nFirstPageInGroup = nPage;
		}
	}
示例#7
0
void InitGoodies(void)
{
	struct passwd *pwent;
	char tmp[1024];

	if (mailpath == NULL)
	{
		strcpy(tmp, DEFAULT_MAIL_PATH);
		pwent = getpwuid(getuid());
		strcat(tmp, (char *) (pwent->pw_name));
		UpdateString(&mailpath, tmp);
	}

	CreateOrUpdateGoodyGC();
	if (clockfmt)
	{
		if (!do_display_clock)
		{
			clock_width = 0;
		}
		else
		{
			struct tm *tms;
			static time_t timer;
			static char str[24];
			time(&timer);
			tms = localtime(&timer);
			strftime(str, 24, clockfmt, tms);
			clock_width = FlocaleTextWidth(
				FStatusFont, str, strlen(str)) + 4;
		}
	}
	else
	{
		clock_width = FlocaleTextWidth(FStatusFont, "XX:XX", 5) + 4;
	}
	goodies_width += clock_width;
	stwin_width = goodies_width;
}
示例#8
0
void StartButtonInit(int height)
{
  FvwmPicture *p = NULL;
  int pw;
  FvwmPictureAttributes fpa;
  StartAndLaunchButtonItem *tempPtr;

  fpa.mask = FPAM_NO_ALLOC_PIXELS;

  /* if no start button params were specified, trick the program into
   * thinking that they were */
  if (First_Start_Button == NULL && !NoDefaultStartButton)
  {
    StartButtonParseConfig("*FvwmTaskBarStartName Start");
    StartButtonParseConfig("*FvwmTaskBarStartMenu RootMenu");
    StartButtonParseConfig("*FvwmTaskBarStartIcon mini.start.xpm");
  }
  /* some defaults */
  if (First_Start_Button && First_Start_Button->isStartButton == True)
  {
    if (First_Start_Button->buttonCaption == NULL)
      UpdateString(&(First_Start_Button->buttonCaption), "Start");
    if (First_Start_Button->buttonIconFileName == NULL)
      UpdateString(&(First_Start_Button->buttonIconFileName), "mini-start.xpm");
  }

  tempPtr = First_Start_Button;

  while(tempPtr != NULL)
  {
	  p = PGetFvwmPicture(
		  dpy, win, ImagePath, tempPtr->buttonIconFileName, fpa);
	  if (p != NULL && strlen(tempPtr->buttonCaption) != 0)
	  {
		  /* icon and title */
		  pw = p->width + 12;
	  }
	  else if (p != NULL)
	  {
		  /* just icon */
		  pw = p->width + 8;
	  }
	  else
	  {
		  /* just title */
		  pw = 10;
	  }

    tempPtr->buttonItem = (Button *)ButtonNew(
	    tempPtr->buttonCaption, p, BUTTON_UP,0);
    if (tempPtr->isStartButton)
    {
	    StartButton = tempPtr->buttonItem;
	    tempPtr->width = FlocaleTextWidth(
		    FSelButtonFont, tempPtr->buttonCaption,
		    strlen(tempPtr->buttonCaption)) + pw;
    }
    else
    {
	    tempPtr->width = FlocaleTextWidth(
		    FButtonFont, tempPtr->buttonCaption,
		    strlen(tempPtr->buttonCaption)) + pw;
    }
    tempPtr->height = height;
    StartAndLaunchButtonsWidth += tempPtr->width;
    tempPtr=tempPtr->tail;
    PFreeFvwmPictureData(p); /* should not destroy of course */
  }
  if (First_Start_Button)
  {
	  StartAndLaunchButtonsWidth += StartButtonRightMargin;
	  First_Start_Button->height = height;
	  StartAndLaunchButtonsHeight = First_Start_Button->height;
  }
  else
  {
    StartAndLaunchButtonsWidth = 0;
    StartButtonRightMargin = 0;
    if (has_wb_left_margin == 0)
    {
      WindowButtonsLeftMargin = 0;
    }
    if (has_wb_right_margin == 0)
    {
      WindowButtonsRightMargin = 0;
    }
  }
}
示例#9
0
/**
  Create or update a String Token in a String Package.

  If *Reference == 0, a new String Token is created.

  @param This            A pointer to the EFI_HII_PROTOCOL instance.
  @param Language        Pointer to a NULL-terminated string containing a single ISO 639-2 language
                         identifier, indicating the language to print. A string consisting of
                         all spaces indicates that the string is applicable to all languages.
  @param Handle          The handle of the language pack to which the string is to be added.
  @param Reference       The string token assigned to the string.
  @param NewString       The string to be added.


  @retval EFI_SUCCESS             The string was effectively registered.
  @retval EFI_INVALID_PARAMETER   The Handle was unknown. The string is not created or updated in the
                                  the string package.
**/
EFI_STATUS
EFIAPI
HiiNewString (
  IN     EFI_HII_PROTOCOL           *This,
  IN     CHAR16                     *Language,
  IN     FRAMEWORK_EFI_HII_HANDLE   Handle,
  IN OUT STRING_REF                 *Reference,
  IN     CHAR16                     *NewString
  )
{
  EFI_STATUS                                Status;
  HII_THUNK_PRIVATE_DATA                    *Private;
  EFI_GUID                                  TagGuid;
  LIST_ENTRY                                *Link;
  HII_THUNK_CONTEXT                          *ThunkContext;
  HII_THUNK_CONTEXT                          *StringPackThunkContext;
  EFI_STRING_ID                             StringId;
  EFI_STRING_ID                             LastStringId;
  CHAR8                                     AsciiLanguage[ISO_639_2_ENTRY_SIZE + 1];
  CHAR16                                    LanguageCopy[ISO_639_2_ENTRY_SIZE + 1];
  CHAR8                                     *Rfc4646AsciiLanguage;

  LastStringId      = (EFI_STRING_ID) 0;
  StringId          = (EFI_STRING_ID) 0;
  Rfc4646AsciiLanguage = NULL;

  if (Language != NULL) {
    ZeroMem (AsciiLanguage, sizeof (AsciiLanguage));;
    ZeroMem (LanguageCopy, sizeof (LanguageCopy));
    CopyMem (LanguageCopy, Language, ISO_639_2_ENTRY_SIZE * sizeof (CHAR16));
    UnicodeStrToAsciiStr (LanguageCopy, AsciiLanguage);
    Rfc4646AsciiLanguage = ConvertLanguagesIso639ToRfc4646 (AsciiLanguage);
    ASSERT (Rfc4646AsciiLanguage != NULL);
  }

  Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);

  StringPackThunkContext = FwHiiHandleToThunkContext (Private, Handle);
  if (StringPackThunkContext == NULL) {
    return EFI_INVALID_PARAMETER;
  }

  if (StringPackThunkContext->SharingStringPack) {
    Status = GetTagGuidByFwHiiHandle (Private, Handle, &TagGuid);
    ASSERT_EFI_ERROR (Status);

    Link = GetFirstNode (&Private->ThunkContextListHead);
    while (!IsNull (&Private->ThunkContextListHead, Link)) {
      ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);

      if (CompareGuid (&TagGuid, &ThunkContext->TagGuid)) {
        if (ThunkContext->SharingStringPack) {
          StringId = *Reference;
          Status = UpdateString (ThunkContext, Rfc4646AsciiLanguage, NewString, &StringId);
          if (EFI_ERROR (Status)) {
            break;
          }
          
          DEBUG_CODE_BEGIN ();
          if (*Reference == 0) {
            //
            // When creating new string token, make sure all created token is the same
            // for all string packages registered using FW HII interface.
            //
            if (LastStringId == (EFI_STRING_ID) 0) {
              LastStringId = StringId;
            } else {
              if (LastStringId != StringId) {
                ASSERT(FALSE);
              }
            }
          }
          DEBUG_CODE_END ();
          
        }
      }

      Link = GetNextNode (&Private->ThunkContextListHead, Link);
    }
  } else {
    StringId = *Reference;
    Status = UpdateString (StringPackThunkContext, Rfc4646AsciiLanguage, NewString, &StringId);
  }

  if (!EFI_ERROR (Status)) {
    if (*Reference == 0) {
      *Reference = StringId;
    }
  } else {
    //
    // Only EFI_INVALID_PARAMETER is defined in HII 0.92 specification.
    //
    Status = EFI_INVALID_PARAMETER;
  }
  
  return Status;
}
示例#10
0
/* Parse 'goodies' specific resources */
Bool GoodiesParseConfig(char *tline)
{
  char *rest;
  char *option;
  int i;

  option = tline + module->namelen+1;
  i = GetTokenIndex(option, goodyopts, -1, &rest);
  while (*rest && *rest != '\n' && isspace(*rest))
    rest++;
  switch(i)
  {
  case 0: /* BellVolume */
    BellVolume = atoi(rest);
    break;
  case 1: /* Mailbox */
    if (strcasecmp(rest, "None") == 0)
    {
      has_mailpath = False;
    }
    else
    {
      int len;

      UpdateString(&mailpath, rest);
      len = strlen(mailpath);
      if (len > 0 && mailpath[len-1] == '\n')
	mailpath[len-1] = 0;
      has_mailpath = True;
    }
    do_check_mail = (has_mailpath && (mailcheck_interval > 0));
    break;
  case 2: /* Mailcheck */
    mailcheck_interval = MAILCHECK_DEFAULT;
    sscanf(rest, "%d", &mailcheck_interval);
    do_check_mail = (has_mailpath && (mailcheck_interval > 0));
    break;
  case 3: /* ClockFormat */
    UpdateString(&clockfmt, rest);
    do_display_clock = True;
    if (clockfmt && clockfmt[0] == '\0' && datefmt && datefmt[0] == '\0')
    {
	    do_display_clock = False;
    }
    break;
  case 4: /* StatusFont */
    CopyStringWithQuotes(&statusfont_string, rest);
    break;
  case 5: /* TipsFore */
    CopyString(&TipsFore, rest);
    tipscolorset = -1;
    break;
  case 6: /* TipsBack */
    CopyString(&TipsBack, rest);
    tipscolorset = -1;
    break;
  case 7: /* TipsColorset */
    tipscolorset = -1;
    tipscolorset = atoi(rest);
    AllocColorset(tipscolorset);
    break;
  case 8: /* MailCommand */
    CopyString(&MailCmd, rest);
    break;
  case 9: /* IgnoreOldMail */
    IgnoreOldMail = True;
    break;
  case 10: /* ShowTips */
    ShowTips = True;
    break;
  case 11: /* DateFormat */
    UpdateString(&datefmt, rest);
    do_display_clock = True;
    if (clockfmt && clockfmt[0] == '\0' && datefmt && datefmt[0] == '\0')
    {
	    do_display_clock = False;
    }
    break;
  case 12: /* MailDir */
    using_MailDir = True;
    break;
  default:
    /* unknown option */
    return False;
  } /* switch */

  return True;
}
示例#11
0
LRESULT CALLBACK VDPositionControlW32::WndProc(UINT msg, WPARAM wParam, LPARAM lParam) {
	switch(msg) {
	case WM_CREATE:
		OnCreate();
		// fall through
	case WM_SIZE:
		OnSize();
		break;

	case WM_PAINT:
		OnPaint();
		return 0;

	case WM_NOTIFY:
		if (TTN_GETDISPINFO == ((LPNMHDR)lParam)->code) {
			NMTTDISPINFO *lphdr = (NMTTDISPINFO *)lParam;
			UINT id = (lphdr->uFlags & TTF_IDISHWND) ? GetWindowLong((HWND)lphdr->hdr.idFrom, GWL_ID) : lphdr->hdr.idFrom;

			*lphdr->lpszText = 0;

			SendMessage(lphdr->hdr.hwndFrom, TTM_SETMAXTIPWIDTH, 0, 5000);

			for(int i=0; i<sizeof g_posctltips/sizeof g_posctltips[0]; ++i) {
				if (id == g_posctltips[i].id)
					lphdr->lpszText = const_cast<char *>(g_posctltips[i].tip);
			}

			return TRUE;
		}
		break;

	case WM_COMMAND:
		{
			UINT cmd;
			VDPositionControlEventData::EventType eventType = VDPositionControlEventData::kEventNone;

			switch(LOWORD(wParam)) {
			case IDC_STOP:			cmd = PCN_STOP;			break;
			case IDC_PLAY:			cmd = PCN_PLAY;			break;
			case IDC_PLAYPREVIEW:	cmd = PCN_PLAYPREVIEW;	break;
			case IDC_MARKIN:		cmd = PCN_MARKIN;		break;
			case IDC_MARKOUT:		cmd = PCN_MARKOUT;		break;

			case IDC_START:
				cmd = PCN_START;
				if (mbAutoStep)
					InternalSetPosition(mRangeStart, VDPositionControlEventData::kEventJumpToStart);
				break;

			case IDC_BACKWARD:
				cmd = PCN_BACKWARD;
				if (mbAutoStep)
					InternalSetPosition(mPosition - 1, VDPositionControlEventData::kEventJumpToPrev);
				break;

			case IDC_FORWARD:
				cmd = PCN_FORWARD;
				if (mbAutoStep)
					InternalSetPosition(mPosition + 1, VDPositionControlEventData::kEventJumpToNext);
				break;

			case IDC_END:
				cmd = PCN_END;
				if (mbAutoStep)
					InternalSetPosition(mRangeEnd, VDPositionControlEventData::kEventJumpToEnd);
				break;

			case IDC_KEYPREV:
				cmd = PCN_KEYPREV;
				eventType = VDPositionControlEventData::kEventJumpToPrevKey;
				break;

			case IDC_KEYNEXT:
				cmd = PCN_KEYNEXT;
				eventType = VDPositionControlEventData::kEventJumpToNextKey;
				break;

			case IDC_SCENEREV:
				cmd = PCN_SCENEREV;
				if (BST_UNCHECKED!=SendMessage((HWND)lParam, BM_GETCHECK, 0, 0)) {
					if (IsDlgButtonChecked(mhwnd, IDC_SCENEFWD))
						CheckDlgButton(mhwnd, IDC_SCENEFWD, BST_UNCHECKED);
				} else
					cmd = PCN_SCENESTOP;
				break;
			case IDC_SCENEFWD:
				cmd = PCN_SCENEFWD;
				if (BST_UNCHECKED!=SendMessage((HWND)lParam, BM_GETCHECK, 0, 0)) {
					if (IsDlgButtonChecked(mhwnd, IDC_SCENEREV))
						CheckDlgButton(mhwnd, IDC_SCENEREV, BST_UNCHECKED);
				} else
					cmd = PCN_SCENESTOP;
				break;
			default:
				return 0;
			}

			SendMessage(GetParent(mhwnd), WM_COMMAND, MAKELONG(GetWindowLong(mhwnd, GWL_ID), cmd), (LPARAM)mhwnd);
		}
		break;

	case WM_LBUTTONDOWN:
		{
			POINT pt = {(SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)};

			if (PtInRect(&mThumbRect, pt)) {
				mDragOffsetX = pt.x - mThumbRect.left;
				mDragMode = kDragThumbFast;
				SetCapture(mhwnd);

				Notify(PCN_BEGINTRACK, VDPositionControlEventData::kEventNone);
				InvalidateRect(mhwnd, &mThumbRect, TRUE);
			} else if (PtInRect(&mPositionArea, pt)) {
				mPosition = (sint64)floor((pt.x - mTrack.left) * mFramesPerPixel + 0.5);
				if (mPosition < mRangeStart)
					mPosition = mRangeStart;
				if (mPosition > mRangeEnd)
					mPosition = mRangeEnd;
				if (mbAutoFrame)
					UpdateString();
				RecalcThumbRect(mPosition);
				Notify(PCN_THUMBPOSITION, VDPositionControlEventData::kEventJump);
				InvalidateRect(mhwnd, &mThumbRect, TRUE);
			}
		}
		break;

	case WM_RBUTTONDOWN:
		{
			POINT pt = {(SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)};

			if (PtInRect(&mThumbRect, pt)) {
				mDragOffsetX = pt.x - mThumbRect.left;
				mDragAnchorPos = mPosition;
				mDragMode = kDragThumbSlow;
				mDragAccum = 0;
				SetCapture(mhwnd);

				Notify(PCN_BEGINTRACK, VDPositionControlEventData::kEventNone);
				InvalidateRect(mhwnd, &mThumbRect, TRUE);
				ShowCursor(FALSE);
			}
		}
		break;

	case WM_MOUSEMOVE:
		if (mDragMode == kDragThumbFast) {
			POINT pt = {(SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)};

			int x = pt.x - mDragOffsetX;

			if (x < mTrack.left - mThumbWidth)
				x = mTrack.left - mThumbWidth;
			if (x > mTrack.right - mThumbWidth)
				x = mTrack.right - mThumbWidth;

			if (x != mThumbRect.left) {
				if (mbAutoFrame) {
					InvalidateRect(mhwnd, &mThumbRect, TRUE);
					mThumbRect.right = x + (mThumbRect.right - mThumbRect.left);
					mThumbRect.left = x;
					InvalidateRect(mhwnd, &mThumbRect, TRUE);
					UpdateWindow(mhwnd);
				}

				sint64 pos = VDRoundToInt64((x - mTrack.left + mThumbWidth) * mFramesPerPixel);
				if (pos > mRangeEnd)
					pos = mRangeEnd;
				if (pos < mRangeStart)
					pos = mRangeStart;
				if (mPosition != pos) {
					mPosition = pos;

					if (mbAutoFrame)
						UpdateString();

					Notify(PCN_THUMBTRACK, VDPositionControlEventData::kEventTracking);
				}
			}
		} else if (mDragMode == kDragThumbSlow) {
			POINT pt = {(SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)};

			mDragAccum += (pt.x - (mThumbRect.left + mDragOffsetX));
			int delta = mDragAccum / 8;
			mDragAccum -= delta * 8;

			if (delta) {
				SetPosition(mDragAnchorPos += delta);
				Notify(PCN_THUMBTRACK, VDPositionControlEventData::kEventTracking);
			}
			
			pt.x = mThumbRect.left + mDragOffsetX;
			ClientToScreen(mhwnd, &pt);
			SetCursorPos(pt.x, pt.y);
		}
		break;

	case WM_CAPTURECHANGED:
		if ((HWND)lParam == mhwnd)
			break;
	case WM_MOUSELEAVE:
	case WM_RBUTTONUP:
	case WM_LBUTTONUP:
		if (mDragMode) {
			if (mDragMode == kDragThumbSlow)
				ShowCursor(TRUE);

			mDragMode = kDragNone;
			ReleaseCapture();

			Notify(PCN_ENDTRACK, VDPositionControlEventData::kEventNone);
			InvalidateRect(mhwnd, &mThumbRect, TRUE);
		}
		break;

	case WM_MOUSEWHEEL:
		{
			mWheelAccum -= (SHORT)HIWORD(wParam);

			int increments = mWheelAccum / WHEEL_DELTA;

			if (increments) {
				mWheelAccum -= WHEEL_DELTA * increments;

				SetPosition(mPosition + increments);

				if (increments < 0)
					Notify(PCN_THUMBPOSITIONPREV, VDPositionControlEventData::kEventJump);
				else
					Notify(PCN_THUMBPOSITIONNEXT, VDPositionControlEventData::kEventJump);
			}
		}
		return 0;
	}

	return DefWindowProc(mhwnd, msg, wParam, lParam);
}
示例#12
0
void VDPositionControlW32::SetFrameRate(const VDFraction& frameRate) {
	mFrameRate = frameRate;
	if (mhwnd)
		UpdateString();
}
示例#13
0
void VDPositionControlW32::SetDisplayedPosition(VDPosition pos) {
	UpdateString(pos);
	RecalcThumbRect(pos, true);
	if (mhwnd)
		UpdateWindow(mhwnd);
}
示例#14
0
/*
	Import()

	Importa la configurazione corrente dal file specificato.
*/
BOOL	CConfig::Import(LPCSTR lpcszRootKey,LPCSTR lpcszFileName)
{
	BOOL bLoaded = FALSE;
	FILE* fp;

	if((fp = fopen(lpcszFileName,"r"))!=(FILE*)NULL)
	{
		char* p;
		char szBuffer[REGKEY_MAX_SECTION_NAME+REGKEY_MAX_KEY_NAME+REGKEY_MAX_KEY_VALUE+16];
		char szSection[REGKEY_MAX_SECTION_NAME+1];
		char szName[REGKEY_MAX_KEY_NAME+1];
		char szValue[REGKEY_MAX_KEY_VALUE+1];
		char szType[5];

		// legge la prima linea controllando se si tratta di un file di configurazione
		fgets(szBuffer,sizeof(szBuffer)-1,fp);
		if((p = strchr(szBuffer,'\r'))==NULL)
			p = strchr(szBuffer,'\n');
		if(p)
			*p = '\0';
		if(strcmp(szBuffer,"[Configuration File]")!=0)
		{
			fclose(fp);
			return(bLoaded);
		}

		// legge il file di configurazione per linee
		while(fgets(szBuffer,sizeof(szBuffer)-1,fp))
		{
			if((p = strchr(szBuffer,'\r'))==NULL)
				p = strchr(szBuffer,'\n');
			if(p)
				*p = '\0';
			
			// estrae i valori dalla linea (sezione, chiave, valore, tipo)
			memset(szSection,'\0',sizeof(szSection));
			memset(szName,'\0',sizeof(szName));
			memset(szValue,'\0',sizeof(szValue));
			memset(szType,'\0',sizeof(szType));

			p = strrchr(szBuffer,';');
			if(p)
			{
				strcpyn(szType,p+1,sizeof(szType));
				*p = '\0';
			}
			p = strrchr(szBuffer,';');
			if(p)
			{
				strcpyn(szValue,p+1,sizeof(szValue));
				*p = '\0';
			}
			p = strrchr(szBuffer,';');
			if(p)
			{
				strcpyn(szName,p+1,sizeof(szName));
				*p = '\0';
			}
			p = szBuffer;
			if(p)
				strcpyn(szSection,p,sizeof(szSection));

			if(szSection[0]!='\0' && szName[0]!='\0' && szValue[0]!='\0' && szType[0]!='\0')
			{
				if(strcmp(szType,"SZ")==0)
				{
					if(strcmp(UpdateString(szSection,szName,szValue),"")==0)
					{
						CONFIG* c = (CONFIG*)m_plistConfig->Add();
						if(c)
							c->Init(szSection,szName,szValue);
					}
				}
				else if(strcmp(szType,"DW")==0)
				{
					if(UpdateNumber(szSection,szName,strtoul(szValue,NULL,0))==(DWORD)-1)
					{
						CONFIG* c = (CONFIG*)m_plistConfig->Add();
						if(c)
							c->Init(szSection,szName,strtoul(szValue,NULL,0));
					}
				}
			}
		}

		fclose(fp);
		
		Save(lpcszRootKey);
		
		bLoaded = TRUE;
	}

	return(bLoaded);
}
示例#15
0
	CStdString GetPageNumbers( void )
	{
		UpdateString();

		return m_sResult;
	}