openblt

a hobby OS from the late 90s
git clone http://frotz.net/git/openblt.git
Log | Files | Refs | LICENSE

namer.cpp (912B)


      1 /* Copyright 1999, Brian J. Swetland. All rights reserved.
      2 ** Distributed under the terms of the OpenBLT License
      3 */
      4 
      5 #include <blt/Connection.h>
      6 #include <blt/Message.h>
      7 #include <blt/namer.h>
      8 #include <blt/syscall.h>
      9 
     10 #include <string.h>
     11 
     12 using namespace BLT;
     13 
     14 int namer_register(int port, const char *name)
     15 {
     16 	int32 res = -1;
     17 	Connection *cnxn = Connection::FindService("namer");
     18 	
     19 	if(cnxn){
     20 		Message msg;
     21 		msg.PutInt32('code',NAMER_REGISTER);
     22 		msg.PutInt32('port',port);
     23 		msg.PutString('name',name);
     24 		cnxn->Call(&msg,&msg);
     25 		msg.GetInt32('resp',&res);
     26 		delete cnxn;
     27 	}
     28 	
     29 	return res;
     30 }
     31 
     32 int namer_find(const char *name, int blocking)
     33 {
     34 	int32 res = -1;
     35 	Connection *cnxn;
     36 	
     37 	cnxn = Connection::FindService("namer");
     38 	
     39 	if(cnxn){
     40 		Message msg;
     41 		msg.PutInt32('code',NAMER_FIND);
     42 		msg.PutString('name',name);
     43 		cnxn->Call(&msg,&msg);
     44 		msg.GetInt32('resp',&res);
     45 		delete cnxn;
     46 	}
     47 	
     48 	return res;
     49 }
     50 
     51 
     52