config.cpp
Upload User: jinandeyu
Upload Date: 2007-01-05
Package Size: 620k
Code Size: 2k
Category:

Remote Control

Development Platform:

WINDOWS

  1. /*  Back Orifice 2000 - Remote Administration Suite
  2.     Copyright (C) 1999, Cult Of The Dead Cow
  3.     This file is free software, and not subject to GNU Public License
  4. restrictions; you can redistribute it and/or modify it in any way 
  5. you see fit. This file is suitable for inclusion in a derivative
  6. work, regardless of license on the work or availability of source code
  7. to the work. If you redistribute this file, you must leave this
  8. header intact.
  9.     
  10. This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  13. The author of this program may be contacted at dildog@l0pht.com. */
  14. #include<windows.h>
  15. char *GetCfgStr(char *cfgstr,char *key)
  16. {
  17. char *str;
  18. str=cfgstr;
  19. // Skip past name of options list
  20. while(*str!='') str++;
  21. str++;
  22. // Walk through options
  23. while(*str!='') {
  24. int nLen;
  25. if(*str=='B') {
  26. nLen=1;
  27. str+=2;
  28. if(strncmp(str,key,lstrlen(key))==0) break;
  29. } else if(*str=='S') {
  30. str+=2;
  31. nLen=atoi(str);
  32. while(*str!=']') str++;
  33. str+=2;
  34. if(strncmp(str,key,lstrlen(key))==0) break;
  35. } else if(*str=='N') {
  36. str+=2;
  37. char *pb;
  38. pb=str;
  39. while(*str!=',') str++;
  40. nLen=(DWORD)str-(DWORD)pb;
  41. str++;
  42. pb=str;
  43. while(*str!=']') str++;
  44. int nLen2=(DWORD)str-(DWORD)pb;
  45. if(nLen2>nLen) nLen=nLen2;
  46. str+=2;
  47. if(strncmp(str,key,lstrlen(key))==0) break;
  48. }
  49. while(*str!='=') str++;
  50. str++;
  51. str+=(nLen+1);
  52. }
  53. if(*str!='') {
  54. while(*str!='=') str++;
  55. return str+1;
  56. }
  57. return NULL;
  58. }
  59. int GetCfgNum(char *cfgstr,char *key)
  60. {
  61. char *str;
  62. str=GetCfgStr(cfgstr,key);
  63. return (str==NULL)?0:atoi(str);
  64. }
  65. int GetCfgBool(char *cfgstr,char *key)
  66. {
  67. return GetCfgNum(cfgstr,key)?TRUE:FALSE;
  68. }