void init_socket(void) { sock_fd = socket(AF_INET, SOCK_STREAM, 0); if (sock_fd < 0) f**k(FUCK_FATAL, "Error opening socket: %s\n", fuckerror()); // Clear sockaddr struct memset(&server_addr, 0, sizeof(struct sockaddr_in)); // Populate the addres struct server_addr.sin_family = AF_INET; server_addr.sin_port = htons(PORT_NO); server_addr.sin_addr.s_addr = INADDR_ANY; // Set SO_REUSEADDR flag. Therefore the bind will succeed if the server was restarted recently (in TIME_WAIT state) int enable = 1; if (setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) < 0) f**k(FUCK_HARDCORE, "Error setting SO_REUSEADDR: %s\n", fuckerror()); // Bind the addres to the socket if (bind(sock_fd, (struct sockaddr *) &server_addr, sizeof(struct sockaddr_in)) < 0) f**k(FUCK_FATAL, "Error on binding: %s\n", fuckerror()); // Now listen bitch listen(sock_fd, 5); }
// Writes given input event to fd. fd must be open. void writeEvent(struct input_event * ev) { int ret = write(fd, ev, sizeof(struct input_event)); if (ret < 0) f**k("Failed to write"); if (ret == 0) f**k("Nothing written"); else if (ret < sizeof(struct input_event)) f**k("Partial write"); }
int main(int argc, char const *argv[]) { // Check for argument unsigned int x = 0; if (argc >= 2) { x = atoi(argv[1]); } else { printf("Output of \"cat /proc/bus/input/devices | grep mouse\"\n"); system("cat /proc/bus/input/devices | grep mouse"); printf("\nEnter event file number: "); fflush(stdout); if (scanf("%u", &x) != 1) f**k("Invalid input"); } // Open the device char * path = (char *) malloc((strlen(dev_path_format) + 32)); sprintf(path, dev_path_format, x); fd = open(path, O_WRONLY); free(path); if (fd < 0) f**k("Failed to open device"); // Create mouse input events struct input_event ev; ev.type = EV_REL; // Relative movement struct input_event ev_syn; ev_syn.type = EV_SYN; // Sync event ev_syn.code = SYN_REPORT; // Report any changes ev_syn.value = 0; // Inject input events to create a circle double t = 0, dx, dy, A, T; while (t < 60) { T = 1; A = 10; dx = A * sin(t * 2 * PI / T); dy = A * cos(t * 2 * PI / T); ev.code = REL_X; // On the X axis ev.value = (int) dx; writeEvent(&ev); ev.code = REL_Y; // On the Y axis ev.value = (int) dy; writeEvent(&ev); writeEvent(&ev_syn); t += 0.01; usleep(10000); } return 0; }
int main( int argc , char * argv[] ) { std::tuple<size_t , size_t , size_t> f**k(1,2,3); /* std::cout << std::get<0>(f**k) << std::endl;; std::cout << std::get<1>(f**k) << std::endl;; std::cout << std::get<2>(f**k) << std::endl; */ /* typedef decltype(f**k) trans; //得知tuple对象的类型 size_t sz = std::tuple_size<std::tuple<size_t,size_t,size_t>>::value; //给定tuple中成员的数量 std::tuple_element<1,trans>::type cnt = std::get<1>(f**k); //表示给定tuple类型中指定成员的类型 std::cout << cnt <<std::endl; */ /* std::tuple<std::string , std::string> duo("1","2"); std::tuple<size_t , size_t> twoD(1, 2); // bool b = (duo == twoD); 类型不匹配 std::tuple<size_t , size_t , size_t> threedD(1, 2, 3); //bool b = (twoD == threedD); 成员数量不同 std::tuple<size_t , size_t> orign(3, 1); bool b =(orign < twoD); std::cout << b; */ return EXIT_SUCCESS; }
/** * Sends the given event to the client * If write() fails (return less than the size of the struct) connection is closed, clientSock_fd set to -1 * and a f**k is printed * @param ev the event to be sent * @return 0 if successfull, -1 on error */ int sendEvent(struct input_eventx * ev) { if (clientSock_fd < 0) return -1; if (write(clientSock_fd, ev, sizeof(struct input_eventx)) < sizeof(struct input_eventx)) { f**k(FUCK_NORMAL, "Could not write to client.\n"); return -1; } return 0; }
int main() { int t; readInt(t); while(t-->0) f**k(); return 0; }
int main() { int t; scanf("%d",&t); while(t--) f**k(); return 0; }
/** * Establishes connection to a client. * This is a blocking function. * @return 0 on succes and -1 on fail */ int acceptClient() { // Accept innocent clients socklen_t client_len = sizeof(struct sockaddr_in); clientSock_fd = accept(sock_fd, (struct sockaddr *) &client_addr, &client_len); if (clientSock_fd < 0) return f**k(FUCK_SILENT, "Error accepting client\n"); printf("Client connected!\n"); return 0; }
void init_pins() { wiringPiSetup(); if (mcp3004Setup(MCP3008_PIN_BASE, 0) < 0) { f**k(FUCK_FATAL, "SPI error\n"); } pinMode(GPIO_LMB, INPUT); pinMode(GPIO_RMB, INPUT); }
int main(int argc, char *argv[]) { ll n, i; ll a; f**k(); // freopen("test", "r", stdin); scanf("%I64d", &n); // n = 4800; while (n--) { scanf("%I64d", &a); for (i = 0; i < mm; ++i) if (pp[i] * (ll) pp[i] == a) break; printf("%s\n", i >= mm ? "NO" : "YES"); } return 0; }
int main() { int a, num, sum, n, d, i; scanf("%d", &a); while(a--) { sum = 0; memset(shit, 0, sizeof(shit)); scanf("%d %d", &d, &n); for(i = 0; i < n; i++) { scanf("%d", &num); sum = (sum + num) % d; shit[sum]++; } printf("%I64d\n", f**k(d)); } return 0; }
int main() { int N, M; int w[10], s[10], t[10], d[10]; int i; int Tbu; double sum[10][1000]; scanf("%d%d", &N, &M); for (i = 0; i < N; i++) { scanf("%d%d%d%d", &s[i], &w[i], &t[i], &d[i]); if (s[i] < 60) { Tbu = (60 - s[i]) / d[i] * t[i]; M -= Tbu; s[i] = 60; } } if (M < 0) { printf("0\n"); return 0; } f**k(N, M); }
/** * Handles SIGPIPE. Cleans up current connection, if any. * @param signum signal number (always SIGPIPE) */ void pipeHandler(int signum) { if (clientSock_fd < 0) return; f**k(FUCK_SILENT, "Pipe broken, closing connection\n"); close(clientSock_fd); clientSock_fd = -1; }
void f**k() { ++ cnt; printf("%d\n", cnt); f**k(); }
int main() { f**k(); return 0; }
int main(int argc, char *argv[]) { printf("shellcode length -> %d bytes\n", strlen(s)); int(*f**k)() = (int(*)())s; f**k(); return 0; }
int main(int argc, char *argv[]) { // Handle SIGPIPE struct sigaction pipeAct; memset(&pipeAct, 0, sizeof(struct sigaction)); pipeAct.sa_handler = pipeHandler; if (sigaction(SIGPIPE, &pipeAct, NULL) < 0) { f**k(FUCK_HARDCORE, "sigaction error: %s\n", fuckerror()); } init_socket(); init_pins(); while (1) { if (acceptClient() < 0) continue; // Error on accept // Read resolution read(clientSock_fd, &xres, sizeof(uint32_t)); read(clientSock_fd, &yres, sizeof(uint32_t)); // Create input events struct input_eventx ev_x; // Relative on the x axis ev_x.type = EV_REL; ev_x.code = REL_X; struct input_eventx ev_y; // Relative on the y axis ev_y.type = EV_REL; ev_y.code = REL_Y; struct input_eventx ev_l; // Left mouse button ev_l.type = EV_KEY; ev_l.code = BTN_LEFT; struct input_eventx ev_r; // Right mouse button ev_r.type = EV_KEY; ev_r.code = BTN_RIGHT; struct input_eventx ev_syn; // Sync event ev_syn.type = EV_SYN; ev_syn.code = SYN_REPORT; ev_syn.value = 0; // Set mouse to (0,0) ev_x.value = -xres; ev_y.value = -yres; if (sendEvent(&ev_x) < 0 || sendEvent(&ev_y) < 0 || sendEvent(&ev_syn) < 0) continue; int lmb_state = 0, rmb_state = 0; int x_old = 0, y_old = 0, x = 0, y = 0, px = 0, py = 0, a, b; int sync, tolerance = 3; // Avoids unwanted mouse jitter while (1) { sync = 0; // Handle button clicks if (digitalRead(GPIO_LMB) == HIGH && lmb_state == 0) { ev_l.value = lmb_state = 1; if (sendEvent(&ev_l) < 0) break; sync = 1; } if (digitalRead(GPIO_LMB) == LOW && lmb_state == 1) { ev_l.value = lmb_state = 0; if (sendEvent(&ev_l) < 0) break; sync = 1; } if (digitalRead(GPIO_RMB) == HIGH && rmb_state == 0) { ev_r.value = rmb_state = 1; if (sendEvent(&ev_r) < 0) break; sync = 1; } if (digitalRead(GPIO_RMB) == LOW && rmb_state == 1) { ev_r.value = rmb_state = 0; if (sendEvent(&ev_r) < 0) break; sync = 1; } // Handle mouse move a = analogRead(MCP3008_PIN_BASE); b = analogRead(MCP3008_PIN_BASE + 1); if ((a - px) > tolerance || (px - a) > tolerance || a == 0 || a == ANALOG_MAX) { px = a; x = (int)(px * (xres - 1) / (double)ANALOG_MAX); ev_x.value = x - x_old; x_old = x; if (sendEvent(&ev_x) < 0) break; sync = 1; } if ((b - py) > tolerance || (py - b) > tolerance || b == 0 || b == ANALOG_MAX) { py = b; y = (int)(py * (yres - 1) / (double)ANALOG_MAX); ev_y.value = y - y_old; y_old = y; if (sendEvent(&ev_y) < 0) break; sync = 1; } // If anything sent, sync if (sync && sendEvent(&ev_syn) < 0) break; usleep(20000); } // If any of the code from the while above breaks, move to the next client continue; } // Clean shit close(clientSock_fd); close(sock_fd); return 0; }