summary refs log tree commit diff
path: root/bin/glitch.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-03-02 18:00:36 -0500
committerJune McEnroe <june@causal.agency>2018-03-02 18:00:36 -0500
commitd9c45d62a19d9bbaf138b74bde0817de4903db95 (patch)
treefe2dc1b3790d2b6302d7295097082bf1c8d55640 /bin/glitch.c
parentTake filter patterns in glitch (diff)
downloadsrc-d9c45d62a19d9bbaf138b74bde0817de4903db95.tar.gz
src-d9c45d62a19d9bbaf138b74bde0817de4903db95.zip
Add -f -r options to glitch
Diffstat (limited to 'bin/glitch.c')
-rw-r--r--bin/glitch.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/bin/glitch.c b/bin/glitch.c
index 37d93a70..22d82c13 100644
--- a/bin/glitch.c
+++ b/bin/glitch.c
@@ -265,6 +265,8 @@ enum PACKED Filter {
 
 static struct {
     bool brokenPaeth;
+    bool filt;
+    bool recon;
     uint8_t declareFilter;
     uint8_t applyFilter;
     enum Filter declareFilters[255];
@@ -347,7 +349,11 @@ static struct Bytes origBytes(uint32_t y, size_t i) {
 static void reconData(void) {
     for (uint32_t y = 0; y < header.height; ++y) {
         for (size_t i = 0; i < lineSize(); ++i) {
-            lines[y]->data[i] = recon(lines[y]->type, origBytes(y, i));
+            if (options.filt) {
+                lines[y]->data[i] = filt(lines[y]->type, origBytes(y, i));
+            } else {
+                lines[y]->data[i] = recon(lines[y]->type, origBytes(y, i));
+            }
         }
         lines[y]->type = NONE;
     }
@@ -360,7 +366,11 @@ static void filterData(void) {
         enum Filter minType = NONE;
         for (enum Filter type = NONE; type < FILTER_COUNT; ++type) {
             for (size_t i = 0; i < lineSize(); ++i) {
-                filter[type][i] = filt(type, origBytes(y, i));
+                if (options.recon) {
+                    filter[type][i] = recon(type, origBytes(y, i));
+                } else {
+                    filter[type][i] = filt(type, origBytes(y, i));
+                }
                 heuristic[type] += abs((int8_t)filter[type][i]);
             }
             if (heuristic[type] < heuristic[minType]) minType = type;
@@ -447,7 +457,7 @@ int main(int argc, char *argv[]) {
     char *output = NULL;
 
     int opt;
-    while (0 < (opt = getopt(argc, argv, "a:cd:o:p"))) {
+    while (0 < (opt = getopt(argc, argv, "a:cd:fo:pr"))) {
         switch (opt) {
             case 'a': {
                 options.applyFilter = parseFilters(options.applyFilters, optarg);
@@ -456,8 +466,10 @@ int main(int argc, char *argv[]) {
             case 'd': {
                 options.declareFilter = parseFilters(options.declareFilters, optarg);
             } break;
+            case 'f': options.filt = true; break;
             case 'o': output = optarg; break;
             case 'p': options.brokenPaeth = true; break;
+            case 'r': options.recon = true; break;
             default: return EX_USAGE;
         }
     }
itle.c?id=8836c4bde2366908d45b89fd7788fd0aa09288af&follow=1'>Fail on HTTP failure status in titleJune McEnroe 2019-09-23Add Trail of LightningJune McEnroe 2019-09-22Revert "Enable cookies in title"June McEnroe This reverts commit 279111dda15dd9170e11b9688eb973f2af2e6300. 2019-09-20Enable cookies in titleJune McEnroe Perhaps this will make it less suspicious to Google. Who knows. 2019-09-16Use sensitivity aliases in TF2June McEnroe 2019-09-16Add The Just CityJune McEnroe 2019-09-12Only GET the final redirect locationJune McEnroe 2019-09-12Consume entire bodyJune McEnroe Aborting the request and leaving data around may be causing intermittent errors. Just discard the rest of the data. 2019-09-10Add title -v flagJune McEnroe 2019-09-10Use curl error bufferJune McEnroe 2019-09-10Set Accept-Encoding in titleJune McEnroe Because apparently it's fine for servers to respond with Content-Encoding you didn't ask for, and curl won't decode it if you didn't ask for it. 2019-09-08Set title User-AgentJune McEnroe Some things don't like you if you don't send one. 2019-09-07Add -x flag to titleJune McEnroe 2019-09-07Ignore SIGPIPE in relayJune McEnroe Allows restarting consumers safely. 2019-09-07Add A Memory Called EmpireJune McEnroe 2019-09-05Handle lack of Content-TypeJune McEnroe 2019-09-05Use CURLINFO_CONTENT_TYPEJune McEnroe Oops, didn't see this. 2019-09-05Decode entities in titlesJune McEnroe 2019-09-05Print title as soon as it's availableJune McEnroe 2019-09-05Use CURL_PREFIX to set flagsJune McEnroe 2019-09-05Add titleJune McEnroe 2019-09-04Add Avorter n'est pas tuerJune McEnroe 2019-08-29Unset executable on shell scriptsJune McEnroe 2019-08-29Add long-missing setopt to bin.7June McEnroe 2019-08-29Add editJune McEnroe