s3/libsmb: adjust smb2 code for new idl structs & generated ndr push/pull funcs.
[samba.git] / source3 / libsmb / clirap2.c
index 05d8fb2a291f790a3efe1f9f7496f94a91182e0e..3dd299c1cb33f25b56942fde62cc5e5d9499c694 100644 (file)
@@ -218,7 +218,7 @@ static size_t rap_getstringp(TALLOC_CTX *ctx, char *p, char **dest, char *r, uin
        return 4;
 }
 
-static char *make_header(char *param, uint16 apinum, const char *reqfmt, const char *datafmt)
+static char *make_header(char *param, uint16_t apinum, const char *reqfmt, const char *datafmt)
 {
        PUTWORD(param,apinum);
        if (reqfmt)
@@ -331,7 +331,7 @@ int cli_NetGroupAdd(struct cli_state *cli, struct rap_group_info_1 *grinfo)
 
        if (cli_api(cli,
              param, sizeof(param), 1024, /* Param, length, maxlen */
-             data, soffset, sizeof(data), /* data, length, maxlen */
+             data, soffset, data_size, /* data, length, maxlen */
              &rparam, &rprcnt,   /* return params, length */
              &rdata, &rdrcnt))   /* return data, length */
        {
@@ -867,10 +867,8 @@ int cli_NetUserAdd(struct cli_state *cli, struct rap_user_info_1 * userinfo )
 
        PUTWORD(p, 1); /* info level */
        PUTWORD(p, 0); /* pwencrypt */
-       if(userinfo->passwrd)
-               PUTWORD(p,MIN(strlen((const char *)userinfo->passwrd), RAP_UPASSWD_LEN));
-       else
-               PUTWORD(p, 0); /* password length */
+       PUTWORD(p, MIN(strlen((const char *)userinfo->passwrd),
+                      RAP_UPASSWD_LEN));
 
        p = data;
        memset(data, '\0', soffset);
@@ -1099,7 +1097,7 @@ int cli_RNetUserEnum0(struct cli_state *cli,
  Call a NetFileClose2 - close open file on another session to server.
 ****************************************************************************/
 
-int cli_NetFileClose(struct cli_state *cli, uint32 file_id )
+int cli_NetFileClose(struct cli_state *cli, uint32_t file_id )
 {
        char *rparam = NULL;
        char *rdata = NULL;
@@ -1147,7 +1145,7 @@ int cli_NetFileClose(struct cli_state *cli, uint32 file_id )
  workstation.
 ****************************************************************************/
 
-int cli_NetFileGetInfo(struct cli_state *cli, uint32 file_id, void (*fn)(const char *, const char *, uint16, uint16, uint32))
+int cli_NetFileGetInfo(struct cli_state *cli, uint32_t file_id, void (*fn)(const char *, const char *, uint16_t, uint16_t, uint32_t))
 {
        char *rparam = NULL;
        char *rdata = NULL;
@@ -1247,8 +1245,8 @@ int cli_NetFileGetInfo(struct cli_state *cli, uint32 file_id, void (*fn)(const c
 
 int cli_NetFileEnum(struct cli_state *cli, const char * user,
                    const char * base_path,
-                   void (*fn)(const char *, const char *, uint16, uint16,
-                              uint32))
+                   void (*fn)(const char *, const char *, uint16_t, uint16_t,
+                              uint32_t))
 {
        char *rparam = NULL;
        char *rdata = NULL;
@@ -1547,150 +1545,6 @@ bool cli_get_pdc_name(struct cli_state *cli, const char *workgroup, char **pdc_n
        return(count > 0);
 }
 
-/*************************************************************************
-*
-* Function Name:  cli_get_server_domain
-*
-* PURPOSE:  Remotes a NetWkstaGetInfo API call to the current server
-*           requesting wksta_info_10 level information to determine
-*           the domain the server belongs to. On success, this
-*           routine sets the server_domain field in the cli_state structure
-*           to the server's domain name.
-*
-* Dependencies: none
-*
-* Parameters:
-*             cli       - pointer to cli_state structure
-*
-* Returns:
-*             True      - success
-*             False     - failure
-*
-* Origins:  samba 2.0.6 source/libsmb/clientgen.c cli_NetServerEnum()
-*
-************************************************************************/
-
-bool cli_get_server_domain(struct cli_state *cli)
-{
-       char *rparam = NULL;
-       char *rdata = NULL;
-       unsigned int rdrcnt,rprcnt;
-       char *p;
-       char param[WORDSIZE                      /* api number    */
-                       +sizeof(RAP_WWkstaGetInfo_REQ) /* req string    */
-                       +sizeof(RAP_WKSTA_INFO_L10)    /* return string */
-                       +WORDSIZE                      /* info level    */
-                       +WORDSIZE];                    /* buffer size   */
-       int res = -1;
-
-       /* send a SMBtrans command with api NetWkstaGetInfo */
-       p = make_header(param, RAP_WWkstaGetInfo,
-               RAP_WWkstaGetInfo_REQ, RAP_WKSTA_INFO_L10);
-       PUTWORD(p, 10); /* info level */
-       PUTWORD(p, CLI_BUFFER_SIZE);
-
-       if (cli_api(cli, param, PTR_DIFF(p,param), 8, /* params, length, max */
-                       NULL, 0, CLI_BUFFER_SIZE,         /* data, length, max */
-                       &rparam, &rprcnt,         /* return params, return size */
-                       &rdata, &rdrcnt)) {       /* return data, return size */
-               char *endp = rparam + rprcnt;
-               res = GETRES(rparam, endp);
-
-               if (res == 0) {
-                       TALLOC_CTX *frame = talloc_stackframe();
-                       char *server_domain;
-                       int converter = 0;
-
-                       p = rparam + WORDSIZE;
-                       GETWORD(p, converter, endp);
-
-                       p = rdata + DWORDSIZE + DWORDSIZE; /* skip computer & user names */
-                       endp = rdata + rdrcnt;
-                       p += rap_getstringp(frame,
-                               p,
-                               &server_domain,
-                               rdata,
-                               converter,
-                               endp);
-
-                       if (server_domain) {
-                               fstrcpy(cli->server_domain, server_domain);
-                       }
-                       TALLOC_FREE(frame);
-               }
-       }
-
-       SAFE_FREE(rparam);
-       SAFE_FREE(rdata);
-
-       return(res == 0);
-}
-
-/*************************************************************************
-*
-* Function Name:  cli_get_server_type
-*
-* PURPOSE:  Remotes a NetServerGetInfo API call to the current server
-*           requesting server_info_1 level information to retrieve
-*           the server type.
-*
-* Dependencies: none
-*
-* Parameters:
-*             cli       - pointer to cli_state structure
-*             pstype    - pointer to uint32 to contain returned server type
-*
-* Returns:
-*             True      - success
-*             False     - failure
-*
-* Origins:  samba 2.0.6 source/libsmb/clientgen.c cli_NetServerEnum()
-*
-************************************************************************/
-
-bool cli_get_server_type(struct cli_state *cli, uint32 *pstype)
-{
-       char *rparam = NULL;
-       char *rdata = NULL;
-       unsigned int rdrcnt,rprcnt;
-       char *p;
-       char param[WORDSIZE                       /* api number    */
-               +sizeof(RAP_WserverGetInfo_REQ) /* req string    */
-               +sizeof(RAP_SERVER_INFO_L1)     /* return string */
-               +WORDSIZE                       /* info level    */
-               +WORDSIZE];                     /* buffer size   */
-       int res = -1;
-
-       /* send a SMBtrans command with api NetServerGetInfo */
-       p = make_header(param, RAP_WserverGetInfo,
-               RAP_WserverGetInfo_REQ, RAP_SERVER_INFO_L1);
-       PUTWORD(p, 1); /* info level */
-       PUTWORD(p, CLI_BUFFER_SIZE);
-
-       if (cli_api(cli,
-                       param, PTR_DIFF(p,param), 8, /* params, length, max */
-                       NULL, 0, CLI_BUFFER_SIZE, /* data, length, max */
-                       &rparam, &rprcnt,         /* return params, return size */
-                       &rdata, &rdrcnt           /* return data, return size */
-                       )) {
-               char *endp = rparam + rprcnt;
-               res = GETRES(rparam,endp);
-
-               if (res == 0 || res == ERRmoredata) {
-                       p = rdata;
-                       endp = rparam + rprcnt;
-                       p += 18;
-                       GETDWORD(p,*pstype,endp);
-                       *pstype &= ~SV_TYPE_LOCAL_LIST_ONLY;
-               }
-       }
-
-       SAFE_FREE(rparam);
-       SAFE_FREE(rdata);
-
-       return(res == 0 || res == ERRmoredata);
-}
-
 bool cli_get_server_name(TALLOC_CTX *mem_ctx, struct cli_state *cli,
                         char **servername)
 {
@@ -1777,7 +1631,7 @@ bool cli_get_server_name(TALLOC_CTX *mem_ctx, struct cli_state *cli,
 *
 ************************************************************************/
 
-bool cli_ns_check_server_type(struct cli_state *cli, char *workgroup, uint32 stype)
+bool cli_ns_check_server_type(struct cli_state *cli, char *workgroup, uint32_t stype)
 {
        char *rparam = NULL;
        char *rdata = NULL;
@@ -1912,8 +1766,8 @@ bool cli_NetWkstaUserLogoff(struct cli_state *cli, const char *user, const char
 }
 
 int cli_NetPrintQEnum(struct cli_state *cli,
-               void (*qfn)(const char*,uint16,uint16,uint16,const char*,const char*,const char*,const char*,const char*,uint16,uint16),
-               void (*jfn)(uint16,const char*,const char*,const char*,const char*,uint16,uint16,const char*,unsigned int,unsigned int,const char*))
+               void (*qfn)(const char*,uint16_t,uint16_t,uint16_t,const char*,const char*,const char*,const char*,const char*,uint16_t,uint16_t),
+               void (*jfn)(uint16_t,const char*,const char*,const char*,const char*,uint16_t,uint16_t,const char*,unsigned int,unsigned int,const char*))
 {
        char param[WORDSIZE                         /* api number    */
                +sizeof(RAP_NetPrintQEnum_REQ)    /* req string    */
@@ -2020,7 +1874,7 @@ int cli_NetPrintQEnum(struct cli_state *cli,
                        if (jobcount) {
                                int j;
                                for (j=0;j<jobcount;j++) {
-                                       uint16 jid = 0, pos = 0, fsstatus = 0;
+                                       uint16_t jid = 0, pos = 0, fsstatus = 0;
                                        char ownername[RAP_USERNAME_LEN];
                                        char notifyname[RAP_MACHNAME_LEN];
                                        char datatype[RAP_DATATYPE_LEN];
@@ -2088,8 +1942,8 @@ int cli_NetPrintQEnum(struct cli_state *cli,
 }
 
 int cli_NetPrintQGetInfo(struct cli_state *cli, const char *printer,
-       void (*qfn)(const char*,uint16,uint16,uint16,const char*,const char*,const char*,const char*,const char*,uint16,uint16),
-       void (*jfn)(uint16,const char*,const char*,const char*,const char*,uint16,uint16,const char*,unsigned int,unsigned int,const char*))
+       void (*qfn)(const char*,uint16_t,uint16_t,uint16_t,const char*,const char*,const char*,const char*,const char*,uint16_t,uint16_t),
+       void (*jfn)(uint16_t,const char*,const char*,const char*,const char*,uint16_t,uint16_t,const char*,unsigned int,unsigned int,const char*))
 {
        char param[WORDSIZE                         /* api number    */
                +sizeof(RAP_NetPrintQGetInfo_REQ) /* req string    */
@@ -2349,7 +2203,7 @@ int cli_RNetServiceEnum(struct cli_state *cli, void (*fn)(const char *, const ch
  Call a NetSessionEnum - list workstations with sessions to an SMB server.
 ****************************************************************************/
 
-int cli_NetSessionEnum(struct cli_state *cli, void (*fn)(char *, char *, uint16, uint16, uint16, unsigned int, unsigned int, unsigned int, char *))
+int cli_NetSessionEnum(struct cli_state *cli, void (*fn)(char *, char *, uint16_t, uint16_t, uint16_t, unsigned int, unsigned int, unsigned int, char *))
 {
        char param[WORDSIZE                       /* api number    */
                +sizeof(RAP_NetSessionEnum_REQ) /* parm string   */
@@ -2449,7 +2303,7 @@ int cli_NetSessionEnum(struct cli_state *cli, void (*fn)(char *, char *, uint16,
 ****************************************************************************/
 
 int cli_NetSessionGetInfo(struct cli_state *cli, const char *workstation,
-               void (*fn)(const char *, const char *, uint16, uint16, uint16, unsigned int, unsigned int, unsigned int, const char *))
+               void (*fn)(const char *, const char *, uint16_t, uint16_t, uint16_t, unsigned int, unsigned int, unsigned int, const char *))
 {
        char param[WORDSIZE                          /* api number    */
                +sizeof(RAP_NetSessionGetInfo_REQ) /* req string    */