int main() { while (true) { Function1(); Function2(); } return 0; }
int main() { ComboFunction_initialize(); printf("Function1=%g\n", Function1()); printf("Function2=%g\n", Function2()); ComboFunction_terminate(); return 0; }
void Function() { Function1(Type1<-42>()); // expected-error{{no matching function for call to 'Function1'}} Function2(Type2<42>()); // expected-error{{no matching function for call to 'Function2'}} struct Type3<boolTy::b, "3"> t3; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type3Helper<(boolTy)false>::Ty' (aka 'boolTy')}} struct Type4<charTy::c, "4"> t4; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type4Helper<(charTy)'\x0'>::Ty' (aka 'charTy')}} struct Type5<scharTy::c, "5"> t5; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type5Helper<(scharTy)'\x0'>::Ty' (aka 'scharTy')}} struct Type6<ucharTy::c, "6"> t6; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type6Helper<(ucharTy)'\x0'>::Ty' (aka 'ucharTy')}} struct Type7<wcharTy::c, "7"> t7; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type7Helper<(wcharTy)L'\x0'>::Ty' (aka 'wcharTy')}} struct Type8<char16Ty::c, "8"> t8; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type8Helper<(char16Ty)u'\x0'>::Ty' (aka 'char16Ty')}} struct Type9<char32Ty::c, "9"> t9; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type9Helper<(char32Ty)u'\x0'>::Ty' (aka 'char32Ty')}} }
/* Background tasks related to Subsystem control */ void BackgroundSubsystemTasks(void) { rpub_PtrToU8 = &rub_Var1; /* We need to initialize the pointer to be used by our function invocation */ rpfu_PtrToFctn = &Function1; /* Let's perform our deferencing procedure (initialization) */ /* Let's first call our function through direct invocation */ rub_Var2 = Function1(rpub_PtrToU8); /* Clear var2 in preparation to next invocation */ rub_Var2 = 0; /* Now, perform invocation through our pointer */ rub_Var2 = rpfu_PtrToFctn(rpub_PtrToU8); /* See, I told you, pointers to functions are FUN !! */; }
int DoesSomething() { int status; unsigned int buf; int err; buf = (unsigned int)malloc(1000); err = Function1(); if ( err != STATUS_SUCCESS ) PRINT_ERROR_AND_FINISH(); else status = Function2(buf); free((void*)buf); done: return status; }
void Function() { Function1(Type1<-42>()); // expected-error{{no matching function for call to 'Function1'}} Function2(Type2<42>()); // expected-error{{no matching function for call to 'Function2'}} }
int main(int argc, char* argv[]) { // store the invoking program name char* prg_name = argv[0]; // create an object of cpuClock and start it cpuClock clock; clock.Start(); // want to mark lines positionMarker pm; // pm << plume::off; // open a file std::ofstream out("MyTestFile.txt"); channel1.ResetStream(out); // channel1.Off(); channel2.Off(); // channel1.ResetStream(channel2); // invoke a function Function1(); pm << "About to test anAngle class";// << plume::pause; // test out the degree, angle etc. anAngle alpha; alpha = degree(45); std::cout << "sin of 45 dgrees is: " << sin(alpha) << std::endl; pm << "alpha = degree(45) is over" << plume::ends; alpha = degree(90); std::cout << "sin of 90 dgrees is: " << sin(alpha) << std::endl; alpha = radian(45.0); // sin( degree(45) ); // error // sin( radian(1.0) ); // error std::cout << sin( anAngle( degree(45) ) ) << std::endl << sin( anAngle( radian(1) ) ) << std::endl; // insert a position marker here //** pm << plume::off; pm << " I am here." << plume::pause; pm << "******** Testing aStream object ***********" << plume::ends; int i=5; pm << " the value of i is: " << i << plume::ends; plume::aStream my_s; my_s << "~~~~~~~~~Inserted this into the stream." << std::endl << std::ends; std::cout << my_s; my_s << "~~~~*****Now the string is different" << std::endl << std::endl; my_s << std::ends; std::cout << my_s; my_s << std::ends; std::cout << my_s; // is the new traceable class, traceable?? #if 1 pm << plume::ends; pm << "checking anotherTraceableClass **** " << plume::ends; anotherTraceableClass atc; pm << plume::pause; #endif #if 1 pm << plume::ends; pm << "checking yetAnotherTraceableClass **** " << plume::ends; yetAnotherTraceableClass yatc; yetAnotherTraceableClass yatc1; yetAnotherTraceableClass yatc2; pm << plume::pause; #endif #if 0 // turn off object tracing for the moment // now let us test object tracing traceableClass tc; traceableClass* ptc = new traceableClass; traceableClass* ptca = new traceableClass[2]; delete ptc; delete [] ptca; #endif // stop the clock and display cpu time clock.Stop(); clock.Display(); // write a closure message and finish the program std::cout << "Program " << prg_name << " completed successfully :-)" << std::endl; return 0; }
DWORD WINAPI ConnectionHandler(LPVOID CSocket) { int RecvBufLen = DEFAULT_BUFLEN; char *RecvBuf = malloc(DEFAULT_BUFLEN); char BigEmpty[1000]; char *GdogBuf = malloc(1024); int Result, SendResult, i, k; memset(BigEmpty, 0, 1000); memset(RecvBuf, 0, DEFAULT_BUFLEN); SOCKET Client = (SOCKET)CSocket; SendResult = send( Client, "Welcome to Vulnerable Server! Enter HELP for help.\n", 51, 0 ); if (SendResult == SOCKET_ERROR) { printf("Send failed with error: %d\n", WSAGetLastError()); closesocket(Client); return 1; } while (CSocket) { Result = recv(Client, RecvBuf, RecvBufLen, 0); if (Result > 0) { if (strncmp(RecvBuf, "HELP ", 5) == 0) { const char NotImplemented[47] = "Command specific help has not been implemented\n"; SendResult = send( Client, NotImplemented, sizeof(NotImplemented), 0 ); } else if (strncmp(RecvBuf, "HELP", 4) == 0) { const char ValidCommands[251] = "Valid Commands:\nHELP\nSTATS [stat_value]\nRTIME [rtime_value]\nLTIME [ltime_value]\nSRUN [srun_value]\nTRUN [trun_value]\nGMON [gmon_value]\nGDOG [gdog_value]\nKSTET [kstet_value]\nGTER [gter_value]\nHTER [hter_value]\nLTER [lter_value]\nKSTAN [lstan_value]\nEXIT\n"; SendResult = send( Client, ValidCommands, sizeof(ValidCommands), 0 ); } else if (strncmp(RecvBuf, "STATS ", 6) == 0) { char *StatBuf = malloc(120); memset(StatBuf, 0, 120); strncpy(StatBuf, RecvBuf, 120); SendResult = send( Client, "STATS VALUE NORMAL\n", 19, 0 ); } else if (strncmp(RecvBuf, "RTIME ", 6) == 0) { char *RtimeBuf = malloc(120); memset(RtimeBuf, 0, 120); strncpy(RtimeBuf, RecvBuf, 120); SendResult = send( Client, "RTIME VALUE WITHIN LIMITS\n", 26, 0 ); } else if (strncmp(RecvBuf, "LTIME ", 6) == 0) { char *LtimeBuf = malloc(120); memset(LtimeBuf, 0, 120); strncpy(LtimeBuf, RecvBuf, 120); SendResult = send( Client, "LTIME VALUE HIGH, BUT OK\n", 25, 0 ); } else if (strncmp(RecvBuf, "SRUN ", 5) == 0) { char *SrunBuf = malloc(120); memset(SrunBuf, 0, 120); strncpy(SrunBuf, RecvBuf, 120); SendResult = send( Client, "SRUN COMPLETE\n", 14, 0 ); } else if (strncmp(RecvBuf, "TRUN ", 5) == 0) { char *TrunBuf = malloc(3000); memset(TrunBuf, 0, 3000); for (i = 5; i < RecvBufLen; i++) { if ((char)RecvBuf[i] == '.') { strncpy(TrunBuf, RecvBuf, 3000); Function3(TrunBuf); break; } } memset(TrunBuf, 0, 3000); SendResult = send( Client, "TRUN COMPLETE\n", 14, 0 ); } else if (strncmp(RecvBuf, "GMON ", 5) == 0) { char GmonStatus[13] = "GMON STARTED\n"; for (i = 5; i < RecvBufLen; i++) { if ((char)RecvBuf[i] == '/') { if (strlen(RecvBuf) > 3950) { Function3(RecvBuf); } break; } } SendResult = send( Client, GmonStatus, sizeof(GmonStatus), 0 ); } else if (strncmp(RecvBuf, "GDOG ", 5) == 0) { strncpy(GdogBuf, RecvBuf, 1024); SendResult = send( Client, "GDOG RUNNING\n", 13, 0 ); } else if (strncmp(RecvBuf, "KSTET ", 6) == 0) { char *KstetBuf = malloc(100); strncpy(KstetBuf, RecvBuf, 100); memset(RecvBuf, 0, DEFAULT_BUFLEN); Function2(KstetBuf); SendResult = send( Client, "KSTET SUCCESSFUL\n", 17, 0 ); } else if (strncmp(RecvBuf, "GTER ", 5) == 0) { char *GterBuf = malloc(180); memset(GdogBuf, 0, 1024); strncpy(GterBuf, RecvBuf, 180); memset(RecvBuf, 0, DEFAULT_BUFLEN); Function1(GterBuf); SendResult = send( Client, "GTER ON TRACK\n", 14, 0 ); } else if (strncmp(RecvBuf, "HTER ", 5) == 0) { char THBuf[3]; memset(THBuf, 0, 3); char *HterBuf = malloc((DEFAULT_BUFLEN+1)/2); memset(HterBuf, 0, (DEFAULT_BUFLEN+1)/2); i = 6; k = 0; while ( (RecvBuf[i]) && (RecvBuf[i+1])) { memcpy(THBuf, (char *)RecvBuf+i, 2); unsigned long j = strtoul((char *)THBuf, NULL, 16); memset((char *)HterBuf + k, (byte)j, 1); i = i + 2; k++; } Function4(HterBuf); memset(HterBuf, 0, (DEFAULT_BUFLEN+1)/2); SendResult = send( Client, "HTER RUNNING FINE\n", 18, 0 ); } else if (strncmp(RecvBuf, "LTER ", 5) == 0) { char *LterBuf = malloc(DEFAULT_BUFLEN); memset(LterBuf, 0, DEFAULT_BUFLEN); i = 0; while(RecvBuf[i]) { if ((byte)RecvBuf[i] > 0x7f) { LterBuf[i] = (byte)RecvBuf[i] - 0x7f; } else { LterBuf[i] = RecvBuf[i]; } i++; } for (i = 5; i < DEFAULT_BUFLEN; i++) { if ((char)LterBuf[i] == '.') { Function3(LterBuf); break; } } memset(LterBuf, 0, DEFAULT_BUFLEN); SendResult = send( Client, "LTER COMPLETE\n", 14, 0 ); } else if (strncmp(RecvBuf, "KSTAN ", 6) == 0) { SendResult = send( Client, "KSTAN UNDERWAY\n", 15, 0 ); } else if (strncmp(RecvBuf, "EXIT", 4) == 0) { SendResult = send( Client, "GOODBYE\n", 8, 0 ); printf("Connection closing...\n"); closesocket(Client); return 0; } else { SendResult = send( Client, "UNKNOWN COMMAND\n", 16, 0 ); } if (SendResult == SOCKET_ERROR) { printf("Send failed with error: %d\n", WSAGetLastError()); closesocket(Client); return 1; } } else if (Result == 0) { printf("Connection closing...\n"); closesocket(Client); return 0; } else { printf("Recv failed with error: %d\n", WSAGetLastError()); closesocket(Client); return 1; } } }
void Function2(void) { Function1(); }