#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <linux/limits.h>
#include <unistd.h>
Go to the source code of this file.
|
|
#define | REPLACE_TRUNCATE_AFTER_MATCH 1 |
| |
|
| int | replace_text (char *original, const char *target, const char *replacement, unsigned flags) |
| |
| int | file_replace_text (const char *filename, const char *target, const char *replacement, unsigned flags) |
| |
◆ file_replace_text()
| int file_replace_text |
( |
const char * | filename, |
|
|
const char * | target, |
|
|
const char * | replacement, |
|
|
unsigned | flags ) |
Replace target with replacement in filename
fprintf(stderr, "failed to replace strings in file\n");
exit(1);
}
int file_replace_text(const char *filename, const char *target, const char *replacement, unsigned flags)
Definition relocation.c:110
- Parameters
-
| filename | path to file |
| target | string value to replace |
| replacement | string |
| flags | REPLACE_TRUNCATE_AFTER_MATCH |
- Returns
- 0 on success, -1 on error
◆ replace_text()
| int replace_text |
( |
char * | original, |
|
|
const char * | target, |
|
|
const char * | replacement, |
|
|
unsigned | flags ) |
Replace all occurrences of target with replacement in original
size_t str_maxlen = 100;
char *str = calloc(str_maxlen, sizeof(char));
safe_strncpy(str, "This are a test.", str_maxlen);
fprintf(stderr, "string replacement failed\n");
exit(1);
}
free(str);
int replace_text(char *original, const char *target, const char *replacement, unsigned flags)
Definition relocation.c:28
- Parameters
-
| original | string to modify |
| target | string value to replace |
| replacement | string value |
| flags | REPLACE_TRUNCATE_AFTER_MATCH |
- Returns
- 0 on success, -1 on error