Example #1
0
static void parse_extended_opts(e2fsck_t ctx, const char *opts)
{
	char	*buf, *token, *next, *p, *arg;
	int	ea_ver;
	int	extended_usage = 0;

	buf = string_copy(ctx, opts, 0);
	for (token = buf; token && *token; token = next) {
		p = strchr(token, ',');
		next = 0;
		if (p) {
			*p = 0;
			next = p+1;
		} 
		arg = strchr(token, '=');
		if (arg) {
			*arg = 0;
			arg++;
		}
		if (strcmp(token, "ea_ver") == 0) {
			if (!arg) {
				extended_usage++;
				continue;
			}
			ea_ver = strtoul(arg, &p, 0);
			if (*p ||
			    ((ea_ver != 1) && (ea_ver != 2))) {
				fprintf(stderr,
					_("Invalid EA version.\n"));
				extended_usage++;
				continue;
			}
			ctx->ext_attr_ver = ea_ver;
		} else {
			fprintf(stderr, _("Unknown extended option: %s\n"),
				token);
			extended_usage++;
		}
	}
	if (extended_usage) {
		fputs(("\nExtended options are separated by commas, "
		       "and may take an argument which\n"
		       "is set off by an equals ('=') sign.  "
			"Valid extended options are:\n"
		       "\tea_ver=<ea_version (1 or 2)>\n\n"), stderr);
		exit(1);
	}
}	
Example #2
0
uint64_t system_hostid( void )
{
#if FOUNDATION_PLATFORM_ANDROID
    //Not implemented yet, see https://code.google.com/p/libjingle/source/browse/trunk/talk/base/ifaddrs-android.cc
    return 0;
#else
    struct ifaddrs* ifaddr;
    struct ifaddrs* ifa;
    uint64_t hostid = 0;

#if !FOUNDATION_PLATFORM_APPLE
    struct ifreq buffer;
    int sock = socket( PF_INET, SOCK_DGRAM, 0 );
#endif

    if( getifaddrs( &ifaddr ) == 0 )
    {
        for( ifa = ifaddr; ifa && !hostid; ifa = ifa->ifa_next )
        {
            if( string_equal_substr( ifa->ifa_name, "lo", 2 ) )
                continue;

#if FOUNDATION_PLATFORM_APPLE
            hostid = _system_hostid_lookup( ifa );
#else
            memset( &buffer, 0, sizeof( buffer ) );
            string_copy( buffer.ifr_name, ifa->ifa_name, sizeof( buffer.ifr_name ) );

            hostid = _system_hostid_lookup( sock, &buffer );
#endif
        }
        freeifaddrs( ifaddr );
    }
#if !FOUNDATION_PLATFORM_APPLE
    else
    {
        memset( &buffer, 0, sizeof( buffer ) );
        strcpy( buffer.ifr_name, "eth0" );

        hostid = _system_hostid_lookup( sock, &buffer );
    }

    close( sock );
#endif

    return hostid;
#endif
}
Example #3
0
File: blob.c Project: jlsandell/tig
static enum request
blob_request(struct view *view, enum request request, struct line *line)
{
	switch (request) {
	case REQ_VIEW_BLAME:
		if (view->parent)
			string_copy(view->env->ref, view->parent->vid);
		return request;

	case REQ_EDIT:
		open_blob_editor(view->vid, NULL, (line - view->line) + 1);
		return REQ_NONE;
	default:
		return pager_request(view, request, line);
	}
}
Example #4
0
OBJECT * path_tmpfile(void)
{
    OBJECT * result = 0;
    OBJECT * tmpnam;

    string file_path;
    string_copy(&file_path,path_tmpdir());
    string_push_back(&file_path,PATH_DELIM);
    tmpnam = path_tmpnam();
    string_append(&file_path,object_str(tmpnam));
    object_free(tmpnam);
    result = object_new(file_path.value);
    string_free(&file_path);

    return result;
}
Example #5
0
int string_resize (char ** string, int new_size)
{
    if (string == NULL)
    {
        return 0;
    }
    char * new_string = new char[new_size + 1];
    memset (new_string, 0, new_size + 1);
    string_copy( * string, new_string);
    if (* string != NULL)
    {
        delete [] * string;
    }
    * string = new_string;
    return string_length(* string);
}
Example #6
0
void
get_phases_real_path (void) {
#ifdef PATH_MAX
       char pathstr[PATH_MAX];
#else
       char pathstr[4096];
#endif
       phases_t i;
       for (i = P_NONE; i < P_LAST; i++) {
               if (!phase_info[i].dir) { continue; }
               char* p = realpath (phase_info[i].dir, pathstr);
               if (p && strcmp (p, phase_info[i].dir)) {
                       phase_info[i].dir = string_copy (p);
               }
       }
}
Example #7
0
void perform_split(const char* str, const int output_size,
                  const int string_size, char** output, char** error,
                  const int i, const int last_split, const int output_index) {
  // First check errors.
  int size = i - last_split;
  if (size > string_size) {
    *error = "string_size not large enough";
  }

  if (output_index > output_size - 1) {
    *error = "output_size not large enough";
  }

  // Otherwise we're good!
  string_copy(&str[last_split], size, output[output_index]);
}
Example #8
0
libusbp_error * libusbp_device_copy(const libusbp_device * source, libusbp_device ** dest)
{
    if (dest == NULL)
    {
        return error_create("Device output pointer is null.");
    }

    *dest = NULL;

    if (source == NULL)
    {
        return NULL;
    }

    libusbp_error * error = NULL;

    // Allocate the device.
    libusbp_device * new_device = NULL;
    if (error == NULL)
    {
        error = device_allocate(&new_device);
    }

    // Copy the simple fields, while leaving the pointers owned by the
    // device NULL so that libusbp_device_free is still OK to call.
    if (error == NULL)
    {
        memcpy(new_device, source, sizeof(libusbp_device));
        new_device->serial_number = NULL;
    }

    // Copy the serial number.
    if (error == NULL && source->serial_number != NULL)
    {
        error = string_copy(source->serial_number, &new_device->serial_number);
    }

    // Pass the device to the caller.
    if (error == NULL)
    {
        *dest = new_device;
        new_device = NULL;
    }

    libusbp_device_free(new_device);
    return error;
}
Example #9
0
/*! 
  Associate the sounds in the _name_ array with the
  sound context sound_context.  If more than one sound is specified,
  then a sound will be chosen randomly from the list each time the
  sound is played.  If num_sounds == 0, then the entry for the sound
  context is deleted.

  \pre     \c sound_context != NULL
  \arg \c  sound_context sound context to bind sounds to
  \arg \c  names list of sound names to bind to context
  \arg \c  num_sounds number of elements in \c names

  \return  none
  \author  jfpatry
  \date    Created:  2000-08-13
  \date    Modified: 2000-08-14
*/
void bind_sounds_to_context( char *sound_context, char **names, int num_sounds )
{
    int i;
    sound_context_data_t *data;

    check_assertion( initialized_, "audio module not initialized" );

    if ( get_hash_entry( sound_contexts_, sound_context, 
			 (hash_entry_t*) &data ) )
    {
	/* Entry for this context already exists; decrement ref_cts &
	   delete arrays */

	for (i=0; i<data->num_sounds; i++) {
	    decr_sound_data_ref_ctr( data->sound_names[i] );
	    free( data->sound_names[i] );
	}

	free( data->sound_names );
	free( data->chunks );
	del_hash_entry( sound_contexts_, sound_context, NULL );
    } else {
	data = (sound_context_data_t*)malloc( sizeof(sound_context_data_t) );
    }

    if ( num_sounds == 0 ) {
	/* delete the context */
	free( data );
	return;
    }

    check_assertion( num_sounds > 0, "num_sounds isn't > 0 " );

    data->num_sounds = num_sounds;
    data->sound_names = (char**)malloc( sizeof(char*)*num_sounds );
    data->chunks = (Mix_Chunk**)malloc( sizeof(Mix_Chunk*)*num_sounds );
    data->loop_count = 0;
    data->channel = 0;
    data->volume = 128;

    for (i=0; i<num_sounds; i++) {
	data->sound_names[i] = string_copy( names[i] );
	incr_sound_data_ref_ctr( names[i] );
	data->chunks[i] = NULL;
    }
    add_hash_entry( sound_contexts_, sound_context, (hash_entry_t)data );
}
Example #10
0
libusbp_error * libusbp_device_get_os_id(
    const libusbp_device * device, char ** id)
{
    if (id == NULL)
    {
        return error_create("Device OS ID output pointer is null.");
    }

    *id = NULL;

    if (device == NULL)
    {
        return error_create("Device is null.");
    }

    return string_copy(device->device_instance_id, id);
}
Example #11
0
static int
blast_client_send_handshake(blast_client_t* client, blast_reader_t* reader) {
	int iaddr, addrsize = 0;
	socket_t** socks;
	const network_address_t** addrarr;
	packet_handshake_t packet;

	packet.type = PACKET_HANDSHAKE;
	packet.token = 0;
	packet.timestamp = blast_timestamp(client->begin_send);
	packet.datasize = reader->size;
	packet.seq = blast_seq(client->seq++);
	packet.namesize = (uint32_t)string_copy(packet.name, sizeof(packet.name),
	                                        STRING_ARGS(reader->name)).length;

	if (client->target) {
		addrarr = &client->target;
		socks = &client->sock;
		addrsize = 1;
	}
	else {
		addrarr = (const network_address_t**)client->address;
		socks = client->socks;
		addrsize = array_size(addrarr);
	}

	for (iaddr = 0; iaddr < addrsize; ++iaddr) {
		udp_socket_sendto(socks[iaddr],
		                  &packet, sizeof(packet_handshake_t) - (PACKET_NAME_MAXSIZE - packet.namesize) + 1,
		                  addrarr[iaddr]);

#if BUILD_ENABLE_LOG
		{
			char buffer[NETWORK_ADDRESS_NUMERIC_MAX_LENGTH];
			string_t addr = network_address_to_string(buffer, sizeof(buffer), addrarr[iaddr], true);
			log_infof(HASH_BLAST, STRING_CONST("Sent handshake to %.*s (seq %lld, timestamp %lld)"),
			          STRING_FORMAT(addr), packet.seq,
			          (tick_t)packet.timestamp);
		}
#endif
	}

	client->last_send = time_current();

	return 0;
}
Example #12
0
File: nis.c Project: Exim/exim
static int
nis0_find(void *handle, uschar *filename, const uschar *keystring, int length,
  uschar **result, uschar **errmsg, uint *do_cache)
{
int rc;
uschar *nis_data;
int nis_data_length;
do_cache = do_cache;   /* Placate picky compilers */
if ((rc = yp_match(CCS handle, CCS filename, CCS keystring, length + 1,
    CSS &nis_data, &nis_data_length)) == 0)
  {
  *result = string_copy(nis_data);
  (*result)[nis_data_length] = 0;    /* remove final '\n' */
  return OK;
  }
return (rc == YPERR_KEY || rc == YPERR_MAP)? FAIL : DEFER;
}
Example #13
0
uschar *
string_domain_alabel_to_utf8(const uschar * alabel, uschar ** err)
{
uschar * s1;
uschar * s;
int rc;

if (  (rc = idna_to_unicode_8z8z(CCS alabel, CSS &s1, IDNA_USE_STD3_ASCII_RULES))
   != IDNA_SUCCESS)
  {
  if (err) *err = US idna_strerror(rc);
  return NULL;
  }
s = string_copy(s1);
free(s1);
return s;
}
Example #14
0
/*************************************************************************
 * f_sql_column_names( int handle )                                      
 *
 * returns the returned column names of the last executed statement
 *************************************************************************/
svalue_t *
f_sql_column_names( svalue_t * argv, int argc )
{
#if ODBC_DEBUG & DEBUG_FUNC
   printf( "call f_sql_column_names( )\n" );
#endif
   int  id, cnt, i;
   hDBC * handle;

   vector_t    * vec;

   TYPE_TEST1( argv, T_NUMBER );
   id = argv->u.number;
   free_svalue( argv );

   if ( !(handle = get_db_connection_by_id( id )) ) {
      errorf( "Illegal handle for database.\n" );

      return( NULL );
   }

   if ( !handle->columns ) {

      vec = allocate_array( 0 );
      MEM_CHECK( vec );

      put_array( argv, vec );
      return( argv );
   }

   cnt = handle->colcnt;

   vec = allocate_array( cnt );
   MEM_CHECK( vec );

   for ( i = 0; i < cnt; ++i ) {
      if ( handle->columns[ i ] )
         put_malloced_string(vec->item + i, string_copy(  handle->columns[ i ]->name ) );
   }

   put_array( argv, vec );
#if ODBC_DEBUG & DEBUG_FUNC
   printf( "ret f_sql_column_names( )\n" );
#endif
   return( argv );
}
Example #15
0
/*! 
  Associate the music with name _name_ to the music context
  _music_context_.  If _name_ is NULL or the null string, the data for
  the music context will be deleted.

  \pre     \c music_context != \c NULL
  \arg \c  music_context music context to bind sounds to
  \arg \c  name name of music to bind to context
  \arg \c  loop number of loops to play music for (-1 to loop forever)

  \return  none
  \author  jfpatry
  \date    Created:  2000-08-13
  \date Modified: 2000-08-14 */
void bind_music_to_context( char *music_context, char *name, int loop )
{
    music_context_data_t *data;

    check_assertion( initialized_, "audio module not initialized" );

    if ( get_hash_entry( music_contexts_, music_context, 
			 (hash_entry_t*) &data ) )
    {
	/* Entry for this context already exists; decrement ref count &
	   delete string */

	/* check if music is playing, stop if it is */
	if ( current_music_name_ != NULL && 
	     strcmp( current_music_name_, data->music_name ) == 0 )
	{

	    Mix_HaltMusic();

	    current_music_name_ = NULL;
	    current_music_data_ = NULL;
	    check_assertion( get_music_playing_status( data->music_name ),
			     "inconsistent music playing status info" );
	    set_music_playing_status( data->music_name, False );
	}

	decr_music_data_ref_ctr( data->music_name );
	free( data->music_name );
	del_hash_entry( music_contexts_, music_context, NULL );
    } else {
	data = (music_context_data_t*)malloc( sizeof(music_context_data_t) );
    }

    if ( name == NULL || name[0]=='\0' ) {
	/* delete the context */
	free( data );
	return;
    }

    data->music_name = string_copy( name );
    incr_music_data_ref_ctr( name );
    data->music = NULL;
    data->loop = loop;
    add_hash_entry( music_contexts_, music_context, (hash_entry_t)data );
}
Example #16
0
/***************************************************************************** 
 *                              M R B H D R                                  *
 *****************************************************************************/
ftnword f77name(mrbhdr)(word *buf, ftnword *f_temps,
			ftnword *f_flgs, char *f_stnid,
			ftnword *f_idtyp, ftnword *f_lati, ftnword *f_lon,
			ftnword *f_dx, ftnword *f_dy, ftnword *f_elev,
			ftnword *f_drcv, ftnword *f_date, ftnword *f_oars,
			ftnword *f_run, ftnword *f_nblk,
			ftnword *f_sup, ftnword *f_nsup,
			ftnword *f_xaux, ftnword *f_nxaux, int ll1)
{
int temps, flgs, idtyp, lati, lon;
int dx, dy,elev, drcv, date, oars, run, nblk;
int nsup=*f_nsup, nxaux=*f_nxaux;
char stnid[11] = {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','\0'};
int ier, l1;

#if defined(NEC64)
   BUF_C;
   ier = c_mrbhdr(buf+1, &temps, &flgs, stnid, &idtyp,
		  &lati, &lon, &dx, &dy, &elev,
		  &drcv, &date, &oars, &run, &nblk,
		  (word *)f_sup, nsup, (word *)f_xaux, nxaux);
   BUF_F;
#else
   ier = c_mrbhdr(buf, &temps, &flgs, stnid, &idtyp,
		  &lati, &lon, &dx, &dy, &elev,
		  &drcv, &date, &oars, &run, &nblk,
		  (word *)f_sup, nsup, (word *)f_xaux, nxaux);
#endif
   *f_temps = (ftnword) temps;
   *f_flgs = (ftnword) flgs;
   *f_idtyp = (ftnword) idtyp;
   *f_lati  = (ftnword) lati;
   *f_lon = (ftnword) lon;
   *f_dx = (ftnword) dx;
   *f_dy = (ftnword) dy;
   *f_elev = (ftnword) elev;
   *f_drcv = (ftnword) drcv;
   *f_date = (ftnword) date;
   *f_oars = (ftnword) oars;
   *f_run = (ftnword) run;
   *f_nblk = (ftnword) nblk;
   l1 = (ll1 > 11) ? 11: ll1;
   string_copy(f_stnid,stnid,l1);
   return((ftnword) ier);
}
Example #17
0
rc_t vds_rinsert( p_dump_str s, const char *s1 )
{
    size_t len;
    if ( ( s == NULL )||( s1 == NULL ) )
    {
        return RC( rcVDB, rcNoTarg, rcInserting, rcParam, rcNull );
    }
    len = string_size( s1 );
    if ( len == 0 )
    {
        return RC( rcVDB, rcNoTarg, rcInserting, rcParam, rcEmpty );
    }
    if ( s->str_len <= len ) return 0;
    len = s->str_len - len;
    string_copy( s->buf + len, sizeof( s->buf ) - len, s1, string_size( s1 ) );
    /* s->str_len does not change */
    return 0;
}
Example #18
0
static char *find_fsck(char *type)
{
  char *s;
  const char *tpl;
  static char prog[256];
  char *p = string_copy(fsck_path);
  struct stat st;

  
  tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s");

  for(s = strtok(p, ":"); s; s = strtok(NULL, ":")) {
	sprintf(prog, tpl, s, type);
	if (stat(prog, &st) == 0) break;
  }
  free(p);
  return(s ? prog : NULL);
}
Example #19
0
/**
 * Performs code-generation for a lookup node.
 */
int generate_lookup(Pool *pool, FILE *out, AstLookup *p)
{
  int rv;

  /* If a tag satisfies the lookup, generate that: */
  rv = generate_lookup_tag(pool, out, p);
  if (rv == 1) return 1;
  if (rv == 0) return 0;

  /* If that didn't work, try the built-in transforms: */
  if (generate_lookup_builtin(pool, out, p))
    return 1;

  source_location(stderr, p->name.p);
  fprintf(stderr, "error: Could not find a transform named \"%s\".\n",
    string_copy(pool, p->name).p);
  return 0;
}
Example #20
0
/**
 * Performs code-generation for a map statement.
 */
int generate_map(Pool *pool, FILE *out, AstMap *p)
{
  ListNode *line;

  /* Match against the map: */
  for (line = p->lines; line; line = line->next) {
    AstMapLine *l = ast_to_map_line(line->d);
    if (test_filter(l->filter, p->item)) {
      CHECK(generate_code(pool, out, l->code));
      return 1;
    }
  }

  /* Nothing matched: */
  fprintf(stderr, "error: Could not match item \"%s\" against map.\n",
    string_copy(pool, p->item->name).p);
  return 0;
}
Example #21
0
uschar *
tls_cert_serial_number(void * cert, uschar * mod)
{
    uschar bin[50], txt[150];
    size_t sz = sizeof(bin);
    uschar * sp;
    uschar * dp;
    int ret;

    if ((ret = gnutls_x509_crt_get_serial((gnutls_x509_crt_t)cert,
                                          bin, &sz)))
        return g_err("gs0", __FUNCTION__, ret);

    for(dp = txt, sp = bin; sz; dp += 2, sp++, sz--)
        sprintf(dp, "%.2x", *sp);
    for(sp = txt; sp[0]=='0' && sp[1]; ) sp++;	/* leading zeroes */
    return string_copy(sp);
}
Example #22
0
static LIST* downcase_list( LIST *in )
{
    LIST* result = 0;
    
    string s[1];
    string_new( s );
        
    while (in)
    {
        string_copy( s, in->string );
        downcase_inplace( s->value );
        result = list_append( result, list_new( 0, newstr( s->value ) ) );
        in = in->next;
    }
    
    string_free( s );
    return result;
}
Example #23
0
libusbp_error * libusbp_serial_port_get_name(
    const libusbp_serial_port * port,
    char ** name)
{
    if (name == NULL)
    {
        return error_create("String output pointer is null.");
    }

    *name = NULL;

    if (port == NULL)
    {
        return error_create("Serial port is null.");
    }

    return string_copy(port->port_name, name);
}
Example #24
0
/* Find fsck program for a given fs type. */
static char *find_fsck(char *type)
{
  char *s;
  const char *tpl;
  char *p = string_copy(fsck_path);
  struct stat st;

  /* Are we looking for a program or just a type? */
  tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s");

  for(s = strtok(p, ":"); s; s = strtok(NULL, ":")) {
	s = xasprintf(tpl, s, type);
	if (stat(s, &st) == 0) break;
	free(s);
  }
  free(p);
  return s;
}
Example #25
0
/*
 * Interpret filesystem auto type if necessary
 */
static void interpret_type(struct fs_info *fs)
{
	const char	*type;
	
	if (strcmp(fs->type, "auto") == 0 ||
	    (strchr(fs->type, ',') != 0)) {
		if (fs && strchr(fs->device, '='))
			fs->device = interpret_device(fs->device);
		type = identify_fs(fs->device, fs->type);
		if (type) {
			free(fs->type);
			fs->type = string_copy(type);
		} else
			fprintf(stderr, _("Could not determine "
					  "filesystem type for %s\n"),
				fs->device);
	}
}
Example #26
0
uint64_t system_hostid( void )
{
	struct ifaddrs* ifaddr;
	struct ifaddrs* ifa;
	uint64_t hostid = 0;

#if !FOUNDATION_PLATFORM_APPLE
	struct ifreq buffer;
	int sock = socket( PF_INET, SOCK_DGRAM, 0 );
#endif
	
	if( getifaddrs( &ifaddr ) == 0 )
	{
		for( ifa = ifaddr; ifa && !hostid; ifa = ifa->ifa_next )
		{
			if( string_equal_substr( ifa->ifa_name, "lo", 2 ) )
				continue;
			
#if FOUNDATION_PLATFORM_APPLE
			
			
#else
			memset( &buffer, 0, sizeof( buffer ) );
			string_copy( buffer.ifr_name, ifa->ifa_name, sizeof( buffer.ifr_name ) );

			hostid = _system_hostid_lookup( sock, &buffer );
#endif
		}
		freeifaddrs( ifaddr );
	}
#if !FOUNDATION_PLATFORM_APPLE
	else
	{
		memset( &buffer, 0, sizeof( buffer ) );
		strcpy( buffer.ifr_name, "eth0" );

		hostid = _system_hostid_lookup( sock, &buffer );
	}

	close( sock );
#endif
	
	return hostid;
}
Example #27
0
/*************************************************************************
 * extracts the dignosticinfo of an handle.
 *************************************************************************/
static char *
extract_diagnostics_info( SQLSMALLINT type, SQLHANDLE handle )
{
   char       ** tmp;
   char       * ret;
   int        i,
              j = 0;

   SQLINTEGER recnum;
   
   SQLGetDiagField( type, handle, 0, SQL_DIAG_NUMBER, &recnum, SQL_IS_INTEGER, 0 );

   if ( !recnum )
      return( NULL );

   tmp = pxalloc( recnum * sizeof( tmp ) );

   SQLCHAR     state[ 7 ];
   SQLINTEGER  native;
   SQLCHAR     text[1000],
               buffer[1000];
   SQLSMALLINT len;

  for ( i = 0; i < recnum; i++ ) {
      SQLGetDiagRec( type, handle, i+1, state, &native, text, sizeof( text ), &len );
      sprintf( buffer, "[%5s]%s\n", state, text );
      tmp[ i ] = string_copy( buffer );
      j += strlen( tmp[ i ] );
   }
   
   ret = pxalloc( (j + 1) * sizeof( char ) );
   for ( i = 0; i < recnum; i++ ) {
      if( i ) {
         strcat( ret, tmp[ i ] );
      } else {
         strcpy( ret, tmp[ i ] );
      }
      pfree( tmp[ i ] );
   }
   
   pfree( tmp );

   return( ret );
}
Example #28
0
int main(void)
{
    int n;
    char a[SIZE], b[SIZE];

    printf("文字列(空白無し)を一つ入力してください:");
    scanf("%s", a);
    printf("先頭から何文字をそのままコピーしますか:");
    scanf("%d",&n);

    string_copy(b, a, n);
    printf("コピーした文字列:<%s>\n", b);

    /* 以下は参考までに 
    string_copy( b, &a[1] ,n);
    printf("1 文字ずらしてコピーした文字列:<%s>\n", b);
    */
    return 0;
}
Example #29
0
/*
 * This function returns true if a particular option appears in a
 * comma-delimited options list
 */
static int opt_in_list(char *opt, char *optlist)
{
	char    *list, *s;

	if (!optlist)
		return 0;
	list = string_copy(optlist);

	s = strtok(list, ",");
	while(s) {
		if (strcmp(s, opt) == 0) {
			free(list);
			return 1;
		}
		s = strtok(NULL, ",");
	}
	free(list);
	return 0;
}
Example #30
0
File: srs.c Project: ArthasZRZ/exim
int eximsrs_reverse(uschar **result, uschar *address)
{
  char res[512];
  int n;

  if((n = srs_reverse(srs, address, res, sizeof(res))) & SRS_RESULT_FAIL)
  {
    DEBUG(D_any)
      debug_printf("srs_reverse failed (%s): %s\n", address, srs_geterrormsg(n));
    if(n == SRS_RESULT_NOTSRS || n == SRS_RESULT_BADSRS)
      return DECLINE;
    if(n == SRS_RESULT_BADHASH || n == SRS_RESULT_BADTIMESTAMP || n == SRS_RESULT_TIMESTAMPEXPIRED)
      return FAIL;
    return DEFER;
  }

  *result = string_copy(res);
  return OK;
}