tweak: conciseness tweaks.
This commit is contained in:
parent
304b4b274c
commit
76ab73e38c
Binary file not shown.
|
@ -4,20 +4,16 @@
|
|||
|
||||
int main(){
|
||||
char uri[] = "https://reddit.com/r/blah";
|
||||
|
||||
int uri_length = strlen(uri);
|
||||
int l = LIBRE_N+uri_length;
|
||||
char uri_filtered[l++];
|
||||
for(int i=0; i<l; i++){
|
||||
uri_filtered[i] = ' ';
|
||||
}
|
||||
uri_filtered[l] = '\0';
|
||||
|
||||
int l = LIBRE_N + strlen(uri) + 1;
|
||||
char uri_filtered[l];
|
||||
str_init(uri_filtered, l);
|
||||
|
||||
int libre_check = libre_redirect(uri, uri_filtered);
|
||||
if(!libre_check){
|
||||
printf("Filtered url: %s", uri_filtered);
|
||||
printf("Filtered url: %s\n", uri_filtered);
|
||||
}else{
|
||||
printf("Uri: %s", uri);
|
||||
printf("Uri: %s\n", uri);
|
||||
// failure; do something with the original uri.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,13 @@
|
|||
|
||||
// int str_replace_start(const char* string, const char* target, const char* replacement, char* output){
|
||||
|
||||
void str_init(char* str, int n){
|
||||
for(int i=0; i<n; i++){
|
||||
str[i] = ' ';
|
||||
}
|
||||
str[n] = '\0';
|
||||
} // could also use <https://manpages.ubuntu.com/manpages/impish/man3/strinit.3pub.html>
|
||||
|
||||
int libre_redirect(const char* uri, char* output){
|
||||
/* inv.riverside.rocks */
|
||||
// max length
|
||||
|
@ -16,7 +23,7 @@ int libre_redirect(const char* uri, char* output){
|
|||
return 1; // not enough memory.
|
||||
}else{
|
||||
char tmp_uri[l2++];
|
||||
strcpy(tmp_uri, uri);
|
||||
strcpy(tmp_uri, uri); // includes terminating '\0'
|
||||
|
||||
char* sites[] = {
|
||||
"https://youtube.com",
|
||||
|
@ -39,7 +46,6 @@ int libre_redirect(const char* uri, char* output){
|
|||
strcpy(tmp_uri, output);
|
||||
}
|
||||
strcpy(output, tmp_uri);
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -4,5 +4,6 @@
|
|||
#define LIBRE_N 12
|
||||
|
||||
int libre_redirect(const char* uri, char* uri_filtered);
|
||||
void str_init(char* str, int n);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user