Exemplo n.º 1
0
int main(int argc, char** argv){
   argc = argc;
   if(argc>1)
      for(int count = 1; count < argc; count ++){
         getinfo(argv[count]);
      }
   else
      getinfo(".");

   return EXIT_STATUS;
}
static void do_command (int sock, char* func, char*args[], int num_args)
{
	char response[100];

	q_lib_init ();

	qb_log (LOG_INFO,"RPC:%s() called.", func);

	if (strcmp ("votequorum_getinfo", func) == 0) {
		getinfo (sock);
	} else if (strcmp ("votequorum_setvotes", func) == 0) {
		setvotes (sock, args[0]);
	} else if (strcmp ("votequorum_setexpected", func) == 0) {
		setexpected (sock, args[0]);
	} else if (strcmp ("quorum_getquorate", func) == 0) {
		getquorate (sock);
	} else if (strcmp ("context_test", func) == 0) {
		context_test (sock);
	} else if (strcmp ("are_you_ok_dude", func) == 0 ||
	           strcmp ("init", func) == 0) {
		snprintf (response, 100, "%s", OK_STR);
		send (sock, response, strlen (response) + 1, 0);
	} else {
		qb_log (LOG_ERR,"%s RPC:%s not supported!", __func__, func);
		snprintf (response, 100, "%s", NOT_SUPPORTED_STR);
		send (sock, response, strlen (response), 0);
	}
}
Exemplo n.º 3
0
int
initsyscall(void)
{
    static char name[] = "name";

    hertz = stathz ? stathz : hz;

    syscall_order(name);

    /* drvinit gets number of cpus! */
    drvinit(1);

    counts_mib_len = __arraycount(counts_mib);
    if (sysctlnametomib("kern.syscalls.counts", counts_mib,
                        &counts_mib_len))
        counts_mib_len = 0;

    times_mib_len = __arraycount(times_mib);
    if (sysctlnametomib("kern.syscalls.times", times_mib, &times_mib_len))
        times_mib_len = 0;

    getinfo(&s2, SHOW_COUNTS | SHOW_TIMES);
    s1 = s2;

    return(1);
}
Exemplo n.º 4
0
static void curl_thread_done(uv_work_t *w, int _) {
	luv_curl_t *lc = (luv_curl_t *)w->data;
	lua_State *L = lc->L;

	free(w);

	if (lc->stat == DOWNLOADING)
		lc->stat = DONE;

	// 1
	if (lc->curl_ret == 0 && lc->retsb) {
		strbuf_append_char(lc->retsb, 0);
		lua_pushstring(L, lc->retsb->buf);
	} else 
		lua_pushnil(L);

	if (lc->retfp)
		fclose(lc->retfp);

	// 2
	getinfo(lc);
	push_curl_stat(lc);

	lua_do_global_callback(lc->L, "curl_done", lc->c, 2, 1);
	lua_do_global_callback(lc->L, "curl_cancel", lc->c, 0, 0);

	curl_easy_cleanup(lc->c);
	if (lc->retsb)
		strbuf_free(lc->retsb);
	if (lc->retfname)
		free(lc->retfname);
}
Exemplo n.º 5
0
LUALIB_API int lua_getClient(lua_State *L)
{
    int cn = luaL_checknumber(L, 1);
    clientinfo *ci = getinfo(cn);

    if(!ci)
    {
        luaL_argerror(L, 1, "Invalid client number.");
        return 0;
    }

    ::server::lua::clientReference *ref;
    if(!ci->ref)
    {
        ref = (::server::lua::clientReference *)lua_newuserdata(L, sizeof(::server::lua::clientReference));
        ref->ci = ci;
        ref->L = L;

        luaL_getmetatable(L, LUA_SERVER_CLIENT_MT);
        lua_setmetatable(L, -2);

        lua_newtable(L);
        lua_setfenv(L, -2);

        ref->r = luaL_ref(L, LUA_REGISTRYINDEX);
    }

    lua_rawgeti(L, LUA_REGISTRYINDEX, ref->r);
    ::lua::Environment(L).dump();

    return 1;
}
Exemplo n.º 6
0
/* set or get wcs units (degrees or sexigesimal) */
char *wcsunits(int n, char *s){
  Info info = getinfo(n);
  char *str = NULL;
  if( info->wcs ){
    str = info->str;
    *str = '\0';
    if( s && *s ){
      if( !strcasecmp(s, "degrees") ){
	setwcsdeg(info->wcs, WCS_DEGREES);
	info->wcsunits = WCS_DEGREES;
      } else {
	setwcsdeg(info->wcs, WCS_SEXAGESIMAL);
	info->wcsunits = WCS_SEXAGESIMAL;
      }
    }
    switch(info->wcsunits){
    case WCS_DEGREES:
      strncpy(str, "degrees", SZ_LINE-1);
    break;
    case WCS_SEXAGESIMAL:
      strncpy(str, "sexagesimal", SZ_LINE-1);
    break;
    }
    culc(str);
  }
  return str;
}
Exemplo n.º 7
0
curlhttpget::curlhttpget(const char *url, curlhttpget_iface *iface, curlhttpget_info_t *info)
  : curl_handle(curl_easy_init())
  , m_iface(iface)
{
  curl_easy_setopt(curl_handle, CURLOPT_URL, url);
//curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1L);
  curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
  curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libdvbtee");

  if (m_iface) {
    curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, this);
    curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data);
  }

  CURLcode res = curl_easy_perform(curl_handle);
  if (res != CURLE_OK) {
    fprintf(stderr, "%s: curl_easy_perform() failed: %s\nURL: %s\n\n", __func__, curl_easy_strerror(res), url);
    goto fail;
  }

  if (info) getinfo(info);

fail:
  curl_easy_cleanup(curl_handle);
}
Exemplo n.º 8
0
int mtnexec_target(ARG arg)
{
  int i;
  MTNSVR *s;
  MTNSVR *tgt = NULL;
  MTNSVR *svr = getinfo(mtn);
  if(!svr){
    mtnlogger(mtn,0,"[mtnexec] error: node not found\n");
    return(-1);
  }
  for(i=0;ctx->targets[i];i++){
    for(s=svr;s;s=s->next){
      if(strcmp(s->host, ctx->targets[i]) == 0){
        tgt = pushsvr(tgt, s);
        break;
      }
    }
    if(!s){
      mtnlogger(mtn, 0, "[mtnexec] error: %s host not found\n", ctx->targets[i]);
      clrsvr(tgt);
      clrsvr(svr);
      return(-1);
    }
  }
  for(s=tgt;s;s=s->next){
    if(mtnexec_fork(cpsvr(s), arg) == -1){
      break;
    }
  }
  clrsvr(tgt);
  clrsvr(svr);
  return(s ? -1 : 0);
}
Exemplo n.º 9
0
int
initvmstat(void)
{
	static char *intrnamebuf;
	char *cp;
	int i;

	if (intrnamebuf)
		free(intrnamebuf);
	if (intrname)
		free(intrname);
	if (intrloc)
		free(intrloc);

	if (namelist[0].n_type == 0) {
		if (kvm_nlist(kd, namelist) &&
		    namelist[X_ALLEVENTS].n_type == 0) {
			nlisterr(namelist);
			return(0);
		}
	}
	hertz = stathz ? stathz : hz;
	if (!drvinit(1))
		return(0);

	/* Old style interrupt counts - deprecated */
	nintr = (namelist[X_EINTRCNT].n_value -
		namelist[X_INTRCNT].n_value) / sizeof (long);
	if (nintr) {
		intrloc = calloc(nintr, sizeof (long));
		intrname = calloc(nintr, sizeof (long));
		intrnamebuf = malloc(namelist[X_EINTRNAMES].n_value -
				     namelist[X_INTRNAMES].n_value);
		if (intrnamebuf == NULL || intrname == 0 || intrloc == 0) {
			error("Out of memory\n");
			nintr = 0;
			return(0);
		}
		NREAD(X_INTRNAMES, intrnamebuf, NVAL(X_EINTRNAMES) -
		      NVAL(X_INTRNAMES));
		for (cp = intrnamebuf, i = 0; i < nintr; i++) {
			intrname[i] = cp;
			cp += strlen(cp) + 1;
		}
	}

	/* event counter interrupt counts */
	get_interrupt_events();

	nextintsrow = INTSROW + 1;
	allocinfo(&s);
	allocinfo(&s1);
	allocinfo(&s2);
	allocinfo(&z);

	getinfo(&s2);
	copyinfo(&s2, &s1);
	return(1);
}
Exemplo n.º 10
0
int main()
{
	struct namect person;

	person = getinfo();
	person = makeinfo(person);
	showinfo(person);
	return 0;
}
Exemplo n.º 11
0
static int curl_stat(lua_State *L) {
	luv_curl_t *lc = (luv_curl_t *)lua_touserdata(L, lua_upvalueindex(1));

	if (lc->stat == DOWNLOADING)
		getinfo(lc);
	push_curl_stat(lc);

	return 1;
}
Exemplo n.º 12
0
int main(void){

	struct namect person;

	person=getinfo();
	person=makeinfo(person);//person======
	showinfo(person);
	return 0;
}
Exemplo n.º 13
0
void
fetchsyscall(void)
{
    time_t now;

    time(&now);
    strlcpy(buf, ctime(&now), sizeof(buf));
    buf[19] = '\0';
    getinfo(&s, show);
}
Exemplo n.º 14
0
int main(void)
{
    struct namect person;

    getinfo(&person);
    makeinfo(&person);
    showinfo(&person);
    cleanup(&person);

    double area = rect_area( &(struct rect) {10.5, 20.0});
Exemplo n.º 15
0
void
fetchvmstat(void)
{
	time_t now;

	time(&now);
	strlcpy(buf, ctime(&now), sizeof(buf));
	buf[19] = '\0';
	getinfo(&s);
}
Exemplo n.º 16
0
Arquivo: names1.c Projeto: jnksu/CPP
int main(int argc, char ** argv)
{
	struct namect person;
	
	getinfo(&person);
	makeinfo(&person);
	showinfo(&person);
	
	exit(EXIT_SUCCESS);
}
Exemplo n.º 17
0
int main(){
  struct namect person;

  getinfo(&person);
  makeinfo(&person);
  showinfo(&person);
  cleanup(&person);

  return 0;
}
Exemplo n.º 18
0
int
_ajax_sesinit()
{
	capability owner;	/* Current owner; may be session svr private */
	capability self;	/* This process */
	capability *session;	/* Most specific session svr cap */
	capability *tty;	/* TTY (stdin) */
	int pid;		/* Process ID if known */
	int err;
	
	MU_LOCK(&mu);
	if (!_ajax_sesinited) {
		session = getcap("_SESSION");
		if (session == NULL) {
			MU_UNLOCK(&mu);
			_ajax_puts(
				"Ajax (init): can't find _SESSION in cap env");
			ERR(EIO, "sesinit: no _SESSION in cap env");
		}
		if (_ajax_getowner(&owner) != 0) {
			MU_UNLOCK(&mu);
			return -1; /* Can't find owner capability */
		}
		if (getinfo(&self, NILPD, 0) < 0) {
			MU_UNLOCK(&mu);
			ERR(EIO, "sesinit: getinfo failed");
		}
		if (PORTCMP(&owner.cap_port, &session->cap_port)) {
			/* Session svr already owns us */
			session = &owner;
			pid = prv_number(&owner.cap_priv);
		}
		else {
			/* Owner is not the session svr */
			pid = 0;
		}
		if ((err = ses_init(session, &self, &_ajax_session)) < 0) {
			MU_UNLOCK(&mu);
			_ajax_putnum("Ajax (init): session init failed, error",
									err);
			ERR(EIO, "sesinit: ses_init failed");
		}
		if (pid == 0) {
			/* Arrange for tty interrupts to go to the
			 * session server.
			 */
			if ((tty = getcap("TTY")) != NULL) {
				(void) ttq_intcap(tty, &_ajax_session);
			}
		}
		_ajax_sesinited = 1;
	}
	MU_UNLOCK(&mu);
	return 0;
}
Exemplo n.º 19
0
/* convert pixels to wcs and return string */
char *pix2wcsstr(int n, double xpix, double ypix){
  Info info = getinfo(n);
  char *str = NULL;
  if( info->wcs ){
    str = info->str;
    *str = '\0';
    // convert from 1-indexed image coords
    pix2wcst(info->wcs, xpix-1, ypix-1, str, SZ_LINE);
  }
  return str;
}
Exemplo n.º 20
0
int mtnfile_info()
{
  MTNSVR *s;
  uint32_t node  = 0;
  uint64_t msize = 0;
  uint64_t mfree = 0;
  uint64_t dsize = 0;
  uint64_t dfree = 0;
  uint32_t cpu_num = 0;
  for(s=getinfo();s;s=s->next){
    node++;
    cpu_num += s->cnt.cpu;
    msize += s->memsize/1024/1024;
    mfree += s->memfree/1024/1024;
    dsize  = s->dsize/1024/1024;
    dfree  = s->dfree/1024/1024;
    printf("%5s: ",       s->host);
    printf("ORD=%03d ",   s->order);
    printf("CPU=%02d ",   s->cnt.cpu);
    printf("LA=%d.%02d ", s->loadavg / 100, s->loadavg % 100);
    printf("MS=%luM ",    s->memsize/1024/1024);
    printf("MF=%luM ",    s->memfree/1024/1024);
    printf("DF=%luG",     dfree/1024);
    printf("(%02lu%%) ",  dfree * 100 / dsize);
    printf("PS=%d ",      s->cnt.prc);
    printf("VSZ=%luK ",   s->vsz/1024);
    printf("RES=%luK ",   s->res/1024);
    printf("MLC=%d ",     s->cnt.mem);
    printf("TSK=%d ",     s->cnt.tsk);
    printf("TSV=%d ",     s->cnt.tsv);
    printf("SVR=%d ",     s->cnt.svr);
    printf("DIR=%d ",     s->cnt.dir);
    printf("STA=%d ",     s->cnt.sta);
    printf("STR=%d ",     s->cnt.str);
    printf("ARG=%d ",     s->cnt.arg);
    printf("CLD=%d ",     s->cnt.cld);
    if(s->flags & MTNMODE_RDONLY){
      printf("RDONLY ");
    }
    printf("\n");
  }
  if(!node){
    printf("node not found");
  }else{
    printf("TOTAL: ");
    printf("%dCPU(%dnode) ", cpu_num, node);
    if(msize){
      printf("MEM=%luM/%luM(%lu%%Free) ",  mfree, msize, mfree * 100 / msize);
    }
  }
  printf("\n");
  return(0);
}
Exemplo n.º 21
0
int
initvmstat(void)
{
	field_view *v;
	int mib[4], i;
	size_t size;

	hertz = stathz;
	if (!dkinit(1))
		return(0);

	mib[0] = CTL_KERN;
	mib[1] = KERN_INTRCNT;
	mib[2] = KERN_INTRCNT_NUM;
	size = sizeof(nintr);
	if (sysctl(mib, 3, &nintr, &size, NULL, 0) < 0)
		return (-1);

	intrloc = calloc(nintr, sizeof(long));
	intrname = calloc(nintr, sizeof(char *));

	for (i = 0; i < nintr; i++) {
		char name[128];

		mib[0] = CTL_KERN;
		mib[1] = KERN_INTRCNT;
		mib[2] = KERN_INTRCNT_NAME;
		mib[3] = i;
		size = sizeof(name);
		if (sysctl(mib, 4, name, &size, NULL, 0) < 0)
			return (-1);

		intrname[i] = strdup(name);
		if (intrname[i] == NULL)
			return (-1);
	}

	nextintsrow = INTSROW + 2;
	allocinfo(&s);
	allocinfo(&s1);
	allocinfo(&s2);
	allocinfo(&s3);
	allocinfo(&z);

	getinfo(&s2);
	copyinfo(&z, &s1);

	for (v = views_vm; v->name != NULL; v++)
		add_view(v);

	return(1);
}
Exemplo n.º 22
0
void main(int argc, char *argv[]) {
	int n,i;

	getmem();
	getinfo();
	printf("  PROG1:  SYS=%02Xh, MEM=%08Xh\n",
		SysType, Mem.FreeLinearSpaceInPages);

	for(i=0; i<3; i++) n=spawnl(P_WAIT, "prog2.exe", "prog2.exe", 0);

	getmem();
	printf("  PROG1:  RET=%lXh, MEM=%08Xh\n",
		n, Mem.FreeLinearSpaceInPages);
	exit(0x55);
}
Exemplo n.º 23
0
/* convert pixels to wcs and return string */
char *wcs2pixstr(int n, double ra, double dec){
  Info info = getinfo(n);
  char str[SZ_LINE];
  double xpix, ypix;
  int offscale;
  if( info->wcs ){
    wcs2pix(info->wcs, ra, dec, &xpix, &ypix, &offscale);
    // convert to 1-indexed image coords
    snprintf(str, SZ_LINE-1, "%.3f %.3f", xpix+1, ypix+1);
    nowhite(str, info->str);
    return info->str;
  } else {
    return NULL;
  }
}
Exemplo n.º 24
0
void
fetchkre(void)
{
	time_t now;
	struct tm *tp;
	static int d_first = -1;

	if (d_first < 0)
		d_first = (*nl_langinfo(D_MD_ORDER) == 'd');

	time(&now);
	tp = localtime(&now);
	(void) strftime(buf, sizeof(buf),
			d_first ? "%e %b %R" : "%b %e %R", tp);
	getinfo(&s);
}
Exemplo n.º 25
0
int
getpagesize()
{
#ifdef PAGESIZE
	return PAGESIZE;
#else
	capability self;
	int clickshift, first, last;
	
	if (getinfo(&self, NILPD, 0) < 0)
		ERR(EIO, "getpagesize: getinfo failed");
	if (getdef(&self, &clickshift, &first, &last) < 0)
		ERR(EIO, "getpagesize: getdef failed");
	return 1<<clickshift;
#endif
}
Exemplo n.º 26
0
int mtnexec_all(ARG arg)
{
  MTNSVR *s;
  MTNSVR *svr = getinfo(mtn);
  if(!svr){
    mtnlogger(mtn,0,"[mtnexec] error: node not found\n");
    return(-1);
  }
  for(s=svr;s;s=s->next){
    if(mtnexec_fork(cpsvr(s), arg) == -1){
      break;
    }
  }
  clrsvr(svr);
  return(s ? -1 : 0);
}
Exemplo n.º 27
0
void Game:: turn ()
{
	char str [10] = "turn";

	q.sendstr (str);

	waitendturn ();


	// new month
	readqueue ();
	getinfo ();
	if ( active_players () >= 2 ) {
		market ();
	}
}
Exemplo n.º 28
0
/* 主函数 */
int main(int argc, char *argv[])
{
	FILE *pf;
	char line_buf[100];
	int s, E, b, flag;
	char trace_name[100];
	int state;
	simu_cache cache;
	flag = 0;	
	getinfo(argc, argv, &s, &E, &b, trace_name, &flag);
	initCache(&cache, s, E);
	pf = fopen(trace_name, "r");
	if (!pf) {
		printf("Error: Cann't open file %s!\n", trace_name);
		return -1;
	}
	while (NULL != fgets(line_buf, 100, pf)) {
		if (' ' == line_buf[0]) {
			line_buf[strlen(line_buf)-1] = '\0';
			state = parse_traces(&cache, line_buf, s, E, b, flag);
			if (1 == flag) {
				switch (state) {
				case HIT:
					printf("%s hit\n", line_buf+1);
					break;
				case MISS:
					printf("%s miss\n", line_buf+1);
					break;
				case MISS_AND_HIT:
					printf("%s miss hit\n", line_buf+1);
					break;
				case MISS_AND_EVICTION:
					printf("%s miss eviction\n", line_buf+1);
					break;
				case MISS_EVICTION_AND_HIT:
					printf("%s miss eviction hit\n", line_buf+1);
					break;
				default:
					break;
				}
			}
		}
	}
	fclose(pf);
	printSummary(hits, misses, evictions);
	return 0;
}
Exemplo n.º 29
0
int	recursive(char *s)
{
	DIR *stream;
	struct dirent *dir;
	t_lst *lst;
	t_maxlen *i;
	int a;

	a = 1;

	i = malloc(sizeof(t_maxlen));

	stream = opendir(s);
	//perror("open main");
	if(!(lst = getinfo(s)))
		return (0);
	printf("%s :\n", s);
	ct_all(lst->next, &i);
	sortbytime(&lst, 1);
	printlist(lst->next, *i, a);
	lstdel(lst);

	if (!stream)
	{
		printf("error exit ---------------------\n") ;
		   	return (0);
	}
	while ((dir = readdir(stream)))
	{
		if (dir->d_type == DT_DIR)
		{
		   if (ft_strcmp(dir->d_name, ".") != 0 && ft_strcmp(dir->d_name, "..") != 0)
		   {
				printf("\n");
				recursive(getpath(s,dir->d_name));
		   }
		}
	}
		closedir(stream);
	return (0);
}
Exemplo n.º 30
0
int  main( int argc, char *argv[])
{
  if(argc != 6){
    printf(" \n  get_info -- statistics header information\n\n");
    printf("  Usage:\n\n  get_info  [infile] [infofile] [key] \n\n");
    printf("  Parameters: \n");
    printf("  infile  :  inputfile in SU format\n");
    printf("  infofile:  file to store statistics information\n");
    printf("  coodfile:  file to store the coordinates\n");
    printf("  dir     :   working directory\n");
    printf("  key=fldr/ep/cdp/sx    keyword describing the gathers\n\n");
    return 0;
  }
  printf("input file is %s\n",argv[1]);
  printf("info file  is %s\n",argv[2]);
  printf("coord file is %s\n",argv[3]);
  printf("dir        is %s\n",argv[4]);
  printf("keyword    is %s\n",argv[5]);
  getinfo(argv[1],argv[2],argv[3],argv[4],argv[5]);
  return 0;
}