Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

new stream_filter which copies pubsub_filtered code but just uses stdin stdout #64

Merged
merged 1 commit into from Jun 28, 2012

Conversation

Projects
None yet
3 participants
Contributor

ploxiln commented Jun 27, 2012

a new much simpler batch-oriented tool that I find useful

perhaps should be refactored and consolidated ... the whole Makefile and everything could be cleaned up in another pull request

new stream_filter which copies pubsub_filtered code but just uses std…
…in stdout

perhaps should be refactored and consolidated

@jayridge jayridge commented on the diff Jun 27, 2012

pubsub_filtered/stream_filter.c
+int parse_encrypted_fields(char *str)
+{
+ int i;
+ num_encrypted_fields = parse_fields(str, encrypted_fields);
+
+ for (i = 0; i < num_encrypted_fields; i++) {
+ fprintf(stderr, "Encrypted field: \"%s\"\n", encrypted_fields[i]);
+ }
+
+ return 1;
+}
+
+/*
+ * Parse a comma-delimited list of strings and put them
+ * in an char array. Array better have enough slots
+ * because I didn't have time to work out the memory allocation.
@jayridge

jayridge Jun 27, 2012

Contributor

Here's a whack-a-string alternative; copied so some field names do not make sense.

char **parse_fields(char *key, int *nkeys)
{
    char **argv, *p=key;
    int dots=0, argsz=8;

    *nkeys = 0;
    if (!key) return NULL;
    p = strdup(key);
    argv = calloc(argsz, sizeof(char *));
    argv[0] = p;
    while (*p) {
        if (*p == ',') {
            *p = '\0';
            argv[++dots] = p+1;
            if (dots == argsz) {
                argsz *= 2;
                argv = realloc(argv, argsz);
            }
        }
        p++;
    }
    *nkeys = dots+1;
    return argv;
}
@ploxiln

ploxiln Jun 27, 2012

Contributor

that comment that you're responding to is actually just copied from pubsub_filtered which Jehiah suggested you originally wrote...

@jayridge

jayridge Jun 27, 2012

Contributor

funny

mreiferson added a commit that referenced this pull request Jun 28, 2012

Merge pull request #64 from ploxiln/new_stream_filter
new stream_filter which copies pubsub_filtered code but just uses stdin stdout

@mreiferson mreiferson merged commit f78a28e into bitly:master Jun 28, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment