本文整理汇总了C++中chomp函数的典型用法代码示例。如果您正苦于以下问题:C++ chomp函数的具体用法?C++ chomp怎么用?C++ chomp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了chomp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_send_msg
char* create_send_msg(char *message, const char *user_name)
{
chomp(message);
int to_send_len = 4 + strlen(user_name) +
2 + strlen(message) +
1;
char hex_len[5];
int_to_hex_4(to_send_len, hex_len);
char *to_send = malloc(to_send_len);
snprintf(to_send, to_send_len, "%s%s: %s", hex_len, user_name, message);
return to_send;
}
示例2: readOneSequence
FASTQ readOneSequence(FILE *fin){
FASTQ sequence;
char *dummy;
do{
sequence.name=readOneLine(fin);
}while(sequence.name[0]!='@' && sequence.name[0]!='\0');
sequence.dna=readOneLine(fin);
dummy=readOneLine(fin);
/*if(strcmp(dummy, "+\n")!=0 && !feof(stdin)){*/
if(dummy[0]!='+' && !feof(stdin)){
fprintf(stderr, "This file does not seem to be the fastq format. EXIT\n");
exit(3);
}
free(dummy);
sequence.quality=readOneLine(fin);
chomp(sequence.name);
chomp(sequence.dna);
chomp(sequence.quality);
sequence.length=strlen(sequence.dna);
sequence.dnaShow=NULL;
sequence.qualityShow=NULL;
return sequence;
}
示例3: fopen
StructuredDataset *StructuredSVM::LoadDataset(const char *fname, bool getLock) {
if(params.debugLevel > 0) fprintf(stderr, "Reading dataset %s...", fname);
if(getLock) Lock();
FILE *fin = fopen(fname, "r");
if(!fin) {
fprintf(stderr, "Couldn't open dataset file %s\n", fname);
Unlock();
return NULL;
}
StructuredDataset *d = new StructuredDataset();
char *line = new char[1000000];
Json::Reader reader;
while(fgets(line, 999999, fin) && strlen(line) > 1) {
chomp(line);
Json::Value r;
if(!reader.parse(line, r)) {
fprintf(stderr, "Error parsing dataset example %s\n", line);
delete d;
fclose(fin);
return NULL;
}
StructuredExample *ex = new StructuredExample;
ex->x = NewStructuredData();
ex->y = NewStructuredLabel(ex->x);
if(r.isMember("y_latent")) ex->y_latent = NewStructuredLabel(ex->x);
if(!r.isMember("x") || !r.isMember("y") ||
!ex->x->load(r["x"], this) || !ex->y->load(r["y"], this) ||
(r.isMember("y_latent") && !ex->y_latent->load(r["y_latent"], this))) {
fprintf(stderr, "Error parsing values for dataset example %s\n", line);
delete ex;
delete d;
fclose(fin);
return NULL;
}
d->AddExample(ex);
}
fclose(fin);
if(getLock) Unlock();
delete [] line;
if(params.debugLevel > 0) fprintf(stderr, "done\n");
return d;
}
示例4: set_quality
static int set_quality (char *value)
{
#if defined(DEBUG)
syslog(LOG_NOTICE, "check_password: Setting quality to [%s]", value);
#endif
#if defined(LDEBUG)
char* msg = chomp(value);
printf("check_password: Setting quality to [%s]\n", msg);
ber_memfree(msg);
#endif
/* No need to require more quality than we can check for. */
if (!isdigit(*value) || (int) (value[0] - '0') > 4) return DEFAULT_QUALITY;
return (int) (value[0] - '0');
}
示例5: time
char *time_from_now(int secs)
{
int seconds = secs;
char buf[128] = { 0 };
struct timeval tv;
seconds += time(NULL);
tv.tv_sec = seconds;
tv.tv_usec = 0;
strcpy(buf, ctime((time_t *) &tv));
chomp(buf); // LF Bye!
return strdup(buf);
}
示例6: ts
void Log::fatal(std::string domain, std::string msg)
{
std::string str = ts() + "Fatal [" + domain + "] - " + chomp(msg);
if (inPythonScript) {
PyErr_SetString(PyExc_RuntimeError, str.c_str());
}
else {
std::cerr << str << std::endl;
#ifdef _WIN32
wMessageBox("Tsunagari - Fatal", str);
#endif
#ifdef __APPLE__
macMessageBox("Tsunagari - Fatal", str.c_str());
#endif
}
}
示例7: valid_word
static validator valid_word (char *word)
{
struct {
char * parameter;
validator dealer;
} list[] = { { "min_points", set_quality },
{ "use_cracklib", set_cracklib },
{ "min_upper", set_digit },
{ "min_lower", set_digit },
{ "min_digit", set_digit },
{ "min_punct", set_digit },
{ "max_consecutive_per_class", set_digit},
{ NULL, NULL } };
int index = 0;
#if defined(DEBUG)
syslog(LOG_NOTICE, "check_password: Validating parameter [%s]", word);
#endif
#if defined(LDEBUG)
char* msg = chomp(word);
printf("check_password: Validating parameter [%s]\n", msg);
ber_memfree(msg);
#endif
while (list[index].parameter != NULL) {
if (strlen(word) == strlen(list[index].parameter) &&
strcmp(list[index].parameter, word) == 0) {
#if defined(DEBUG)
syslog(LOG_NOTICE, "check_password: Parameter accepted.");
#endif
#if defined(LDEBUG)
printf("check_password: Parameter accepted.\n");
#endif
return list[index].dealer;
}
index++;
}
#if defined(DEBUG)
syslog(LOG_NOTICE, "check_password: Parameter rejected.");
#endif
#if defined(LDEBUG)
printf("check_password: Parameter rejected.\n");
#endif
return NULL;
}
示例8: reflist_new
static RefList *read_stream_reflections(FILE *fh)
{
char *rval = NULL;
int first = 1;
RefList *out;
out = reflist_new();
do {
char line[1024];
signed int h, k, l;
float intensity, sigma, fs, ss, pk, bg;
int r;
Reflection *refl;
rval = fgets(line, 1023, fh);
if ( rval == NULL ) continue;
chomp(line);
if ( strcmp(line, REFLECTION_END_MARKER) == 0 ) return out;
r = sscanf(line, "%i %i %i %f %f %f %f %f %f",
&h, &k, &l, &intensity, &sigma, &pk, &bg, &fs, &ss);
if ( (r != 9) && (!first) ) {
reflist_free(out);
return NULL;
}
first = 0;
if ( r == 9 ) {
refl = add_refl(out, h, k, l);
set_intensity(refl, intensity);
set_detector_pos(refl, 0.0, fs, ss);
set_esd_intensity(refl, sigma);
set_redundancy(refl, 1);
set_peak(refl, pk);
set_mean_bg(refl, bg);
}
} while ( rval != NULL );
/* Got read error of some kind before finding PEAK_LIST_END_MARKER */
return NULL;
}
示例9: io_read_choices
struct choices *
io_read_choices(int read_descriptions)
{
char *line, *description, *field_separator;
size_t line_size;
ssize_t length;
struct choice *choice;
struct choices *choices;
field_separator = getenv("IFS");
if (field_separator == NULL) {
field_separator = " ";
}
choices = malloc(sizeof(struct choices));
if (choices == NULL) {
err(1, "malloc");
}
SLIST_INIT(choices);
for (;;) {
line = NULL;
description = "";
line_size = 0;
length = getline(&line, &line_size, stdin);
if (length == -1) {
break;
}
chomp(line, length);
if (read_descriptions) {
strtok_r(line, field_separator, &description);
}
choice = choice_new(line, description, 1);
SLIST_INSERT_HEAD(choices, choice, choices);
free(line);
}
free(line);
return choices;
}
示例10: updateTech
static void updateTech(void)
{
char buf[16000];
char *p = buf;
const char *ext;
int type;
int i;
ext = ASAPInfo_GetOriginalModuleExt(edited_info, saved_module, saved_module_len);
if (ext != NULL)
p += sprintf(p, "Composed in %s\r\n", ASAPInfo_GetExtDescription(ext));
i = ASAPInfo_GetSongs(edited_info);
if (i > 1) {
p += sprintf(p, "SONGS %d\r\n", i);
i = ASAPInfo_GetDefaultSong(edited_info);
if (i > 0)
p += sprintf(p, "DEFSONG %d (song %d)\r\n", i, i + 1);
}
p += sprintf(p, ASAPInfo_GetChannels(edited_info) > 1 ? "STEREO\r\n" : "MONO\r\n");
p += sprintf(p, ASAPInfo_IsNtsc(edited_info) ? "NTSC\r\n" : "PAL\r\n");
type = ASAPInfo_GetTypeLetter(edited_info);
if (type != 0)
p += sprintf(p, "TYPE %c\r\n", type);
p += sprintf(p, "FASTPLAY %d (%d Hz)\r\n", ASAPInfo_GetPlayerRateScanlines(edited_info), ASAPInfo_GetPlayerRateHz(edited_info));
if (type == 'C')
p += sprintf(p, "MUSIC %04X\r\n", ASAPInfo_GetMusicAddress(edited_info));
if (type != 0) {
p = appendAddress(p, "INIT %04X\r\n", ASAPInfo_GetInitAddress(edited_info));
p = appendAddress(p, "PLAYER %04X\r\n", ASAPInfo_GetPlayerAddress(edited_info));
p = appendAddress(p, "COVOX %04X\r\n", ASAPInfo_GetCovoxAddress(edited_info));
}
i = ASAPInfo_GetSapHeaderLength(edited_info);
if (i >= 0) {
while (p < buf + sizeof(buf) - 17 && i + 4 < saved_module_len) {
int start = saved_module[i] + (saved_module[i + 1] << 8);
int end;
if (start == 0xffff) {
i += 2;
start = saved_module[i] + (saved_module[i + 1] << 8);
}
end = saved_module[i + 2] + (saved_module[i + 3] << 8);
p += sprintf(p, "LOAD %04X-%04X\r\n", start, end);
i += 5 + end - start;
}
}
chomp(buf);
SendDlgItemMessage(infoDialog, IDC_TECHINFO, WM_SETTEXT, 0, (LPARAM) buf);
}
示例11: load_workitems
/*
* Load ip's/hosts in a linked list.
*/
void load_workitems(char *inputfile, workitem **wi_start, int reverse)
{
FILE *f;
workitem *curr, *head;
char host[256];
char line[256];
int first = 1;
head = NULL;
f = fopen(params->inputfile, "r");
if (f != NULL)
{
while (fgets(line, 255, f) != NULL)
{
memset(host, 0, sizeof(host));
chomp(line);
if (reverse)
{
strcpy(host, line);
}
else
{
strcat(host, line);
strcat(host, ".");
strcat(host, params->domain);
}
curr = (workitem *)malloc(sizeof(workitem)); /* free memory! */
memset(curr, 0, sizeof(workitem));
curr->wi = (char *)malloc(strlen(host) + 1);
memset(curr->wi, 0, strlen(host) + 1);
strcpy(curr->wi, host);
curr->next = head;
head = curr;
}
fclose(f);
*wi_start = head;
}
else
{
printf("Error: File %s could not be opened\n", inputfile);
exit -1;
}
}
示例12: fi_get_one_url
int fi_get_one_url(char *buf)
{
char tmp[1024];
pthread_mutex_lock(&m_file_mutex);
if (fgets(tmp, sizeof(tmp), m_fp)) {
chomp(tmp);
strcpy(buf, tmp);
pthread_mutex_unlock(&m_file_mutex);
return 0;
}
pthread_mutex_unlock(&m_file_mutex);
return -1;
}
示例13: while
char *treat_protein_name(char *protein_name_local, char *global_tmp_local){
int i=0;
char *cp1;
i=0;
while(isspace(global_tmp_local[i++])) {}
i-=2; if(i<=0) i=0;
cp1=global_tmp_local+i;
if(strlen(cp1)+strlen(protein_name_local)>protein_name_length){
protein_name_length+=MAXLETTER;
protein_name_local=(char *)realloc(protein_name_local, (size_t)protein_name_length);
}
strcat(protein_name_local, cp1);
strtok(protein_name_local,"[");
chomp(protein_name_local);
return protein_name_local;
}
示例14: process_args
static void process_args( WCHAR *cmdline, int *pargc, WCHAR ***pargv )
{
WCHAR **argv, *p = msi_strdup(cmdline);
int i, n;
n = chomp( p );
argv = HeapAlloc(GetProcessHeap(), 0, sizeof (WCHAR*)*(n+1));
for( i=0; i<n; i++ )
{
argv[i] = p;
p += lstrlenW(p) + 1;
}
argv[i] = NULL;
*pargc = n;
*pargv = argv;
}
示例15: parse_conf
static int parse_conf(char *file)
{
FILE *fp;
char line[LINE_SIZE] = "";
char *x;
fp = fopen(file, "r");
if (!fp)
return 1;
/*
* If not standard finit.conf, then we want to show just the base name
* Loading configuration ............. vs
* Loading services configuration ....
*/
if (!string_match (file, FINIT_CONF)) {
/* Remove leading path */
x = strrchr(file, '/');
if (!x) x = file;
else x++;
/* Remove ending .conf */
strlcpy(line, x, sizeof(line));
x = strstr(line, ".conf");
if (x) *x = 0;
/* Add empty space. */
strcat(line, " ");
}
if (!silent)
print(0, "Loading %sconfiguration", line);
while (!feof(fp)) {
if (!fgets(line, sizeof(line), fp))
continue;
chomp(line);
_d("conf: %s", line);
parse_static(line);
parse_dynamic(line, 0);
}
fclose(fp);
return 0;
}