Namecoin console(fstream somehow not working)


SUBMITTED BY: Guest

DATE: April 21, 2013, 10:23 a.m.

FORMAT: Text only

SIZE: 2.3 kB

HITS: 1173

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include <string>
  4. #include <process.h>
  5. #include <windows.h>
  6. #include <fstream>
  7. using namespace std;
  8. HANDLE hMutex;
  9. void startserver(void *lol){
  10. WaitForSingleObject( hMutex, INFINITE );
  11. string b="\"F:\\Program Files (x86)\\namecoind\\namecoind\" ";
  12. const char * d = b.c_str();
  13. system(d);
  14. ReleaseMutex( hMutex );
  15. }
  16. void cbracket() {}
  17. string icomma()
  18. {
  19. }
  20. void genconf(){
  21. system("md %APPDATA%\\Roaming\\Namecoin");
  22. fstream config;
  23. config.open("%APPDATA%\\Namecoin\\bitcoin.conf",ios::out);
  24. config<<"rpcuser=username\nrpcpassword=l0l0l0l0l0l\nrpcport=8336\ndaemon=1";
  25. config.close();
  26. }
  27. int main()
  28. {
  29. hMutex = CreateMutex( NULL, FALSE, NULL );
  30. string a;
  31. string b="\"F:\\Program Files (x86)\\namecoind\\namecoind\" ";
  32. string c;
  33. const char * d = b.c_str();
  34. _beginthread(startserver,0,NULL);
  35. cout<<"namecoind instance starting...";
  36. if (WaitForSingleObject( hMutex, 15000 )!=WAIT_TIMEOUT){
  37. cout<<"\nconfig missing. Generating config...";
  38. genconf();
  39. cout<<"ok, \npress any key to quit. restart the program after this"<<endl;
  40. cin.ignore();
  41. }
  42. else {
  43. cout<<"started"<<endl;
  44. cout<<"Type in help and press enter to check."<<endl;
  45. cout<<"if it says error: cannot connect to server, that means it is still starting. Try some more till it list out the commands."<<endl;
  46. cout<<"QUIT ONLY BY TYPING quit IN LOWER CASE AND PRESS ENTER"<<endl;
  47. //cout<<"if you are getting the error of no config file, type in \"genconf\" in lower case and press enter, then start the application again."<<endl;
  48. while(true)
  49. {
  50. cout<<">";
  51. getline(cin,a);
  52. if (a=="quit")
  53. {
  54. system("\"F:\\Program Files (x86)\\namecoind\\namecoind\" stop");
  55. break;
  56. }
  57. //else if(a=="genconf")genconf();
  58. else
  59. {
  60. c=b+a;
  61. d = c.c_str();
  62. system(d);
  63. }
  64. }
  65. _endthread();
  66. }
  67. }

comments powered by Disqus