Ejemplo n.º 1
0
std::string Relais::write_channel(int channel, bool onoff)
{
    int input_int=0; 
//     string::iterator i;
//     int counter=0;
//     for (int i=1; i<9; i++)
//     {
//        if (i!=channel) input_int+= std::pow(2,channel_bench[i]);
//        else if (i==channel && onoff == true &&int(onoff)!=channel_bench[i])input_int+= std::pow(2,i-1);
//        else if (i==channel&&int(onoff)==channel_bench[i]) input_int+= std::pow(2,channel_bench[i]);
//     }
    if (channel < 8 && channel > -1)
    {
      this->channel_bench[7-channel] = onoff; //reversed logic!
      
      std::string s;
      s.clear();
      s = "\xf0";
      s += static_cast<char>(this->channel_bench.to_ulong());
      std::string  answer=this->inputOutput(s);
      if(!answer.c_str()==static_cast<char>(this->channel_bench.to_ulong()))  std::cout << "Relais: SET ERROR: Relais answerd"  <<answer << std::endl;

    }
 return    read_channels();
}
Ejemplo n.º 2
0
void read_channels_epgdump( char *arg_onTV, STATION **psta, int *pcount )
{
	if(strcmp(arg_onTV, "/BS") == 0){
		StaCount = read_channels( "/usr/local/etc/bs_channels.txt",4000,4, names, Sta, ch );
		if( StaCount ){
			*psta = Sta;
			*pcount = StaCount;
		}
	}else if(strcmp(arg_onTV, "/CS") == 0){
		StaCount = read_channels( "/usr/local/etc/cs_channels.txt",5000,7, names, Sta, ch );
		if( StaCount ){
			*psta = Sta;
			*pcount = StaCount;
		}
	}
	return;
}
Ejemplo n.º 3
0
void read_channels_tune( char *arg_onTV, struct channel **pch, int *pcount )
{
	if(strcmp(arg_onTV, "/BS") == 0){
		StaCount = read_channels( "/usr/local/etc/bs_channels.txt",4000,4, names, Sta, ch );
		if( StaCount ){
			*pch = ch;
			*pcount = StaCount;
		}
	}else if(strcmp(arg_onTV, "/CS") == 0){
		StaCount = read_channels( "/usr/local/etc/cs_channels.txt",5000,7, names, Sta, ch );
		if( StaCount ){
			*pch = ch;
			*pcount = StaCount;
		}
	}
	return;
}
Ejemplo n.º 4
0
/* Should be removed when the new config system is in place. */
static int tcl_loadchannels(ClientData cd, Tcl_Interp *irp, int argc,
                            char *argv[])
{
  BADARGS(1, 1, "");
  if (!chanfile[0]) {
    Tcl_AppendResult(irp, "no channel file");
    return TCL_ERROR;
  }
  setstatic = 0;
  read_channels(1);
  return TCL_OK;
}
Ejemplo n.º 5
0
/* Thread worker */
void * thread_main(void *arg)
{
	long ret;
	unsigned long thread_num = (unsigned long)arg;

	ret = pipe(thread_pipe);
	if (ret < 0) {
		perror("Error creating pipe");
		return (void*)ret;
	}
	ret = read_channels(thread_num, &fd_pairs, inotify_fd, &inotify_watch_array);
	close(thread_pipe[0]);	/* close read end */
	close(thread_pipe[1]);	/* close write end */
	return (void*)ret;
}
Ejemplo n.º 6
0
static void channels_rehash()
{
  struct chanset_t *chan;

  setstatic = 0;
  read_channels(1);
  /* Remove any extra channels, by checking the flag. */
  chan = chanset;
  for (chan = chanset; chan;) {
    if (chan->status & CHAN_FLAGGED) {
      putlog(LOG_MISC, "*", "No longer supporting channel %s", chan->dname);
      remove_channel(chan);
      chan = chanset;
    } else
      chan = chan->next;
  }
}
Ejemplo n.º 7
0
void do_rogues(char *infilename,int *a_srate,dataptr dz)
{
	if(read_special_type(dz)<0)
		return;
	if(read_srate(infilename,dz)<0)
		return;
	if(*a_srate==0)
		*a_srate = dz->infile->srate;
	else if(*a_srate!= dz->infile->srate) {
		sprintf(errstr,"%s has different sampling rate [%d] to earlier file [%d]\n",
		infilename,dz->infile->srate,*a_srate);
		print_outmessage_flush(errstr);
		return;
	}
	if(read_channels(infilename,dz)<0)
		return;
	get_length(infilename,dz);
}
Ejemplo n.º 8
0
static void channels_rehash()
{
  struct chanset_t *chan;

  setstatic = 0;
  read_channels(1);
  /* remove any extra channels */
  chan = chanset;
  while (chan) {
    if (chan->status & CHAN_FLAGGED) {
      putlog(LOG_MISC, "*", "No longer supporting channel %s", chan->name);
      if (!channel_inactive(chan))
	dprintf(DP_SERVER, "PART %s\n", chan->name);
      remove_channel(chan);
      chan = chanset;
    } else
      chan = chan->next;
  }
}
Ejemplo n.º 9
0
char *channels_start(Function * global_funcs)
{
  global = global_funcs;

  gfld_chan_thr = 10;
  gfld_chan_time = 60;
  gfld_deop_thr = 3;
  gfld_deop_time = 10;
  gfld_kick_thr = 3;
  gfld_kick_time = 10;
  gfld_join_thr = 5;
  gfld_join_time = 60;
  gfld_ctcp_thr = 5;
  gfld_ctcp_time = 60;
  global_idle_kick = 0;
  Context;
  module_register(MODULE_NAME, channels_table, 1, 0);
  if (!module_depend(MODULE_NAME, "eggdrop", 105, 3)) {
    module_undepend(MODULE_NAME);
    return "This module needs eggdrop1.5.3 or later";
  }
  add_hook(HOOK_MINUTELY, (Function) check_expired_bans);
  add_hook(HOOK_MINUTELY, (Function) check_expired_exempts);
  add_hook(HOOK_MINUTELY, (Function) check_expired_invites);
  add_hook(HOOK_USERFILE, (Function) channels_writeuserfile);
  add_hook(HOOK_REHASH, (Function) channels_rehash);
  add_hook(HOOK_PRE_REHASH, (Function) channels_prerehash);
  Tcl_TraceVar(interp, "global-chanset",
	       TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
	       traced_globchanset, NULL);
  add_builtins(H_chon, my_chon);
  add_builtins(H_dcc, C_dcc_irc);
  add_tcl_commands(channels_cmds);
  add_tcl_strings(my_tcl_strings);
  add_help_reference("channels.help");
  add_help_reference("chaninfo.help");
  my_tcl_ints[0].val = &share_greet;
  add_tcl_ints(my_tcl_ints);
  add_tcl_coups(mychan_tcl_coups);
  read_channels(0);
  setstatic = 1;
  return NULL;
}
Ejemplo n.º 10
0
/**
 * @ingroup lte_resource_mapper
 *
 *	See lte_ctrl_tx for grid params.
 *
 * \param nof_channels Number of channels to extract
 * \param channel_id_n Id of the n-th channel to extract (configured in channel_setup.h)
 * \param (optional) subframe_idx, if not provided, subframe_idx is counted automatically starting at zero
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {
	int i;
	char tmp[64];
	int max_out_port;

	max_out_port = read_channels();

	grid.fft_size = 128;
	grid.nof_prb = 6;
	grid.nof_osymb_x_subf = 14;
	grid.nof_ports = 1;
	grid.cell_id = 0;
	grid.cfi = -1;
	grid.nof_pdsch = 0;
	grid.nof_pdcch = 0;

	subframe_idx_id = param_id("subframe_idx");
	if (!subframe_idx_id) {
		subframe_idx = 0;
	}

	if (param_get_int_name("nof_channels",&nof_channels)) {
		nof_channels = 1;
	}
	if (nof_channels > MAX_CHANNELS) {
		moderror_msg("Maximum allowed channels is %d (%d)\n",nof_channels,MAX_CHANNELS);
		return -1;
	}
	for (i=0;i<nof_channels;i++) {
		snprintf(tmp,64,"channel_id_%d",i);
		if (param_get_int_name(tmp,&channel_ids[i])) {
			channel_ids[i] = i;
		}
	}

	nof_output_itf = max_out_port+1;
	nof_input_itf = 1;


	return 0;
}
Ejemplo n.º 11
0
int read_fifo_store_data(int fifo_fd, int storage_fd, unsigned char* buf, size_t length)
{
	fprintf(stderr, "Child process %i has entered read_fifo_store_data\n", getpid() );
	int bytes_read;

	while(1){
		if ( (bytes_read = read(fifo_fd, buf, length)) != length) //reading from fifo_device
        	{
            		fprintf(stderr, "Error: couldn't read from fifo_dev correctly; bytes_read = %d\n", bytes_read);
        	}

        // now store the data in buf to a file
		calculate_checksum();
		read_channels();
		determineError(pass_fail);
		write(storage_fd, buf, bytes_read);
		fprintf(stderr, "Child read from fifo. \n");
    }
	close(storage_fd);
	close(fifo_fd);
    	return 0;
}
Ejemplo n.º 12
0
/**
 * @ingroup lte_resource_mapper
 *
 *	See lte_ctrl_tx for grid params.
 *
 * \param (optional) subframe_idx, if not provided, subframe_idx is counted automatically starting at zero
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {
	int max_in_port;

	max_in_port = read_channels();

	grid.fft_size = 128;
	grid.nof_prb = 6;
	grid.nof_osymb_x_subf = 14;
	grid.nof_ports = 1;
	grid.cell_id = 0;
	grid.cfi = 1;
	grid.nof_pdcch = 1;
	grid.pdcch[0].nof_cce = 2;
	grid.nof_pdsch = 1;
	grid.pdsch[0].rbg_mask=0xFFFF;
	grid.verbose = 0;

	if (lte_grid_init(&grid)) {
		moderror("Initiating channels grid\n");
		return -1;
	}

	nof_output_itf = 1;
	nof_input_itf = max_in_port+1;

	if (init_refsinc_signals()) {
		return -1;
	}

	subframe_idx_id = param_id("subframe_idx");
	if (!subframe_idx_id) {
		subframe_idx = 0;
	}

	return 0;
}
Ejemplo n.º 13
0
int main(int argc, char *argv[])
{
	const char *home;
	char chanfile[2 * PATH_MAX];
	int list_channels = 0;
	unsigned int chan_no = 0;
	const char *chan_name = NULL;
	unsigned int adapter = 0, frontend = 0, demux = 0, dvr = 0, rec_psi = 0;
	int bypass = 0;
	int opt, copt = 0;
	int human_readable = 0;

	lnb_type = *lnb_enum(0);

	while ((opt = getopt(argc, argv, "Hhqrpn:a:f:d:c:l:xib")) != -1) {
		switch (opt) {
		case '?':
		case 'h':
		default:
			bad_usage(argv[0], 0);
		case 'b':
			bypass = 1;
			break;
		case 'q':
			list_channels = 1;
			break;
		case 'r':
			dvr = 1;
			break;
		case 'n':
			chan_no = strtoul(optarg, NULL, 0);
			break;
		case 'a':
			adapter = strtoul(optarg, NULL, 0);
			break;
		case 'f':
			frontend = strtoul(optarg, NULL, 0);
			break;
		case 'p':
			rec_psi = 1;
			break;
		case 'd':
			demux = strtoul(optarg, NULL, 0);
			break;
		case 'c':
			copt = 1;
			strncpy(chanfile, optarg, sizeof(chanfile));
			break;
		case 'l':
			if (lnb_decode(optarg, &lnb_type) < 0) {
				bad_usage(argv[0], 1);
				return -1;
			}
			break;
		case 'x':
			exit_after_tuning = 1;
			break;
		case 'H':
			human_readable = 1;
			break;
		case 'i':
			interactive = 1;
			exit_after_tuning = 1;
		}
	}
	lnb_type.low_val *= 1000;	/* convert to kiloherz */
	lnb_type.high_val *= 1000;	/* convert to kiloherz */
	lnb_type.switch_val *= 1000;	/* convert to kiloherz */

	if (optind < argc)
		chan_name = argv[optind];

	if (chan_name && chan_no) {
		bad_usage(argv[0], 0);
		return -1;
	}
	if (list_channels && (chan_name || chan_no)) {
		bad_usage(argv[0], 0);
		return -1;
	}
	if (!list_channels && !chan_name && !chan_no && !interactive) {
		bad_usage(argv[0], 0);
		return -1;
	}

	if (!copt) {
		if (!(home = getenv("HOME"))) {
			fprintf(stderr, "error: $HOME not set\n");
			return TRUE;
		}
		snprintf(chanfile,
			 sizeof(chanfile),
			 "%s/.szap/%i/%s",
	   		 home,
	   		 adapter,
	   		 CHANNEL_FILE);

		if (access(chanfile, R_OK))
			snprintf(chanfile,
				 sizeof(chanfile),
				 "%s/.szap/%s",
	    			 home,
	    			 CHANNEL_FILE);
	}
	printf("reading channels from file '%s'\n", chanfile);

	if (rec_psi)
		dvr=1;

	if (!read_channels(chanfile,
			   list_channels,
		    	   chan_no,
		    	   chan_name,
			   adapter,
		    	   frontend,
		    	   demux,
		    	   dvr,
		    	   rec_psi,
		    	   bypass,
		    	   human_readable))
		return TRUE;

	return FALSE;
}
Ejemplo n.º 14
0
auto_ptr<VoxelGrid> read_fluid_file(
    const char*         filename,
    FluidChannels&      channels)
{
    assert(filename);

    FILE* file = fopen(filename, "rb");

    if (file == 0)
        return auto_ptr<VoxelGrid>(0);

    // Read the file header.
    FluidFileHeader header;
    if (fread(&header, sizeof(FluidFileHeader), 1, file) < 1)
    {
        fclose(file);
        return auto_ptr<VoxelGrid>(0);
    }

    // Check the validity of the file header.
    if (header.m_id != CC32('F', 'L', 'D', '3'))
    {
        fclose(file);
        return auto_ptr<VoxelGrid>(0);
    }

    const size_t voxel_count = header.m_xres * header.m_yres * header.m_zres;

    // Compute the number of channels, and set channel indices.
    size_t channel_count = 0;
    if (header.m_has_color)
    {
        channels.m_color_index = channel_count;
        channel_count += 3;
    }
    if (header.m_has_density)
    {
        channels.m_density_index = channel_count;
        channel_count += 1;
    }
    if (header.m_has_temperature)
    {
        channels.m_temperature_index = channel_count;
        channel_count += 1;
    }
    if (header.m_has_fuel)
    {
        channels.m_fuel_index = channel_count;
        channel_count += 1;
    }
    if (header.m_has_falloff)
    {
        channels.m_falloff_index = channel_count;
        channel_count += 1;
    }
    if (header.m_has_pressure)
    {
        channels.m_pressure_index = channel_count;
        channel_count += 1;
    }
    if (header.m_has_coordinates)
    {
        channels.m_coordinates_index = channel_count;
        channel_count += 3;
    }
    if (header.m_has_velocity)
    {
        channels.m_velocity_index = channel_count;
        channel_count += 3;
    }

    auto_ptr<VoxelGrid> grid(
        new VoxelGrid(
            header.m_xres,
            header.m_yres,
            header.m_zres,
            channel_count));

    size_t channel_index = 0;
    size_t read = 0;
    size_t needed = 0;

    // Read fluid color.
    if (header.m_has_color)
    {
        read += read_channels(file, grid.get(), channel_index, 3);
        needed += voxel_count * 3;
        channel_index += 3;
    }

    // Read fluid density.
    if (header.m_has_density)
    {
        read += read_channels(file, grid.get(), channel_index, 1);
        needed += voxel_count;
        channel_index += 1;
    }

    // Read fluid temperature.
    if (header.m_has_temperature)
    {
        read += read_channels(file, grid.get(), channel_index, 1);
        needed += voxel_count;
        channel_index += 1;
    }

    // Read fluid fuel.
    if (header.m_has_fuel)
    {
        read += read_channels(file, grid.get(), channel_index, 1);
        needed += voxel_count;
        channel_index += 1;
    }

    // Read fluid falloff.
    if (header.m_has_falloff)
    {
        read += read_channels(file, grid.get(), channel_index, 1);
        needed += voxel_count;
        channel_index += 1;
    }

    // Read fluid pressure.
    if (header.m_has_pressure)
    {
        read += read_channels(file, grid.get(), channel_index, 1);
        needed += voxel_count;
        channel_index += 1;
    }

    // Read fluid coordinates.
    if (header.m_has_coordinates)
    {
        read += read_channels(file, grid.get(), channel_index, 3);
        needed += voxel_count * 3;
        channel_index += 3;
    }

    // Read fluid velocity.
    if (header.m_has_velocity)
    {
        // X.
        read += read_channels(file, grid.get(), channel_index, 1);
        needed += voxel_count;
        channel_index += 1;

        // Y.
        read += read_channels(file, grid.get(), channel_index, 1);
        needed += voxel_count;
        channel_index += 1;

        // Z.
        read += read_channels(file, grid.get(), channel_index, 1);
        needed += voxel_count;
        channel_index += 1;
    }

    assert(channel_index == channel_count);

    fclose(file);

    return read == needed ? grid : auto_ptr<VoxelGrid>(0);
}
Ejemplo n.º 15
0
/* This is to be called at every loop() */
int ReceiverRouter::get_stm_action() {
    read_channels(); //Once every 500ms
    return parse_action();
}
Ejemplo n.º 16
0
static void channels_rehash()
{
  /* add channels from the chanfile but don't remove missing ones */
  read_channels(1, 0);
  write_channels();
}
Ejemplo n.º 17
0
Archivo: rpc.c Proyecto: lynnard/RPC
int main(int argc, char *argv[])
{
    int channels_len;
    fm_channel_t* channels;
    if (read_channels(&channels, &channels_len) != 0) {
        printf("Failed to retrieve the channel list. Try again later.\n");
        return -1;
    }

    char *addr = "localhost";
    char *port = "10098";
    int c;

    while ((c = getopt(argc, argv, "a:p:")) != -1) {
        switch (c) {
            case 'a':
                addr = optarg;
                break;
            case 'p':
                port = optarg;
                break;
            default:
                break;
        }
    }

    char input_buf[64] = "";
    char output_format[512] = "";
    char output_buf[1024] = "";
    int buf_size;

    if (optind < argc) {
        strcpy(input_buf, argv[optind]);
        int i;
        char *buf = strcmp(input_buf, "info") == 0 ? output_format : input_buf;
        for (i = optind + 1; i < argc; i++) {
            strcat(buf, " ");
            strcat(buf, argv[i]);
        }
    } else {
        strcpy(input_buf, "info");
    }

    int open_webpage = 0;
    if (strcmp(input_buf, "channels") == 0) {
        print_channels(channels, channels_len);
        return 0;
    }
    else if (strcmp(input_buf, "help") == 0) {
        print_usage();
        return 0;
    }
    else if (strcmp(input_buf, "launch") == 0) {
        // forcefully restart RPD
        system("pgrep rpd && /usr/local/bin/rpc end && sleep 30; /usr/local/bin/rpd");
        return 0;
    } 
    else if (strncmp(input_buf, "webpage", 7) == 0) {
        // client told to trigger a webpage
        strcpy(input_buf, "info");
        open_webpage = 1;
    }

    struct addrinfo hints, *results, *p;
    int sock_fd;

    memset(&hints, 0, sizeof(hints));
    hints.ai_family = AF_INET;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_flags = AI_PASSIVE;

    if (getaddrinfo(addr, port, &hints, &results) != 0) {
        return -1;
    }

    for (p = results; p != NULL; p = p->ai_next) {
        sock_fd = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
        if (sock_fd < 0) {
            continue;
        }
        if (connect(sock_fd, p->ai_addr, p->ai_addrlen) == 0) {
            break;
        }
        close(sock_fd);
    }
    if (p == NULL) {
        perror("connect");
        return -1;
    }

    freeaddrinfo(results);

    send(sock_fd, input_buf, strlen(input_buf), 0);
    buf_size = recv(sock_fd, output_buf, sizeof(output_buf), 0);
    if (buf_size == 0) {
        close(sock_fd);
        return 0;
    }
    output_buf[buf_size] = '\0';
    close(sock_fd);

    json_object *obj = json_tokener_parse(output_buf);
    char *status = obj ? strdup(json_object_get_string(json_object_object_get(obj, "status"))) : "error", 
         *channel = "", *artist = "", *title = "", pos[16] = "", len[16] = "", kbps[8] = "", *album = "", *cover = "", year[8] = "", *douban_url = "", *like = "";
    if (strcmp(status, "error") != 0) {
        char *chl = strdup(json_object_get_string(json_object_object_get(obj, "channel")));
        long int cid;
        if (strcmp(chl, LOCAL_CHANNEL) == 0) {
            channel = get_local_channel_name();
        } else if (strcmp(chl, JING_TOP_CHANNEL) == 0) {
            channel = JING_TOP_CHANNEL_NAME;
        } else if (strcmp(chl, JING_PSN_CHANNEL) == 0) {
            channel = JING_PSN_CHANNEL_NAME;
        } else {
            // determining if it is an integer number
            char *address;
            cid = strtol(chl, &address, 10);
            if (*address == '\0') {
                // this is valid number
                // loop through the array to get the correct name for the channel
                int i;
                for (i=0; i<channels_len; i++) {
                    if (channels[i].id == cid) {
                        channel = channels[i].name;
                        break;
                    }
                }
                if (channel[0] == '\0') {
                    channel = "未知兆赫";
                }
            } else {
                channel = chl;
            }
        }
        sprintf(kbps, "%d", json_object_get_int(json_object_object_get(obj, "kbps")));
        if (strcmp(status, "stop") != 0) {
            time_str(json_object_get_int(json_object_object_get(obj, "pos")), pos);
            time_str(json_object_get_int(json_object_object_get(obj, "len")), len);
            like = json_object_get_int(json_object_object_get(obj, "like")) ? "1" : "0";
            artist = strdup(json_object_get_string(json_object_object_get(obj, "artist")));
            title = strdup(json_object_get_string(json_object_object_get(obj, "title")));
            album = strdup(json_object_get_string(json_object_object_get(obj, "album")));
            sprintf(year, "%d", json_object_get_int(json_object_object_get(obj, "year")));
            cover = strdup(json_object_get_string(json_object_object_get(obj, "cover")));
            douban_url = strdup(json_object_get_string(json_object_object_get(obj, "url")));
        }
    }

    if (output_format[0] == '\0') {
        if (strcmp(status, "error") == 0) {
            if (obj)
                printf("%s\n", json_object_get_string(json_object_object_get(obj, "message")));
            else
                printf("Unkown error with buf content %s\n", output_buf);
        } else if (open_webpage) {
            // open the designated webpage
            char sh[1280];
            // the url can become rather long after escaping
            char url[1024];
            if (escapesh(url, douban_url)[0] == '\0') {
                // we need to make a custom url to open
                sprintf(url, "%s %s", artist, album);
                // first obtain a curl instance to escape the query
                CURL *curl = curl_easy_init();
                char *st = curl_easy_escape(curl, url, 0);
                sprintf(url, "https://music.douban.com/subject_search?search_text=%s&cat=1003", st);
                curl_free(st);
                curl_easy_cleanup(curl);
            }
            /* printf("url is %s\n", url); */
            sprintf(sh, "%s $'%s' &", "$BROWSER", url);
            /* printf("cmd is %s\n", sh); */
            system(sh);
        } else {
            printf("RPD %s - %s / %s kbps\n", strcmp(status, "play") == 0? "Playing": (strcmp(status, "pause") == 0? "Paused": "Stopped"), channel, kbps);

            if (strcmp(status, "stop") != 0) {
                printf("%s%s - %s\n%s / %s\n", 
                        like[0] == '1' ? "[Like] ": "", artist, title, 
                        pos, len);
            }
        }
    } else {
        char info[1024], *arg = "";
        int l = strlen(output_format) + 1;
        // we must print out the information the user wants
        // trim the space in front 
        int i = 1, pi = 0;
        while ( i < l) {
            char ch = output_format[i++];
            if (i < l - 1 && ch == '%') {
                char spec = output_format[i++];
                switch (spec) {
                    case 'a': arg = artist; break;
                    case 't': arg = title; break;
                    case 'b': arg = album; break;
                    case 'y': arg = year; break;
                    case 'i': arg = cover; break;
                    case 'd': arg = douban_url; break;
                    case 'c': arg = channel; break;
                    case 'p': arg = pos; break;
                    case 'l': arg = len; break;
                    case 'u': arg = status; break;
                    case 'k': arg = kbps; break;
                    case 'r': arg = like; break;
                    case '%': arg = "%%"; break;
                    default: 
                        printf("Unknown specifier %c. Try help\n", spec);
                        return 1;
                }
                // loop through the arg and copy the chars
                while (*arg != '\0') {
                    info[pi++] = *arg;
                    arg++;
                }
            } else 
                info[pi++] = ch;
        }
        printf(info);
    }
    json_object_put(obj);
    // free the channel list
    free_channels(channels, channels_len);

    return 0;
}
Ejemplo n.º 18
0
char *channels_start(Function *global_funcs)
{
  global = global_funcs;

  gfld_chan_thr = 10;
  gfld_chan_time = 60;
  gfld_deop_thr = 3;
  gfld_deop_time = 10;
  gfld_kick_thr = 3;
  gfld_kick_time = 10;
  gfld_join_thr = 5;
  gfld_join_time = 60;
  gfld_ctcp_thr = 5;
  gfld_ctcp_time = 60;
  global_idle_kick = 0;
  global_aop_min = 5;
  global_aop_max = 30;
  allow_ps = 0;
  lastdeletedmask = 0;
  use_info = 1;
  strcpy(chanfile, "chanfile");
  chan_hack = 0;
  quiet_save = 0;
  strcpy(glob_chanmode, "nt");
  udef = NULL;
  global_stopnethack_mode = 0;
  global_revenge_mode = 0;
  global_ban_type = 3;
  global_ban_time = 120;
  global_exempt_time = 60;
  global_invite_time = 60;
  strcpy(glob_chanset,
         "-enforcebans "
         "+dynamicbans "
         "+userbans "
         "-autoop "
         "-bitch "
         "+greet "
         "+protectops "
         "+statuslog "
         "-revenge "
         "-secret "
         "-autovoice "
         "+cycle "
         "+dontkickops "
         "-inactive "
         "-protectfriends "
         "+shared "
         "-seen "
         "+userexempts "
         "+dynamicexempts "
         "+userinvites "
         "+dynamicinvites "
         "-revengebot "
         "-protecthalfops "
         "-autohalfop "
         "-nodesynch "
         "-static ");
  module_register(MODULE_NAME, channels_table, 1, 1);
  if (!module_depend(MODULE_NAME, "eggdrop", 106, 20)) {
    module_undepend(MODULE_NAME);
    return "This module requires Eggdrop 1.6.20 or later.";
  }
  add_hook(HOOK_MINUTELY, (Function) check_expired_bans);
  add_hook(HOOK_MINUTELY, (Function) check_expired_exempts);
  add_hook(HOOK_MINUTELY, (Function) check_expired_invites);
  add_hook(HOOK_USERFILE, (Function) channels_writeuserfile);
  add_hook(HOOK_BACKUP, (Function) backup_chanfile);
  add_hook(HOOK_REHASH, (Function) channels_rehash);
  add_hook(HOOK_PRE_REHASH, (Function) channels_prerehash);
  Tcl_TraceVar(interp, "global-chanset",
               TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
               traced_globchanset, NULL);
  add_builtins(H_chon, my_chon);
  add_builtins(H_dcc, C_dcc_irc);
  add_tcl_commands(channels_cmds);
  add_tcl_strings(my_tcl_strings);
  add_help_reference("channels.help");
  add_help_reference("chaninfo.help");
  my_tcl_ints[0].val = &share_greet;
  add_tcl_ints(my_tcl_ints);
  add_tcl_coups(mychan_tcl_coups);
  read_channels(0, 1);
  return NULL;
}