示例#1
0
文件: service.c 项目: FMNSSun/NoOS
NUSHORT srvc_register_service(NPCHAR name) {
#ifdef DEBUG_LVL_ONE
  vid_print("[ SRVC ] srvc_register_service: ",0x0A);
  vid_print(name,0x0A);
  vid_print("\r\n",0x07);
#endif
  struct SRVCEntry entry;
  entry.name = (NPCHAR)mem_alloc(nstrlen(name)+1);
#ifdef DEBUG_LVL_ONE
  vid_print("[ SRVC ] Name of service: ",0x0A);
  vid_print(name,0x0A); char buffer[256];
  vid_print(" ptr = ",0x0A); nultoa((NULONG)(NPVALUE)entry.name,16,buffer); vid_print(buffer,0xf);
  vid_print("\r\n",0x0A);
#endif
  NUSHORT i;
  NUINT len = nstrlen(name)+1;
  for(i=0;i<len;i++) {
    entry.name[i] = name[i];
  }
  entry.sid = srvc_sid;
  srvc_sid++;
  srvc_entries[srvc_index] = entry;
#ifdef DEBUG_LVL_ONE
  vid_print("[ SRVC ] Registered as: ",0x0A);
  vid_print(nitoa((int)srvc_entries[srvc_index].sid,10),0x0A);
  vid_print("\r\n",0x07);
#endif
  srvc_index++;
  return entry.sid;
}
示例#2
0
文件: service.c 项目: FMNSSun/NoOS
NVALUE srvc_dump(NPVALUE none) {
  int i;
  for(i=0;i<SRVC_SIZE;i++) {
    if(srvc_entries[i].sid != 0) {
      vid_print(srvc_entries[i].name,0x0A); vid_print (" at ",0x0A); vid_print(nitoa((int)srvc_entries[i].sid,10),0x0A); vid_print("\r\n",0x0A);
    }
  }
}
示例#3
0
// Helper function: prepare for the buffer message with network costs to send.
char *prepare_buffer_message(char *buffer) {
    char cost[MESSAGE_PART_LENGTH];
    int i, j;
    for (i = 0; i < NUM_SERVER; i++) {
        nitoa(server_cost[i], cost, 10);
        for (j = 0; j < MESSAGE_PART_LENGTH - 1; j++) {
            buffer[i * (MESSAGE_PART_LENGTH - 1) + j] = cost[j];
        }
    }
    buffer[TCP_MESSAGE_LENGTH - 2] = SERVER_NAME_CHAR;
    buffer[TCP_MESSAGE_LENGTH - 1] = '\0';
    return buffer;
}
示例#4
0
文件: fuzed.cpp 项目: dave18/Fuzed
void PutNumberLeadingZeros(char* b,int v,int n)
{
    nitoa(v,b,10);
    int l=strlen(b);
    if (l<n)
    {
        int z=0;
        for (z=0;z<=l;z++)
        {
            b[n-l+z]=b[z];
        }
        for (z=0;z<(n-l);z++)
        {
            b[z]='0';
        }
        b[n]=0;

    }

}
示例#5
0
文件: service.c 项目: FMNSSun/NoOS
NUSHORT srvc_get_id(NPCHAR name) { 
  NUSHORT i;
  for(i=0;i<SRVC_SIZE;i++) {
    
    if(nstrlen(srvc_entries[i].name) != nstrlen(name)) continue;
    if(nstrcmp(srvc_entries[i].name,name) != 1) continue;
#ifdef DEBUG_LVL_TWO
    vid_print("[ SRVC ] Found as: ",0x0A);
    vid_print(nitoa((int)srvc_entries[i].sid,10),0x0A);
    vid_print("\r\n",0x07);
    vid_print(srvc_entries[i].name,0x08);
    vid_print(" /SRVC\r\n",0x08);
#endif
    return srvc_entries[i].sid;
  }
#ifdef DEBUG_LVL_TWO
  vid_print("[ SRVC ] srvc_get_id could not find this service :(\r\n",0x04);
  vid_print(name,0x4);
#endif
  //kstop();
  return 0;
}