示例#1
0
/************** syscall routing table ***********/
int kcinth() 
{
  u16 x, y, z, w, r; 
  u16 seg, off;

  seg = running->uss; off = running->usp;

  x = get_word(seg, off+13*2);
  y = get_word(seg, off+14*2);
  z = get_word(seg, off+15*2);
  w = get_word(seg, off+16*2);
  
   switch(x){
       case 0 : r = running->pid;    break;
       case 1 : r = kps();           break;
       case 2 : r = chname(y);       break;
       case 3 : r = kmode();         break;
       case 4 : r = tswitch();       break;
       case 5 : r = kwait();         break;
       case 6 : r = kexit();         break;
       case 7 : r = fork();          break;
       case 8 : r = kexec(y);        break;

       case 9 : r = sout(y); break;
       case 10: r = sin(y); break;

       case 99: r = kexit();                break;

       default: printf("invalid syscall # : %d\n", x);

   }
   put_word(r, seg, off+2*8);
}
示例#2
0
文件: u1.c 项目: B-Rich/CptS460
main()
{ 
  char name[64]; int cmd;
  /* resetVideo();*/
  while(1){
       pid = get_pid();
       printf("==============================================\n");
       printf("I am task %d in Umode at segment=%x\n", pid, getcs());

       show_menu();
       printf("Command ? ");
       mgets(name); 
       if (name[0]==0) 
           continue;

       cmd = find_cmd(name);
       switch(cmd){
           case 0 : get_pid();  break;
           case 1 : ps();       break;
           case 2 : chname();   break;
           case 3 : kmode();    break;
           case 4 : kswitch();  break;
           case 5 : mywait();   break;
           case 6 : myexit();   break;
           case 7 : ufork();    break;
           case 8 : myexec("/u2");  break;
           case 9 : sin();      break;
           case 10 : sout();    break;
           default: invalid(name); break;
       }
  }
}
示例#3
0
main()
{ 
  char name[64]; int cmd;
  int pid;
  while(1){
       pid = getpid();
       printf("==============================================\n");
       printf("Das ist prozess %d im Umode segment=%x\n", pid, getcs());
       show_menu();
       printf("Command ? ");
       gets(name); 
       if (name[0]==0) 
           continue;

       cmd = find_cmd(name);
       switch(cmd){
           case 0 : getpid();  break;
           case 1 : ps();       break;
           case 2 : chname();   break;
           case 3 : kmode();    break;
           case 4 : kswitch();  break;
           case 5 : mywait();   break;
           case 6 : myexit();   break;
           case 7 : ufork();    break;
           case 8 : myexec("/bin/u1"); break; 
           case 9 : sin(); break;
           case 10: sout(); break;
          default: invalid(name); break;
       }
  }
}
示例#4
0
文件: u1.c 项目: thomdabeast/CS460-1
main(int argc, char *argv[])
{
  char name[64]; int pid, cmd, segment, i;

  while(1){
       pid = getpid();
       color = 0x000B + (pid % 5);
       segment = (pid+1)*0x1000;
       printf("==============================================\n");
       printf("I am proc %din U mode: segment=%x\n", pid, segment);
       show_menu();
       printf("Command ? ");
       gets(name);
       if (name[0]==0)
           continue;

       cmd = find_cmd(name);

       switch(cmd){
           case 0 : getpid();   break;
           case 1 : ps();       break;
           case 2 : chname();   break;
           case 3 : kmode();    break;
           case 4 : kswitch();  break;
           case 5 : wait();     break;

           case 6 : exit();     break;
           case 7 : fork();     break;
           case 8 : exec();     break;
           case 9 : do_itimer(); break;

           default: invalid(name); break;
       }
  }
}
示例#5
0
main()
{ 
  char name[64]; int pid, cmd;
color = 0x0F;
  while(1){
    printf("----------------------------------------------\n");
    pid = getpid();
    
     printf("I am proc %d in U mode: running segment=%x\n", pid, getcs());
    show_menu();
    printf("Command ? ");

    gets(name); 
    if (name[0]==0) 
        continue;

    cmd = find_cmd(name);
    switch(cmd){
           case 0 : getpid();   break;
           case 1 : ps();       break;
           case 2 : chname();   break;
           case 3 : pid = kfork();   
           printf("fork returned: %d\n", pid);
            break;
           case 4 : kswitch();  break;
           case 5 : wait();     break;
           case 6 : exit();     break;
           case 7 : pid = exec();   
           printf("exec returned: %d\n", pid);  break;

           default: invalid(name); break;
    }
  }
}
示例#6
0
文件: u1.c 项目: dabbers/dabos
main()
{ 
  char name[64]; int pid, cmd;

  while(1){
    pid = getpid();
    color = 0x000A + (pid % 6);
       
    printf("----------------------------------------------\n");
    printf("I am proc %d in U mode: running segment=%x\n",getpid(), getcs());
    show_menu();
    printf("Command ? ");
    gets(name); 
    if (name[0]==0) 
        continue;

    cmd = find_cmd(name);
    switch(cmd){
           case 0 : getpid();   break;
           case 1 : ps();       break;
           case 2 : chname();   break;
           case 3 : kmode();    break;
           case 4 : kswitch();  break;
           case 5 : wait();     break;
           case 6 : exit();     break;

           default: invalid(name); break;
    }
  }
}
示例#7
0
main()
{ 
  char name[64]; int pid, cmd;
  char c;

  while(1){
    
    color = 0x0C;
       
    printf("----------------------------------------------\n");
    pid = getpid();
    printf("I am proc %d in U mode: running segment=%x\n", pid, getcs());
    show_menu();
    printf("Command ? ");
    gets(name); 
    if (name[0]==0) 
        continue;

    cmd = find_cmd(name);
    switch(cmd){
           case 0 : getpid();   break;
           case 1 : ps();       break;
           case 2 : chname();   break;
           case 3 : kfork();    break;
           case 4 : kswitch();  break;
           case 5 : wait();     break;
           case 6 : exit();     break;
           case 7 : c = kgetc();  putc(c); putc('\n'); putc('\r'); break;
           case 8 : kputc();    break;

           default: invalid(name); break;
    }
  }
}
示例#8
0
文件: Worker.cpp 项目: luozy/fooking
void Worker::doChannelDel(RouterMsg *pMsg)
{
	//频道名称在data域
	int pos = 0;
	std::string chname(pMsg->data + pMsg->slen, pMsg->len);
	ConnectionSet &clients = arrChannels[chname];
	while(pos + SID_LENGTH <= pMsg->slen)
	{
		std::string sid(pMsg->data + pos, SID_LENGTH);
		ClientList::const_iterator it = arrClients.find(sid);
		if(it != arrClients.end()){
			Connection *pClient = it->second;
			ClientData *pClientData = (ClientData*)pClient->getData();
			pClientData->channels.erase(chname);
			
			clients.erase(pClient);
			if(!clients.size()){
				sendToRouter(ROUTER_MSG_CH_UNSUB, chname.size(), chname.c_str(), 0, NULL);
			}
			
			LOG("leave channel name=%s, sid=%s", chname.c_str(), sid.c_str());
		}
		
		pos+= SID_LENGTH;
	}
}
示例#9
0
文件: int.c 项目: bhanderson/cpts460
/****************** syscall handler in C ***************************/
int kcinth(){
	u16    segment, offset;
	int    a,b,c,d, r;
	segment = running->uss;
	offset = running->usp;

	/** get syscall parameters from ustack **/
	a = get_word(segment, offset + 2*PA);
	b = get_word(segment, offset + 2*PB);
	c = get_word(segment, offset + 2*PC);
	d = get_word(segment, offset + 2*PD);

	//printf("proc%d syscall a=%d b=%d c=%d d=%d\n", running->pid, a,b,c,d);

	switch(a){
		case 0 : r = running->pid;     break;
		case 1 : r = do_ps();          break;
		case 2 : r = chname(b);        break;
		case 3 : r = kmode();          break;
		case 4 : r = tswitch();        break;
		case 5 : r = do_wait(b);       break;
		case 6 : r = do_exit(b);       break;

		case 90: r =  getc();          break;
		case 91: r =  putc(b);         break;
		case 99: do_exit(b);           break;
		default: printf("invalid syscall # : %d\n", a);
	}
	put_word(r, segment, offset + 2*AX);
}
示例#10
0
文件: sym.c 项目: 99years/plan9
static void
chan_check(Symbol *sp)
{	Access *a; int i, b=0, d;

	if (verbose&1) goto report;	/* -C -g */

	for (a = sp->access; a; a = a->lnk)
		if (a->typ == 'r')
			b |= 1;
		else if (a->typ == 's')
			b |= 2;
	if (b == 3 || (sp->hidden&16))	/* balanced or formal par */
		return;
report:
	chname(sp);
	for (i = d = 0; i < (int) (sizeof(xx)/sizeof(struct X)); i++)
	{	b = 0;
		for (a = sp->access; a; a = a->lnk)
			if (a->typ == xx[i].typ) b++;
		if (b == 0) continue; d++;
		printf("\n\t%s by: ", xx[i].nm);
		for (a = sp->access; a; a = a->lnk)
		  if (a->typ == xx[i].typ)
		  {	printf("%s", a->who->name);
			if (a->what) printf(" to %s", a->what->name);
			if (a->cnt)  printf(" par %d", a->cnt);
			if (--b > 0) printf(", ");
		  }
	}
	printf("%s\n", (!d)?"\n\tnever used under this name":"");
}
示例#11
0
void
dbgmsg(struct msg* msg, const char* tag)
{
    switch (msg->type) {
        case MSG_CHANNEL_DATA: {
            struct msg_channel_data* m = (void*) msg;
            dbg("%s MSG_CHANNEL_DATA ch=%s sz=%u, payloadsz=%zu",
                tag, chname(m->channel), m->msg.size, m->msg.size - sizeof (*m));
            break;
        }
        case MSG_CHANNEL_WINDOW: {
            struct msg_channel_window* m = (void*) msg;
            dbg("%s MSG_CHANNEL_WINDOW ch=%s d=%u",
                tag, chname(m->channel), m->window_delta);
            break;
        }
        case MSG_CHANNEL_CLOSE: {
            dbg("%s MSG_CHANNEL_CLOSE ch=%s",
                tag, chname(((struct msg_channel_close*)msg)->channel));
            break;
        }
        case MSG_WINDOW_SIZE: {
            struct msg_window_size* ws = (void*) msg;
            dbg("%s MSG_WINDOW_SIZE row=%u col=%u xpixel=%u ypixel=%u",
                tag, ws->ws.row, ws->ws.col, ws->ws.xpixel, ws->ws.ypixel);
            break;
        }
        case MSG_CHILD_EXIT: {
            struct msg_child_exit* m = (void*) msg;
            dbg("%s MSG_CHILD_EXIT status=%u", tag, m->exit_status);
            break;
        }
        case MSG_CHDIR: {
            struct msg_chdir* m = (void*) msg;
            dbg("%s MSG_CHDIR dir=%.*s",
                tag,
                (int) (m->msg.size - sizeof (*m)),
                m->dir);
            break;
        }
        default: {
            dbg("%s MSG_??? type=%d sz=%d", tag, msg->type, msg->size);
            break;
        }
    }
}
示例#12
0
文件: u1.c 项目: vternal3/OSkernal
main(int argc, char *argv[])
{ 
    int pid, cmd, i;
    char name[64];
    ucolor = 0;
    clearScreen(UMODE);
    printf("enter main() : argc = %d\n", argc);
    for (i=0; i<argc; i++)
        printf("argv[%d] = %s\n", i, argv[i]);

    while(1){
        pid = getpid();
        color = ucolor ? ucolor:0x000B + (pid % 5);// avoid black on black baground
        cmd?resetCursor(UMODE):1;
        printf("----------------------------------------------\n");
        printf("I am proc %din U mode: segment=%x\n", pid, (pid+1)*0x1000);
        show_menu();
        printf("Command ? ");
        getCurPos(UMODE);
        printf("                                                                      \n");
        setCurPos(ux_col,uy_row,UMODE);
        gets(name);
        clearScreenRegion(K_X_PRINT_OFFSET,80,U_Y_PRINT_OFFSET-1,24,UMODE);
        if (name[0]==0) 
            continue;

        cmd = find_cmd(name);
        
        getCurPos(UMODE);
        setCurPos(K_X_PRINT_OFFSET,U_Y_PRINT_OFFSET,UMODE);
        switch(cmd){
            case 0 : do_getpid();   break;
            case 1 : ps();          break;
            case 2 : chname();      break;
            case 3 : kmode();       break;
            case 4 : kswitch();     break;
            case 5 : wait();        break;
            case 6 : exit();        break;
            case 7 : fork();        break;
            case 8 : exec();        break;
            case 9 : ucolor = chcolor();     break;

            case 10: pipe();        break;
            case 11: pfd();         break;
            case 12: read_pipe();   break;
            case 13: write_pipe();  break;
            case 14: close_pipe();  break;
            
            default: invalid(name); break;
        }
        setCurPos(ux_col,uy_row,UMODE);
    }
}
示例#13
0
void manip_ulsvolume::print(std::ostream& file, int l) const {
  if (l <= 0) return;
  char s[1000];
  chname(s);
  Ifile << "manip_ulsvolume::print(l=" << l << "): " << s << '\n';
  l = l - 1;
  if (l > 0) {
    indn.n += 2;
    // If to call this it calls manip_ulsvolume::print again and loop...
    ulsvolume::print(file, l - 1);
    indn.n -= 2;
  }
}
示例#14
0
文件: user1.c 项目: arinn1204/MyOS
int main(int argc, char *argv[]) { 
	char name[64];
	int pid, cmd;
	int pd[2];

	while(1){

		printf("\n----------------------------------------------\n");
		#ifndef _LAB_3_
			printf("I am proc %d in U mode with ppid %d: running segment=%x\n",getpid(), getppid(), getcs());
		#else
			printf("I am proc "); getpid(); printf(" in U mode: running segment=%x\n", getcs());
		#endif

		#ifdef _SLEEPER_
			while(1) {
				printf("PID: %d PPID: %d\n", getpid(), getppid());
				sleep(5);
				return 0;
			}
		#endif

		show_menu();
		printf("Command? ");
		gets(name);
		printf("\n"); 
		if (name[0]==0) 
		continue;

		cmd = find_cmd(name);
		switch(cmd){
			case 0:		getpid();	break;
			case 1:		ps();		break;
			case 2:		chname();	break;
			case 3:		kswitch();	break;
			case 4:		wait();		break;
			case 5:		ufork();	break;
			case 6:		uexec();	break;
			case 7: 	exit();		break;
			case 8: 	pipe(pd);	break;
			case 9: 	pfd();		break;
			case 10:	uclose();	break;
			case 11:	uread();	break;
			case 12:	uwrite();	break;
			case 13:	usleep();	break;
			default:invalid(name);break;
		}
	}
}
示例#15
0
void ulsvolume::print(std::ostream& file, int l) const {
  char s[1000];
  chname(s);
  Ifile << "ulsvolume::print(l=" << l << "): " << s << '\n';
  if (l > 0) {
    indn.n += 2;
    Ifile << "qsurf=" << qsurf << " prec=" << prec << '\n';
    for (int n = 0; n < qsurf; ++n) {
      Ifile << " nsurf=" << n << '\n';
      surf[n].get()->print(file, l);
    }
    absvol::print(file, l);
    indn.n -= 2;
  }
}
示例#16
0
文件: dbg.c 项目: neilalfa/fb-adb
void
dbgch(const char* label, struct channel** ch, unsigned nrch)
{
    SCOPED_RESLIST(rl_dbgch);
    unsigned chno;

    dbglock();

    dbg("DBGCH[%s]", label);

    for (chno = 0; chno < nrch; ++chno) {
        struct channel* c = ch[chno];
        struct pollfd p = channel_request_poll(ch[chno]);
        const char* pev;
        switch (p.events) {
            case POLLIN | POLLOUT:
                pev = "POLLIN,POLLOUT";
                break;
            case POLLIN:
                pev = "POLLIN";
                break;
            case POLLOUT:
                pev = "POLLOUT";
                break;
            case 0:
                pev = "NONE";
                break;
            default:
                pev = xaprintf("%xd", p.events);
                break;
        }

        assert(p.fd == -1 || p.fd == c->fdh->fd);

        dbg("  %-18s size:%-4zu room:%-4zu window:%-4d %s%-2s %p %s",
            xaprintf("ch[%d=%s]", chno, chname(chno)),
            ringbuf_size(c->rb),
            ringbuf_room(c->rb),
            c->window,
            (c->dir == CHANNEL_FROM_FD ? "<" : ">"),
            ((c->fdh != NULL)
             ? xaprintf("%d", c->fdh->fd)
             : (c->sent_eof ? "!!" : "!?")),
            c,
            pev);
    }
}
示例#17
0
文件: Worker.cpp 项目: luozy/fooking
void Worker::doChannelPub(RouterMsg *pMsg)
{
	//频道名称在session域
	std::string chname(pMsg->data, pMsg->slen);
	ChannelList::const_iterator it = arrChannels.find(chname);
	if(it == arrChannels.end()){
		return ;
	}
	
	const ConnectionSet &clients = it->second;
	ConnectionSet::const_iterator it2;
	for(it2 = clients.begin(); it2 != clients.end(); ++it2){
		Connection *pClient = it2->first;
		ClientData *pClientData = (ClientData*)pClient->getData();
		sendToClient(pClient, pMsg->data + pMsg->slen, pMsg->len);
		
		LOG("send channel msg to: %s", pClientData->session.getId());
	}
}
示例#18
0
文件: u2.c 项目: shank8/CS460
main()
{ 
  char name[64]; int pid, cmd;
  pid = getpid();

  while(1){
       color = 0x0000B + pid;

       printf("==============================================\n");
       printf("\nIch bin Prozess %d in der U Weise: das laufen im Segment=%x\n",
                getpid(), getcs());
       
       show_menu();
       printf("Command ? ");
       gets(name); 
       if (name[0]==0) 
           continue;

       cmd = find_cmd(name);
       printf("find_cmd = %d\n", cmd);
       switch(cmd){
            case 0 : getpid();   break;
           case 1 : ps();       break;
           case 2 : chname();   break;
           case 3 : kmode();    break;
           case 4 : kswitch();  break;
           case 5 : wait();     break;
           case 6 : exit();     break;
           case 7 : fork();     break;
           case 8 : exec();     break;
         
           case 9 : pipe();    break;
           case 10: pfd();       break;
          
           case 11 : read_pipe(); break;
           case 12 : write_pipe();break;
            case 13: close();     break;
           default: invalid(name); break;
       } 

  }
}
示例#19
0
文件: int.c 项目: thomdabeast/CS460-1
int kcinth()
{
   u16    segment, offset;
   int    a,b,c,d, r;

   segment = running->uss; 
   offset = running->usp;

   a = get_word(segment, offset + 2*PA);
   b = get_word(segment, offset + 2*PB);
   c = get_word(segment, offset + 2*PC);
   d = get_word(segment, offset + 2*PD);

   switch(a){
       case 0 : r = running->pid;     break;
       case 1 : r = do_ps();          break;
       case 2 : r = chname(b);        break;
       case 3 : r = kmode();          break;
       case 4 : r = tswitch();        break;
       case 5 : r = do_wait(b);       break;
       case 6 : r = do_exit(b);       break;
        
       case 7 : r = fork();           break;
       case 8 : r = exec(b);          break;

       case 9 : r = vfork();          break;


   case 30 : r = kpipe(b); break;
   case 31 : r = read_pipe(b,c,d);  break;
   case 32 : r = write_pipe(b,c,d); break;
   case 33 : r = close_pipe(b);     break;
   case 34 : r = pfd();             break;

       case 90: r =  getc();          break;
       case 91: color=running->pid+11;
                r =  putc(b);         break;       
       case 99: do_exit(b);           break;
       default: printf("invalid syscall # : %d\n", a); 
   }
   put_word(r, segment, offset + 2*AX);
}
示例#20
0
文件: u1.c 项目: thomdabeast/CS460-1
main(int argc, char *argv[])
{ 
  char name[64]; int pid, cmd, segment, i;
  pid = getpid();
  color = 0x000B + (pid % 5);  // avoid black on black baground

  printf("enter main() : argc = %d\n", argc);
  for (i=0; i<argc; i++)
    printf("argv[%d] = %s\n", i, argv[i]);
 
  while(1){
       pid = getpid();
       color = 0x000B + (pid % 5);
       segment = (pid+1)*0x1000;   
       printf("==============================================\n");
       printf("I am proc %din U mode: segment=%x\n", pid, segment);
       show_menu();
       printf("Command ? ");
       gets(name); 
       if (name[0]==0) 
           continue;

       cmd = find_cmd(name);

       switch(cmd){
           case 0 : getpid();   break;
           case 1 : ps();       break;
           case 2 : chname();   break;
           case 3 : kmode();    break;
           case 4 : kswitch();  break;
           case 5 : wait();     break;

           case 6 : exit();     break;
           case 7 : fork();     break;
           case 8 : exec();     break;

           case 9:  chcolor(); break;

           default: invalid(name); break;
       } 
  }
}
示例#21
0
文件: u1.c 项目: shank8/CS460
main()
{ 
  char name[64]; int pid, cmd;

  while(1){
    pid = getpid();
    color = 0x000B + (pid % 6);
       
    printf("----------------------------------------------\n");
    printf("I am proc %d in U mode: running segment=%x\n",getpid(), getcs());
    show_menu();
    printf("Command ? ");
    gets(name); 
    if (name[0]==0) 
        continue;

    cmd = find_cmd(name);
      printf("find_cmd = %d\n", cmd);
    /*char *cmd[]={"getpid", "ps", "chname", "kmode", "switch", "wait", "exit", 
             "fork", "exec", "pipe", "pfd", "read", "write", "close", 0};*/
    switch(cmd){
           case 0 : getpid();   break;
           case 1 : ps();       break;
           case 2 : chname();   break;
           case 3 : kmode();    break;
           case 4 : kswitch();  break;
           case 5 : wait();     break;
           case 6 : exit();     break;
           case 7 : fork();     break;
           case 8 : exec();     break;
         
           case 9 : pipe();    break;
           case 10: pfd();       break;
          
           case 11 : read_pipe(); break;
           case 12 : write_pipe();break;
            case 13: close_pipe();     break;
           default: invalid(name); break;
    }
  }
}
示例#22
0
文件: u1.c 项目: B-Rich/CptS460
main()
{ 
  char name[64]; int pid, cmd, segment, i;
  pid = getpid();
  color = 0x000B + (pid % 5);  // avoid black on black baground
 
  while(1){
       pid = getpid();
       color = 0x000B + (pid % 5);
       segment = (pid+1)*0x1000;   
       printf("==============================================\n");
       printf("I am proc %din U mode: segment=%x\n", pid, segment);
       show_menu();
       printf("Command ? ");
       gets(name); 
       if (name[0]==0) 
           continue;

       cmd = find_cmd(name);

       switch(cmd){
           case 0 : getpid();   break;
           case 1 : ps();       break;
           case 2 : chname();   break;
           case 3 : kmode();    break;
           case 4 : kswitch();  break;
           case 5 : wait();     break;
           case 6 : exit();     break;
           case 7 : fork();     break;
           case 8 : exec();     break;

       case 9:  pipe(); break;
       case 10: pfd();  break;
       case 11: read_pipe(); break;
       case 12: write_pipe(); break;
       case 13: close_pipe(); break;

           default: invalid(name); break;
       } 
  }
}
示例#23
0
文件: u2.c 项目: shank8/CS460
main()
{ 
  char name[64]; 
  int pid, cmd;


  while(1){

       printf("==============================================\n");
       printf("\nIch bin Prozess %d in der U Weise: das laufen im Segment=%x\n",
                getpid(), getcs());

       
       show_menu();
       printf("Command ? ");
       gets(name); 
       if (name[0]==0) 
           continue;

       cmd = find_cmd(name);
       switch(cmd){
           case 0 : getpid();   break;
           case 1 : ps();       break;
           case 2 : chname();   break;
           case 3 : kmode();    break;
           case 4 : kswitch();  break;
           case 5 : wait();     break;

           case 6 : die();      break;
           case 7 : ufork();     break;
           case 8 : uexec();     break;

           case 9 : chcolor();  break;

           default: invalid(name); break;
       } 
  }
}
示例#24
0
文件: int.c 项目: bhanderson/cpts460
int kcinth()
{
	ushort seg, off, r;
	int    x, y, z, w;

	seg = running->uss; off = running->usp;

	x = get_word(seg, off + 2*13);
	y = get_word(seg, off + 2*14);
	z = get_word(seg, off + 2*15);
	w = get_word(seg, off + 2*16);

	switch(x){
		case 0 : r = running->pid;		break;
		case 1 : r = do_ps();			break;
		case 2 : r = chname(y);			break;
		case 3 : r = kmode();			break;
		case 4 : r = tswitch();			break;
		case 5 : r = do_wait(y);		break;
		case 6  : r = do_exit(y);		break;

		case 7  : r = ufork();			break;
		case 8 :  r = exec(y);			break;

		case 9 : r = chcolor(y);		break;

		case 10: r = putc(y);			break;

		case 11: mysleep(y);		break;

		case 99 : do_exit(y);			break;

		default: printf("invalid syscall # : %d\n", x);
				 break;
	}
	put_word(r, seg, off + 2*8);
}
示例#25
0
int hfddsrv (int argc, char **argv, void *p)
{
	struct session spdummy, *sp = &spdummy;
	struct iface *ifp;
	struct asy *ap;
	char *ifn;

	/* 07Apr2010, Maiko, Winmor sound card tnc support */
	int notwinmor = 1;

#ifdef WINMOR
	ifp = &ifdummy;
	ifdummy.name = j2strdup ("winmor");
#endif
	/*
	 *  HFDD_PARAMS	hfddp;
	 *
	 * wonder if this getting destroyed when the client terminates is
	 * causing crashes, since a process might still be alive that expects
	 * this. Make it a static for now to see if that solves crashing !
	 */

	if (p != (void*)0)
		sp = (struct session*)p;

#ifdef WINMOR
	/* 07Apr2010, Maiko, No physical TTY for the WINMOR device */
	notwinmor = strcmp ("mor", argv[1]);
#endif

	if (notwinmor)
	{
		if (hfdd_debug)
			log (-1, "argc %d iface %s call %s", argc, argv[1], argv[2]);

    	if ((ifp = if_lookup (argv[1])) == NULLIF)
		{
        	tprintf (Badinterface, argv[1]);
        	return 1;
    	}

    	ap = &Asy[ifp->dev];
    	if (ifp->dev >= ASY_MAX || ap->iface != ifp)
		{
        	tprintf ("Interface %s not asy port\n", argv[1]);
        	return 1;
    	}

    	if (ifp->raw == bitbucket)
		{
        	tprintf ("hfdd session already active on %s\n", argv[1]);
        	return 1;
    	}

    	/* Save output handler and temporarily redirect output to null */
    	ifp->raw = bitbucket;
	}

   	/* Put tty into raw mode */
   	sp->ttystate.echo = 0;
   	sp->ttystate.edit = 0;
   	sockmode (sp->output, SOCK_BINARY);

	/*
	 * 03Jun2007, Maiko, No more keyboard mode for now. This will all be
	 * for mail forwarding only. The keyboard mode never worked very well,
	 * never got developed to it's fullest potential, and introduced some
	 * technical and logistical challenges just not worth doing (yet) !
	 */

	hfddp.keyboard = 0;	/* always from mailbox now, no keyboard user mode */

	hfddp.call = j2strdup (argv[2]);
	hfddp.iface = j2strdup (argv[1]);

	if (notwinmor)
	{
 	  /* 15Feb2005, Maiko, now using device params to configure this */
	  hfddp.pactor = (ap->flags & ASY_PACTOR);
	}
	else hfddp.pactor = 1;	/* 09Apr2010, Maiko, Automatic apparently */

	hfdd_fwdsock = -1;	/* 12Mar2005, Maiko, Make sure of this !!! */

	/*
	 * start up the keyboard handler (as of 02Feb2005, there is only
	 * only one keyboard handler now for all devices, the device specific
	 * stuff is now contained within the handler, instead of having a
	 * separate keyboard handler for each device. More standardized !
	 */
	ifn = if_name (ifp, " keybd");
	sp->proc1 = newproc (ifn, 1024, keyboard_to_hfdd, ifp->dev, sp, &hfddp, 0);
	free (ifn);

    ifn = if_name (ifp, " modem");
    chname (Curproc, ifn);
    free (ifn);

    sp->proc = Curproc;	/* important for alert */
  
    /* bring the line up (just in case) */
    if (ifp->ioctl != NULL)
        (*ifp->ioctl)(ifp, PARAM_UP, TRUE, 0L);

	if (hfdd_debug)
		log (-1, "start the modem machine");

	/*
	 * 22Jan2005, Maiko, Added 'realuser' parameter to the xxx_machine
	 * functions, so that tprintf()'s are suppressed, and the j2alarm()
	 * calls are invoked. Forwarding and having a real user at the
	 * keyboard have slightly different input/output requirements.
	 */
	if (hfdd_is_ptc (hfddp.iface))
		ptc_machine (ifp->dev, hfddp.call);
	else if (hfdd_is_dxp (hfddp.iface))
		dxp_machine (ifp->dev, &hfddp);
	/* 05Feb2007, Maiko, Switched parameters passed to function */
	else if (hfdd_is_kam (hfddp.iface))
		kam_machine (ifp->dev, &hfddp);
	/* 22Apr2008, Maiko, Now support AEA PK232 modem */
	else if (hfdd_is_pk232 (hfddp.iface))
		pk232_machine (ifp->dev, &hfddp);
#ifdef WINMOR
	/* 07Apr2010, Maiko, Support the WINMOR Sound Card modem */
	else if (hfdd_is_winmor (hfddp.iface))
		winmor_machine (ifp->dev, &hfddp);
#endif

	/* 08Feb2007, Maiko, MODEM machine will now never die !!! */

	if (hfdd_debug)
		log (-1, "left the modem machine");

	return 0;
}
示例#26
0
文件: dbg.c 项目: neilalfa/fb-adb
void
dbgmsg(const struct msg* msg, const char* tag)
{
    switch (msg->type) {
        case MSG_CHANNEL_DATA: {
            struct msg_channel_data* m = (void*) msg;
            dbg("%s %s ch=%s sz=%u payloadsz=%zu",
                tag, msgtoname(msg),
                chname(m->channel), m->msg.size, m->msg.size - sizeof (*m));
            break;
        }
        case MSG_CHANNEL_DATA_LZ4: {
            struct msg_channel_data_lz4* m = (void*) msg;
            dbg(("%s %s ch=%s sz=%u "
                 "payloadsz=%zu uncomp=%u"),
                tag, msgtoname(msg),
                chname(m->channel), m->msg.size, m->msg.size - sizeof (*m),
                (unsigned) m->uncompressed_size);
            break;
        }
        case MSG_CHANNEL_WINDOW: {
            struct msg_channel_window* m = (void*) msg;
            dbg("%s %s ch=%s d=%u",
                tag, msgtoname(msg),
                chname(m->channel), m->window_delta);
            break;
        }
        case MSG_CHANNEL_CLOSE: {
            dbg("%s %s ch=%s",
                tag, msgtoname(msg),
                chname(((struct msg_channel_close*)msg)->channel));
            break;
        }
        case MSG_WINDOW_SIZE: {
            struct msg_window_size* ws = (void*) msg;
            dbg("%s %s row=%u col=%u xpixel=%u ypixel=%u",
                tag, msgtoname(msg),
                ws->ws.row, ws->ws.col, ws->ws.xpixel, ws->ws.ypixel);
            break;
        }
        case MSG_CHILD_EXIT: {
            struct msg_child_exit* m = (void*) msg;
            dbg("%s %s status=%u", tag, msgtoname(msg), m->exit_status);
            break;
        }
        case MSG_CHDIR: {
            struct msg_chdir* m = (void*) msg;
            dbg("%s %s dir=%.*s",
                tag, msgtoname(msg),
                (int) (m->msg.size - sizeof (*m)),
                m->dir);
            break;
        }
        default: {
            dbg("%s %s type=%d sz=%d",
                tag,
                msgtoname(msg),
                msg->type, msg->size);
            break;
        }
    }
}
示例#27
0
//
// Creates NetCDF product
//
bool NetCDFProduct(MSG_header *PRO_head, MSG_data* PRO_data,
                   int totalsegs, int *segsindexes,
		   MSG_header *header, MSG_data *msgdat)
{
  struct tm *tmtime;
  char NcName[1024];
  char reftime[64];
  char projname[16];
  int wd, hg;
  int bpp;
  int ncal;
  float *cal;
  NcVar *ivar;
  NcVar *tvar;
  NcDim *tdim;
  NcDim *ldim;
  NcDim *cdim;
  NcDim *caldim;

  int npix = header[0].image_structure->number_of_columns;
  int nlin = header[0].image_structure->number_of_lines;
  size_t npixperseg = npix*nlin;

  size_t total_size = totalsegs*npixperseg;
  MSG_SAMPLE *pixels = new MSG_SAMPLE[total_size];
  memset(pixels, 0, total_size*sizeof(MSG_SAMPLE));
  size_t pos = 0;
  for (int i = 0; i < totalsegs; i ++)
  {
    if (segsindexes[i] >= 0)
      memcpy(pixels+pos, msgdat[segsindexes[i]].image->data,
             npixperseg*sizeof(MSG_SAMPLE));
    pos += npixperseg;
  }

  nlin = nlin*totalsegs;

  // Manage subarea
  if (is_subarea)
  {
    if (AreaLinStart < 0                             ||
        AreaLinStart > nlin - AreaNlin ||
        AreaNlin > nlin - AreaLinStart)
    {
      std::cerr << "Wrong Subarea in lines...." << std::endl;
      throw;
    }
    if (AreaPixStart < 0               ||
        AreaPixStart > npix - AreaNpix ||
        AreaNpix > npix - AreaPixStart)
    {
      std::cerr << "Wrong Subarea in Pixels...." << std::endl;
      throw;
    }
    size_t newsize = AreaNpix * AreaNlin;
    MSG_SAMPLE *newpix = new MSG_SAMPLE[newsize];
    memset(newpix, 0, newsize*sizeof(MSG_SAMPLE));
    for (int i = 0; i < AreaNlin; i ++)
      memcpy(newpix + i * AreaNpix,
             pixels + (AreaLinStart + i) * npix + AreaPixStart,
             AreaNpix * sizeof(MSG_SAMPLE));
    delete [ ] pixels;
    pixels = newpix;
    total_size = newsize;
  }
  else
  {
    AreaNpix = npix;
    AreaNlin = nlin;
  }

  tmtime = PRO_data->prologue->image_acquisition.PlannedAquisitionTime.TrueRepeatCycleStart.get_timestruct( );
  t_enum_MSG_spacecraft spc = header[0].segment_id->spacecraft_id;
  uint_1 chn = header[0].segment_id->spectral_channel_id;
  float sublon = header[0].image_navigation->subsatellite_longitude;
  int cfac = header[0].image_navigation->column_scaling_factor;
  int lfac = header[0].image_navigation->line_scaling_factor;
  int coff = header[0].image_navigation->column_offset;
  int loff = header[0].image_navigation->line_offset;
  float sh = header[0].image_navigation->satellite_h;

  char *channelstring = strdup(MSG_channel_name(spc, chn).c_str( ));
  char *channel = chname(channelstring, strlen(channelstring) + 1);

  // Build up output NetCDF file name and open it
  sprintf( NcName, "%s_%4d%02d%02d_%02d%02d.nc", channel,
           tmtime->tm_year + 1900, tmtime->tm_mon + 1, tmtime->tm_mday,
	   tmtime->tm_hour, tmtime->tm_min );
  NcFile ncf ( NcName , NcFile::Replace );
  if (! ncf.is_valid()) return false;

  // Fill arrays on creation
  ncf.set_fill(NcFile::Fill);

  // Add Global Attributes
  if (! ncf.add_att("Satellite", MSG_spacecraft_name(spc).c_str()))
	            return false;
  sprintf(reftime, "%04d-%02d-%02d %02d:%02d:00 UTC",
      tmtime->tm_year + 1900, tmtime->tm_mon + 1, tmtime->tm_mday,
      tmtime->tm_hour, tmtime->tm_min);
  if (! ncf.add_att("Antenna", "Fixed") ) return false;
  if (! ncf.add_att("Receiver", "HIMET") ) return false;
  if (! ncf.add_att("Time", reftime) ) return false;
  if (! ncf.add_att("Area_Name", "SpaceView" ) ) return false;
  sprintf(projname, "GEOS(%3.1f)", sublon);
  if (! ncf.add_att("Projection", projname) ) return false;
  if (! ncf.add_att("Columns", AreaNpix ) ) return false;
  if (! ncf.add_att("Lines", AreaNlin ) ) return false;
  if (! ncf.add_att("SampleX", 1.0 ) ) return false;
  if (! ncf.add_att("SampleY", 1.0 ) ) return false;
  if (! ncf.add_att("AreaStartPix", AreaPixStart ) ) return false;
  if (! ncf.add_att("AreaStartLin", AreaLinStart ) ) return false;
  if (! ncf.add_att("Column_Scale_Factor", cfac) ) return false;
  if (! ncf.add_att("Line_Scale_Factor", lfac) ) return false;
  if (! ncf.add_att("Column_Offset", coff) ) return false;
  if (! ncf.add_att("Line_Offset", loff) ) return false;
  if (! ncf.add_att("Orbit_Radius", sh) ) return false;
  if (! ncf.add_att("Longitude", sublon) ) return false;
  if (! ncf.add_att("NortPolar", 1) ) return false;
  if (! ncf.add_att("NorthSouth", 1) ) return false;
  if (! ncf.add_att("title", TITLE) ) return false;
  if (! ncf.add_att("Institution", INSTITUTION) ) return false;
  if (! ncf.add_att("Type", TYPE) ) return false;
  if (! ncf.add_att("Version", HIMET_VERSION) ) return false;
  if (! ncf.add_att("Conventions", "COARDS") ) return false;
  if (! ncf.add_att("history", "Created from raw data") ) return false;

  // Dimensions
  wd = AreaNpix;
  hg = AreaNlin;
  bpp = header[0].image_structure->number_of_bits_per_pixel;
  ncal = (int) pow(2.0, bpp);

  tdim = ncf.add_dim("time");
  if (!tdim->is_valid()) return false;
  ldim = ncf.add_dim("line", hg);
  if (!ldim->is_valid()) return false;
  cdim = ncf.add_dim("column", wd);
  if (!cdim->is_valid()) return false;
  caldim = ncf.add_dim("calibration", ncal);
  if (!caldim->is_valid()) return false;

  // Get calibration values
  cal = PRO_data->prologue->radiometric_proc.get_calibration((int) chn, bpp);

  // Add Calibration values
  NcVar *cvar = ncf.add_var("calibration", ncFloat, caldim);
  if (!cvar->is_valid()) return false;
  cvar->add_att("long_name", "Calibration coefficients");
  cvar->add_att("variable", channel);
  if (chn > 3 && chn < 12)
    cvar->add_att("units", "K");
  else
    cvar->add_att("units", "mW m^-2 sr^-1 (cm^-1)^-1");
  if (!cvar->put(cal, ncal)) return false;

  tvar = ncf.add_var("time", ncDouble, tdim);
  if (!tvar->is_valid()) return false;
  tvar->add_att("long_name", "Time");
  tvar->add_att("units", "seconds since 2000-01-01 00:00:00 UTC");
  double atime;
  time_t ttime;
  extern long timezone;
  ttime = mktime(tmtime);
  atime = ttime - 946684800 - timezone;
  if (!tvar->put(&atime, 1)) return false;

  ivar = ncf.add_var(channel, ncShort, tdim, ldim, cdim);
  if (!ivar->is_valid()) return false;
  if (!ivar->add_att("add_offset", 0.0)) return false;
  if (!ivar->add_att("scale_factor", 1.0)) return false;
  if (!ivar->add_att("chnum", chn)) return false;

  // Write output values
  if (!ivar->put((const short int *) pixels, 1, hg, wd)) return false;

  // Close NetCDF output
  (void) ncf.close( );

  delete [ ] pixels;
  delete [ ] cal;

  return( true );
}
示例#28
0
文件: encode.c 项目: lmangani/baresip
int opus_encode_update(struct auenc_state **aesp, const struct aucodec *ac,
		       struct auenc_param *param, const char *fmtp)
{
	struct auenc_state *aes;
	struct opus_param prm, conf_prm;
	opus_int32 fch, vbr;
	const struct aucodec *auc = ac;

	(void)param;

	if (!aesp || !ac || !ac->ch)
		return EINVAL;

	debug("opus: encoder fmtp (%s)\n", fmtp);

	/* Save the incoming OPUS parameters from SDP offer */
	if (str_isset(fmtp)) {
		opus_mirror_params(fmtp);
	}

	aes = *aesp;

	if (!aes) {
		const opus_int32 complex = 10;
		int opuserr;

		aes = mem_zalloc(sizeof(*aes), destructor);
		if (!aes)
			return ENOMEM;

		aes->ch = ac->ch;

		aes->enc = opus_encoder_create(ac->srate, ac->ch,
					       /* this has big impact on cpu */
					       OPUS_APPLICATION_AUDIO,
					       &opuserr);
		if (!aes->enc) {
			warning("opus: encoder create: %s\n",
				opus_strerror(opuserr));
			mem_deref(aes);
			return ENOMEM;
		}

		(void)opus_encoder_ctl(aes->enc, OPUS_SET_COMPLEXITY(complex));

		*aesp = aes;
	}

	prm.srate      = 48000;
	prm.bitrate    = OPUS_AUTO;
	prm.stereo     = 1;
	prm.cbr        = 0;
	prm.inband_fec = 0;
	prm.dtx        = 0;

	opus_decode_fmtp(&prm, fmtp);

	conf_prm.bitrate = OPUS_AUTO;
	opus_decode_fmtp(&conf_prm, auc->fmtp);

	if ((prm.bitrate == OPUS_AUTO) ||
	    ((conf_prm.bitrate != OPUS_AUTO) &&
	     (conf_prm.bitrate < prm.bitrate)))
		prm.bitrate = conf_prm.bitrate;

	fch = prm.stereo ? OPUS_AUTO : 1;
	vbr = prm.cbr ? 0 : 1;

	(void)opus_encoder_ctl(aes->enc,
			       OPUS_SET_MAX_BANDWIDTH(srate2bw(prm.srate)));
	(void)opus_encoder_ctl(aes->enc, OPUS_SET_BITRATE(prm.bitrate));
	(void)opus_encoder_ctl(aes->enc, OPUS_SET_FORCE_CHANNELS(fch));
	(void)opus_encoder_ctl(aes->enc, OPUS_SET_VBR(vbr));
	(void)opus_encoder_ctl(aes->enc, OPUS_SET_INBAND_FEC(prm.inband_fec));
	(void)opus_encoder_ctl(aes->enc, OPUS_SET_DTX(prm.dtx));


#if 0
	{
	opus_int32 bw, complex;

	(void)opus_encoder_ctl(aes->enc, OPUS_GET_MAX_BANDWIDTH(&bw));
	(void)opus_encoder_ctl(aes->enc, OPUS_GET_BITRATE(&prm.bitrate));
	(void)opus_encoder_ctl(aes->enc, OPUS_GET_FORCE_CHANNELS(&fch));
	(void)opus_encoder_ctl(aes->enc, OPUS_GET_VBR(&vbr));
	(void)opus_encoder_ctl(aes->enc, OPUS_GET_INBAND_FEC(&prm.inband_fec));
	(void)opus_encoder_ctl(aes->enc, OPUS_GET_DTX(&prm.dtx));
	(void)opus_encoder_ctl(aes->enc, OPUS_GET_COMPLEXITY(&complex));

	debug("opus: encode bw=%s bitrate=%i fch=%s "
	      "vbr=%i fec=%i dtx=%i complex=%i\n",
	      bwname(bw), prm.bitrate, chname(fch),
	      vbr, prm.inband_fec, prm.dtx, complex);
	}
#endif

	return 0;
}
示例#29
0
文件: n10.c 项目: 00001/plan9port
void ptout1(void)
{
	int k;
	char *codep;
	int w, j, phyw;
	Tchar *q, i;
	static int oxfont = FT;	/* start off in roman */

	for (q = oline; q < olinep; q++) {
		i = *q;
		if (ismot(i)) {
			j = absmot(i);
			if (isnmot(i))
				j = -j;
			if (isvmot(i))
				lead += j;
			else 
				esc += j;
			continue;
		}
		if ((k = cbits(i)) <= ' ') {
			switch (k) {
			case ' ': /*space*/
				esc += t.Char;
				break;
			case '\033':
			case '\007':
			case '\016':
			case '\017':
				oput(k);
				break;
			}
			continue;
		}
		phyw = w = t.Char * t.tfont.wp[k].wid;
		if (iszbit(i))
			w = 0;
		if (esc || lead)
			move();
		esct += w;
		xfont = fbits(i);
		if (xfont != oxfont) {
			switch (oxfont) {
			case ULFONT:	oputs(t.itoff); break;
			case BDFONT:	oputs(t.bdoff); break;
			case BIFONT:	oputs(t.itoff); oputs(t.bdoff); break;
			}
			switch (xfont) {
			case ULFONT:
				if (*t.iton & 0377) oputs(t.iton); break;
			case BDFONT:
				if (*t.bdon & 0377) oputs(t.bdon); break;
			case BIFONT:
				if (*t.bdon & 0377) oputs(t.bdon);
				if (*t.iton & 0377) oputs(t.iton);
				break;
			}
			oxfont = xfont;
		}
		if ((xfont == ulfont || xfont == BIFONT) && !(*t.iton & 0377)) {
			for (j = w / t.Char; j > 0; j--)
				oput('_');
			for (j = w / t.Char; j > 0; j--)
				oput('\b');
		}
		if (!(*t.bdon & 0377) && ((j = bdtab[xfont]) || xfont == BDFONT || xfont == BIFONT))
			j++;
		else
			j = 1;	/* number of overstrikes for bold */
		if (k < ALPHABET) {	/* ordinary ascii */
			oput(k);
			while (--j > 0) {
				oput('\b');
				oput(k);
			}
		} else if (k >= t.tfont.nchars) {	/* BUG -- not really understood */
/* fprintf(stderr, "big char %d, name %s\n", k, chname(k)); /* */
			oputs(chname(k)+1);	/* BUG: should separate Troffchar and MBchar... */
		} else if (t.tfont.wp[k].str == 0) {
/* fprintf(stderr, "nostr char %d, name %s\n", k, chname(k)); /* */
			oputs(chname(k)+1);	/* BUG: should separate Troffchar and MBchar... */
		} else if (t.tfont.wp[k].str[0] == MBchar) {	/* parse() puts this on */
/* fprintf(stderr, "MBstr char %d, name %s\n", k, chname(k)); /* */
			oputs(t.tfont.wp[k].str+1);
		} else {
			int oj = j;
/* fprintf(stderr, "str char %d, name %s\n", k, chname(k)); /* */
			codep = t.tfont.wp[k].str+1;	/* Troffchar by default */
			while (*codep != 0) {
				if (*codep & 0200) {
					codep = plot(codep);
					oput(' ');
				} else {
					if (*codep == '%')	/* escape */
						codep++;
					oput(*codep);
					if (*codep == '\033')
						oput(*++codep);
					else if (*codep != '\b')
						for (j = oj; --j > 0; ) {
							oput('\b');
							oput(*codep);
						}
					codep++;
				}
			}
		}
		if (!w)
			for (j = phyw / t.Char; j > 0; j--)
				oput('\b');
	}
}