void CTUI::InitNCurses() { EndWin(); initscr(); NoEcho(); CBreak(); leaveok(GetRootWin(), false); KeyPad(GetRootWin(), true); Meta(GetRootWin(), true); if (has_colors()) StartColor(); m_pMainBox = new CBox(CBox::VERTICAL, false); m_pMainBox->SetParent(GetRootWin()); m_pMainBox->Init(); m_pMainBox->SetSize(0, 0, GetWWidth(GetRootWin()), GetWHeight(GetRootWin())); m_pMainBox->SetFocus(true); m_pButtonBar = new CButtonBar(GetWWidth(GetRootWin())); // Focused colors are used for keys, defocused colors for descriptions m_pButtonBar->SetFColors(COLOR_YELLOW, COLOR_RED); m_pButtonBar->SetDFColors(COLOR_WHITE, COLOR_RED); m_pMainBox->EndPack(m_pButtonBar, false, false, 0, 0); m_pWinManager = new CWindowManager; m_pMainBox->AddWidget(m_pWinManager); m_pWinManager->ReqFocus(); m_pMainBox->RequestQueuedDraw(); }
int main(int argc, char** argv) { Aes aes; byte* key; /* user entered key */ FILE* inFile; FILE* outFile = NULL; const char* in; const char* out; int option; /* choice of how to run program */ int ret = 0; /* return value */ int size = 0; int inCheck = 0; int outCheck = 0; char choice = 'n'; while ((option = getopt(argc, argv, "d:e:i:o:h")) != -1) { switch (option) { case 'd': /* if entered decrypt */ size = atoi(optarg); ret = SizeCheck(size); choice = 'd'; break; case 'e': /* if entered encrypt */ size = atoi(optarg); ret = SizeCheck(size); choice = 'e'; break; case 'h': /* if entered 'help' */ help(); break; case 'i': /* input file */ in = optarg; inCheck = 1; inFile = fopen(in, "r"); break; case 'o': /* output file */ out = optarg; outCheck = 1; outFile = fopen(out, "w"); break; case '?': if (optopt) { printf("Ending Session\n"); return -111; } default: abort(); } } if (inCheck == 0 || outCheck == 0) { printf("Must have both input and output file"); printf(": -i filename -o filename\n"); } else if (ret == 0 && choice != 'n') { key = malloc(size); /* sets size memory of key */ ret = NoEcho((char*)key, size); if (choice == 'e') AesEncrypt(&aes, key, size, inFile, outFile); else if (choice == 'd') AesDecrypt(&aes, key, size, inFile, outFile); } else if (choice == 'n') { printf("Must select either -e or -d for encryption and decryption\n"); ret = -110; } return ret; }