本文整理汇总了C++中DupString函数的典型用法代码示例。如果您正苦于以下问题:C++ DupString函数的具体用法?C++ DupString怎么用?C++ DupString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DupString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init_conf
int init_conf(void)
{
if (read_configuration_file()) {
/*
* make sure we're sane to start if the config
* file read didn't get everything we need.
* XXX - should any of these abort the server?
* TODO: add warning messages
*/
if (0 == localConf.name || 0 == localConf.numeric)
return 0;
if (conf_error)
return 0;
if (0 == localConf.location1)
DupString(localConf.location1, "");
if (0 == localConf.location2)
DupString(localConf.location2, "");
if (0 == localConf.contact)
DupString(localConf.contact, "");
return 1;
}
return 0;
}
示例2: ServiceModule_do_help
static VALUE
ServiceModule_do_help(VALUE self, VALUE client, VALUE value, VALUE parv)
{
struct Service *service = get_service(self);
struct Client *cclient;
int argc = 0;
int i;
char *cvalue = 0;
char **argv = 0;
VALUE tmp;
Check_OurType(client, cClient);
cclient = value_to_client(client);
if(!NIL_P(value))
{
Check_Type(value, T_STRING);
Check_Type(parv, T_ARRAY);
DupString(cvalue, StringValueCStr(value));
argc = RARRAY(parv)->len - 1;
argv = ALLOCA_N(char *, argc);
for(i = 0; i < argc; ++i)
{
tmp = rb_ary_entry(parv, i);
DupString(argv[i], StringValueCStr(tmp));
}
}
示例3: check_repeat
/*
* check for public repeating and keep/replace appropriate last phrase
* -demond
*/
static int check_repeat(struct Client *source_p,
struct Channel *chptr,
char *text)
{
dlink_node *ptr;
struct Repeat *repeatptr;
for (ptr = source_p->user->repeat.head; ptr; ptr = ptr->next) {
repeatptr = ptr->data;
if (repeatptr->chptr == chptr)
if (!strcmp(repeatptr->text, text)) {
return 1;
} else {
MyFree(repeatptr->text);
DupString(repeatptr->text, text);
repeatptr->lastphrase = CurrentTime;
return 0;
}
}
repeatptr = (struct Repeat *)MyMalloc(sizeof(struct Repeat));
repeatptr->chptr = chptr;
DupString(repeatptr->text, text);
repeatptr->lastphrase = CurrentTime;
ptr = make_dlink_node();
dlinkAdd(repeatptr, ptr, &source_p->user->repeat);
return 0;
}
示例4: make_zline
/** Create a Zline structure.
* @param[in] mask Mask.
* @param[in] reason Reason for Z-line.
* @param[in] expire Expiration timestamp.
* @param[in] lastmod Last modification timestamp.
* @param[in] flags Bitwise combination of ZLINE_* bits.
* @return Newly allocated Z-line.
*/
static struct Zline *
make_zline(char *mask, char *reason, time_t expire, time_t lastmod,
time_t lifetime, unsigned int flags)
{
struct Zline *zline;
assert(0 != expire);
zline = (struct Zline *)MyMalloc(sizeof(struct Zline)); /* alloc memory */
assert(0 != zline);
DupString(zline->zl_reason, reason); /* initialize zline... */
zline->zl_expire = expire;
zline->zl_lifetime = lifetime;
zline->zl_lastmod = lastmod;
zline->zl_flags = flags & ZLINE_MASK;
zline->zl_state = ZLOCAL_GLOBAL; /* not locally modified */
DupString(zline->zl_mask, mask);
if (ipmask_parse(mask, &zline->zl_addr, &zline->zl_bits)) {
zline->zl_flags |= ZLINE_IPMASK;
zline->zl_addr = ipmask_clean(&zline->zl_addr, zline->zl_bits);
}
zline->zl_next = GlobalZlineList; /* then link it into list */
zline->zl_prev_p = &GlobalZlineList;
if (GlobalZlineList)
GlobalZlineList->zl_prev_p = &zline->zl_next;
GlobalZlineList = zline;
return zline;
}
示例5: parse_resv_file
void
parse_resv_file(FILE * file)
{
struct ConfItem *aconf;
char *reason_field;
char *host_field;
char line[BUFSIZE];
char *p;
while (fgets(line, sizeof(line), file))
{
if((p = strpbrk(line, "\r\n")))
*p = '\0';
if((*line == '\0') || (line[0] == '#'))
continue;
host_field = getfield(line);
if(EmptyString(host_field))
continue;
reason_field = getfield(NULL);
if(EmptyString(reason_field))
continue;
if(IsChannelName(host_field))
{
if(hash_find_resv(host_field))
continue;
aconf = make_conf();
aconf->status = CONF_RESV_CHANNEL;
aconf->port = 0;
DupString(aconf->name, host_field);
DupString(aconf->passwd, reason_field);
add_to_resv_hash(aconf->name, aconf);
}
else if(clean_resv_nick(host_field))
{
if(find_nick_resv(host_field))
continue;
aconf = make_conf();
aconf->status = CONF_RESV_NICK;
aconf->port = 0;
DupString(aconf->name, host_field);
DupString(aconf->passwd, reason_field);
dlinkAddAlloc(aconf, &resv_conf_list);
}
}
}
示例6: memset
static DOMAIN_PIECE *find_or_add_host_piece(DOMAIN_LEVEL *level_ptr,
int flags,char *host_piece)
{
DOMAIN_PIECE *piece_ptr;
DOMAIN_PIECE *cur_piece;
DOMAIN_PIECE *new_ptr;
DOMAIN_PIECE *last_ptr;
DOMAIN_PIECE *ptr;
int index;
index = *host_piece&(MAX_PIECE_LIST-1);
piece_ptr = level_ptr->piece_list[index];
if(piece_ptr == (DOMAIN_PIECE *)NULL)
{
cur_piece = (DOMAIN_PIECE *)MyMalloc(sizeof(DOMAIN_PIECE));
memset((void *)cur_piece,0,sizeof(DOMAIN_PIECE));
DupString(cur_piece->host_piece,host_piece);
level_ptr->piece_list[index] = cur_piece;
cur_piece->flags |= flags;
return(cur_piece);
}
last_ptr = (DOMAIN_PIECE *)NULL;
for(ptr=piece_ptr; ptr; ptr = ptr->next_piece)
{
if(!strcasecmp(ptr->host_piece,host_piece))
{
ptr->flags |= flags;
return(ptr);
}
last_ptr = ptr;
}
if(last_ptr)
{
new_ptr = (DOMAIN_PIECE *)MyMalloc(sizeof(DOMAIN_PIECE));
memset((void *)new_ptr,0,sizeof(DOMAIN_PIECE));
DupString(new_ptr->host_piece,host_piece);
last_ptr->next_piece = new_ptr;
new_ptr->flags |= flags;
return(new_ptr);
}
else
{
sendto_realops("Bug: in find_or_add_host_piece. yay.");
return(NULL);
}
/* NOT REACHED */
}
示例7: conf_add_fields
/* conf_add_fields()
*
* inputs - pointer to config item, host/pass/user/operreason fields
* output - NONE
* side effects - update respective fields with pointers
*/
static void
conf_add_fields(struct ConfItem *aconf, const char *host_field,
const char *pass_field, const char *user_field,
const char *operreason_field)
{
if(host_field != NULL)
DupString(aconf->host, host_field);
if(pass_field != NULL)
DupString(aconf->passwd, pass_field);
if(user_field != NULL)
DupString(aconf->user, user_field);
if(operreason_field != NULL)
DupString(aconf->spasswd, operreason_field);
}
示例8: GetGenre
LPSTR GetGenre(LPSTR lpsz)
{
int id = atoi(lpsz + 1);
int i;
if ((*(lpsz + 1) > '0') && (*(lpsz + 1) < '9'))
{
for (i = 0; i < NUMGENRES; i++)
{
if (id == ID3Genres[i].id)
return DupString(ID3Genres[i].name);
}
}
return DupString(lpsz);
}
示例9: DumpBlock
static void DumpBlock(const char *type, struct block_t *blk)
{
uint32 size = (ReadDword((uint32)&blk->size) - sizeof(*blk) - sizeof(uint32)) & ~7;
uint32 seq_id = ReadDword((uint32)&blk->seq_id);
uint32 line = ReadDword((uint32)&blk->line);
char *file = DupString(ReadDword((uint32)&blk->file));
char *func = DupString(ReadDword((uint32)&blk->func));
uint32 ptr = (uint32)blk + sizeof(*blk);
printf("%s %08x = seq:%5d, size:%5d, %-30.30s (%4d) %s\n",
type, ptr, seq_id, size, func, line, basename(file));
free(file);
free(func);
}
示例10: RETURN_ERROR
Lut_t *GetLut(int nband, Input_meta_t *meta, Img_coord_int_t *input_size) {
Lut_t *this;
/* Create the lookup table data structure */
this = (Lut_t *)malloc(sizeof(Lut_t));
if (this == NULL)
RETURN_ERROR("allocating Input data structure", "OpenInput", NULL);
/* Populate the data structure */
this->nband = nband;
this->in_fill = meta->fill;
this->output_fill = OUTPUT_FILL;
this->in_satu = INPUT_SATU;
this->output_satu = OUTPUT_SATU;
this->aerosol_fill = AEROSOL_FILL;
this->ar_region_size.l = AEROSOL_REGION_NLINE;
this->ar_region_size.s = AEROSOL_REGION_NSAMP;
this->ar_size.l = ((input_size->l - 1) / this->ar_region_size.l) + 1;
this->ar_size.s = ((input_size->s - 1) / this->ar_region_size.s) + 1;
this->min_valid_sr = MIN_VALID_SR;
this->max_valid_sr = MAX_VALID_SR;
this->atmos_opacity_scale_factor= ATMOS_OPACITY_SCALE_FACTOR;
this->scale_factor= SCALE_FACTOR; /* scale factor */
this->scale_factor_err= SCALE_FACTOR_ERR; /* scale factor error */
this->add_offset= ADD_OFFSET; /* add offset */
this->add_offset_err= ADD_OFFSET_ERR; /* add offset error */
this->calibrated_nt= CALIBRATED_NT; /* calibrated nt */
this->long_name_prefix = DupString(LONG_NAME_PREFIX);
if (this->long_name_prefix == NULL) {
free(this);
RETURN_ERROR("duplicating long name prefix", "GetLut", NULL);
}
this->units = DupString(UNITS);
if (this->units == NULL) {
free(this);
RETURN_ERROR("duplicating ref units", "GetLut", NULL);
}
if (!InputMetaCopy(meta, nband, &this->meta)) {
free(this);
RETURN_ERROR("copying input metadata", "GetLut", NULL);
}
return this;
}
示例11: m_sxline
/*
* m_sxline() - add info ban line
*
* parv[0] = sender prefix
* parv[1] = info banned mask
*/
int m_sxline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
{
aConfItem *aconf;
char *reason = NULL;
char *mask;
int len;
if (!IsService(sptr) && !IsServer(cptr))
{
sendto_one(sptr, form_str(ERR_NOPRIVILEGES), me.name, parv[0]);
return 0;
}
if(parc<3)
{
sendto_one(sptr, form_str(ERR_NEEDMOREPARAMS),
me.name, parv[0], "SXLINE");
return 0;
}
len=atoi(parv[1]);
mask = parv[2];
if ((strlen(mask) > len) && (mask[len])==':')
{
mask[len] = '\0';
reason = mask+len+1;
}
else
{ /* Bogus */
return 0;
}
if (!find_sxline(mask)) /* sxline does not exist */
{
aconf = make_conf();
DupString(aconf->name, mask);
DupString(aconf->passwd, reason);
aconf->next = sxlines;
sxlines = aconf;
sendto_serv_butone(cptr, ":%s SXLINE %d :%s:%s", sptr->name, len,
aconf->name,aconf->passwd);
}
return 0;
}
示例12: ReplaceString
/*
* ReplaceString - free a string, then allocate new one
*/
void ReplaceString( char **where, const char *str )
{
MemFree( *where );
*where = DupString( str );
} /* ReplaceString */
示例13: mr_error
/*
* mr_error - unregistered client message handler
*
* parv[0] = sender prefix
* parv[parc-1] = text
*/
int mr_error(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
{
const char *para;
if (!IsHandshake(cptr) && !IsConnecting(cptr))
return 0; /* ignore ERROR from regular clients */
para = (parc > 1 && *parv[parc - 1] != '\0') ? parv[parc - 1] : "<>";
Debug((DEBUG_ERROR, "Received ERROR message from %s: %s", cli_name(sptr), para));
if (cptr == sptr)
sendto_opmask_butone(0, SNO_OLDSNO, "ERROR :from %C -- %s", cptr, para);
else
sendto_opmask_butone(0, SNO_OLDSNO, "ERROR :from %C via %C -- %s", sptr,
cptr, para);
if (cli_serv(sptr))
{
MyFree(cli_serv(sptr)->last_error_msg);
DupString(cli_serv(sptr)->last_error_msg, para);
}
return 0;
}
示例14: do_query_name
/** Send a query to look up the address for a name.
* @param[in] query Callback information.
* @param[in] name Hostname to look up.
* @param[in] request DNS lookup structure (may be NULL).
* @param[in] type Preferred request type.
*/
static void
do_query_name(dns_callback_f callback, void *ctx, const char *name,
struct reslist *request, int type)
{
char host_name[HOSTLEN + 1];
ircd_strncpy(host_name, name, HOSTLEN);
add_local_domain(host_name, HOSTLEN);
if (request == NULL)
{
request = make_request(callback, ctx);
DupString(request->name, host_name);
#ifdef IPV6
if (type != T_A)
request->state = REQ_AAAA;
else
#endif
request->state = REQ_A;
}
request->type = type;
Debug((DEBUG_DNS, "Requesting DNS %s %s as %p", (request->state == REQ_AAAA ? "AAAA" : "A"), host_name, request));
query_name(host_name, C_IN, type, request);
}
示例15: create_channel_resv
struct ResvChannel *
create_channel_resv(char *name, char *reason, int conf)
{
struct ResvChannel *resv_p = NULL;
int len;
if(find_channel_resv(name))
return NULL;
if((len = strlen(reason)) > TOPICLEN)
{
reason[TOPICLEN] = '\0';
len = TOPICLEN;
}
resv_p = (struct ResvChannel *)MyMalloc(sizeof(struct ResvChannel));
strlcpy(resv_p->name, name, sizeof(resv_p->name));
DupString(resv_p->reason, reason);
resv_p->conf = conf;
if(ResvChannelList != NULL)
ResvChannelList->prev = resv_p;
resv_p->next = ResvChannelList;
resv_p->prev = NULL;
ResvChannelList = resv_p;
add_to_resv_hash_table(resv_p->name, resv_p);
return resv_p;
}