Kaynağa Gözat

mangle(ANSI_CLS) Random Text plus Random Color

  Oooh, we now have the starts of where we would most likely put code to
display ANSI. Enjoy an extra buggy feature.
david 5 yıl önce
ebeveyn
işleme
c0c35fe46c
1 değiştirilmiş dosya ile 13 ekleme ve 1 silme
  1. 13 1
      mystic.c

+ 13 - 1
mystic.c

@@ -1094,7 +1094,12 @@ int mangle(int fd, char *buffer) {
     ZF_LOGI("seen: ANSI_CLS");
 
     if (random_activate(9)) {
+      int r;
+      int color;
       char display[100] = "";
+      const char* phrasing[] = {"HeHeHe", "Poof!", "Got U",
+                                "Anyone there?", "There Wolf", "There Castle"};
+      const char* phr;
 
       ZF_LOGI("mangle(ANSI_CLS)");
       // sprintf( display, "^P2...");
@@ -1102,7 +1107,14 @@ int mangle(int fd, char *buffer) {
       // strcpy(display, "^P2^S501234567890^P1abcdef^P2g^P3h^P4i^S0^P2");
 
       // strcpy(display, "^P2^S301234^P15^S0^P2");
-      strcpy(display, "^S3^C1Hi^S0^P1");
+
+      // Add in random text, plus color!
+      r = random() % ((sizeof(phrasing) / sizeof(char *)) - 1);
+      color = random() % 16;
+      if(color == 0){ color++; }
+      sprintf(display, "^P1^S3^C%02d%s^S0^P1", color, phrasing[r]);
+      ZF_LOGD("mangle(ANSI_CLS): Inserted (%02d) %s", color, phrasing[r]);
+
       // Move the buffer so there's room for the display string.
       memmove(cp + strlen(display), cp, strlen(cp) + 1);
       strncpy(cp, display, strlen(display));